Modified: trunk/Tools/ChangeLog (138175 => 138176)
--- trunk/Tools/ChangeLog 2012-12-19 17:42:35 UTC (rev 138175)
+++ trunk/Tools/ChangeLog 2012-12-19 17:45:46 UTC (rev 138176)
@@ -1,3 +1,16 @@
+2012-12-19 Julien Chaffraix <jchaffr...@webkit.org>
+
+ 2 clampTo unit tests are failing
+ https://bugs.webkit.org/show_bug.cgi?id=105253
+
+ Reviewed by Emil A Eklund.
+
+ Removed clampToUnsigned as it was actually testing exactly what
+ clampToUnsignedLong was doing. Also made clampToIntFloat more robust
+ to precision loss (fix suggested by Emil).
+
+ * TestWebKitAPI/Tests/WTF/MathExtras.cpp:
+
2012-12-19 Thiago Marcos P. Santos <thiago.san...@intel.com>
[EFL] Move ImageDiff to the Tools directory root
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp (138175 => 138176)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp 2012-12-19 17:42:35 UTC (rev 138175)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp 2012-12-19 17:45:46 UTC (rev 138176)
@@ -87,8 +87,7 @@
EXPECT_EQ(clampTo<int>(underflowInt), minInt);
}
-// https://bugs.webkit.org/show_bug.cgi?id=105253
-TEST(WTF, DISABLED_clampToIntegerFloat)
+TEST(WTF, clampToIntegerFloat)
{
// This test is inaccurate as floats will round the min / max integer
// due to the narrow mantissa. However it will properly checks within
@@ -101,10 +100,11 @@
EXPECT_GT(overflowInt, maxInt);
EXPECT_LT(underflowInt, minInt);
- EXPECT_EQ(clampToInteger(maxInt), maxInt);
+ // If maxInt == 2^31 - 1 (ie on I32 architecture), the closest float used to represent it is 2^31.
+ EXPECT_NEAR(clampToInteger(maxInt), maxInt, 1);
EXPECT_EQ(clampToInteger(minInt), minInt);
- EXPECT_EQ(clampToInteger(overflowInt), maxInt);
+ EXPECT_NEAR(clampToInteger(overflowInt), maxInt, 1);
EXPECT_EQ(clampToInteger(underflowInt), minInt);
}
@@ -145,17 +145,6 @@
EXPECT_EQ(clampToFloat(-std::numeric_limits<float>::infinity()), minFloat);
}
-// https://bugs.webkit.org/show_bug.cgi?id=105253
-TEST(WTF, DISABLED_clampToUnsigned)
-{
- unsigned long maxUnsigned = std::numeric_limits<unsigned>::max();
- unsigned long overflowUnsigned = maxUnsigned + 1;
- EXPECT_EQ(clampTo<unsigned>(maxUnsigned), maxUnsigned);
-
- EXPECT_EQ(clampTo<unsigned>(overflowUnsigned), maxUnsigned);
- EXPECT_EQ(clampTo<unsigned>(-1), 0u);
-}
-
TEST(WTF, clampToUnsignedLong)
{
if (sizeof(unsigned long) == sizeof(unsigned))