Title: [259704] trunk/Tools
- Revision
- 259704
- Author
- [email protected]
- Date
- 2020-04-07 22:46:25 -0700 (Tue, 07 Apr 2020)
Log Message
[Clang 10] Fix -Wimplicit-int-float-conversion compilation warnings in TestWebKitAPI
https://bugs.webkit.org/show_bug.cgi?id=210067
Reviewed by Darin Adler.
There are test cases for overflow, non-overflow, underflow and
non-underflow edge cases in WTF.clampToIntegerFloat test.
maxPlusOne<int> can be used for overflow edge case, INT_MIN for
non-underflow. This change added code to calculate values for
non-overflow and underflow cases.
* TestWebKitAPI/Tests/WTF/MathExtras.cpp:
(TestWebKitAPI::TEST(WTF.clampToIntegerFloat)):
* TestWebKitAPI/Tests/WebCore/FloatRect.cpp:
(TestWebKitAPI::TEST(FloatRect.EnclosingIntRect)): Replaced
shiftMaxXEdgeTo(INT_MAX) with shiftMaxXEdgeTo(0) because it also
causes overflow for enclosingIntRect.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (259703 => 259704)
--- trunk/Tools/ChangeLog 2020-04-08 04:45:45 UTC (rev 259703)
+++ trunk/Tools/ChangeLog 2020-04-08 05:46:25 UTC (rev 259704)
@@ -1,3 +1,23 @@
+2020-04-07 Fujii Hironori <[email protected]>
+
+ [Clang 10] Fix -Wimplicit-int-float-conversion compilation warnings in TestWebKitAPI
+ https://bugs.webkit.org/show_bug.cgi?id=210067
+
+ Reviewed by Darin Adler.
+
+ There are test cases for overflow, non-overflow, underflow and
+ non-underflow edge cases in WTF.clampToIntegerFloat test.
+ maxPlusOne<int> can be used for overflow edge case, INT_MIN for
+ non-underflow. This change added code to calculate values for
+ non-overflow and underflow cases.
+
+ * TestWebKitAPI/Tests/WTF/MathExtras.cpp:
+ (TestWebKitAPI::TEST(WTF.clampToIntegerFloat)):
+ * TestWebKitAPI/Tests/WebCore/FloatRect.cpp:
+ (TestWebKitAPI::TEST(FloatRect.EnclosingIntRect)): Replaced
+ shiftMaxXEdgeTo(INT_MAX) with shiftMaxXEdgeTo(0) because it also
+ causes overflow for enclosingIntRect.
+
2020-04-07 Aakash Jain <[email protected]>
[ews] Add unit tests for layout tests factories
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp (259703 => 259704)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp 2020-04-08 04:45:45 UTC (rev 259703)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp 2020-04-08 05:46:25 UTC (rev 259704)
@@ -93,20 +93,24 @@
// This test is inaccurate as floats will round the min / max integer
// due to the narrow mantissa. However it will properly checks within
// (close to the extreme) and outside the integer range.
- float maxInt = std::numeric_limits<int>::max();
+ float overflowInt = maxPlusOne<int>;
+ float maxInt = overflowInt;
+ for (int i = 0; overflowInt == maxInt; i++)
+ maxInt = overflowInt - i;
+
float minInt = std::numeric_limits<int>::min();
- float overflowInt = maxInt * 1.1;
- float underflowInt = minInt * 1.1;
+ float underflowInt = minInt;
+ for (int i = 0; underflowInt == minInt; i++)
+ underflowInt = minInt - i;
EXPECT_GT(overflowInt, maxInt);
EXPECT_LT(underflowInt, minInt);
- // 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(maxInt), static_cast<int>(maxInt));
+ EXPECT_EQ(clampToInteger(minInt), std::numeric_limits<int>::min());
- EXPECT_NEAR(clampToInteger(overflowInt), maxInt, 1);
- EXPECT_EQ(clampToInteger(underflowInt), minInt);
+ EXPECT_EQ(clampToInteger(overflowInt), std::numeric_limits<int>::max());
+ EXPECT_EQ(clampToInteger(underflowInt), std::numeric_limits<int>::min());
}
TEST(WTF, clampToIntegerDouble)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/FloatRect.cpp (259703 => 259704)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/FloatRect.cpp 2020-04-08 04:45:45 UTC (rev 259703)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/FloatRect.cpp 2020-04-08 05:46:25 UTC (rev 259704)
@@ -770,8 +770,8 @@
EXPECT_EQ(789, enclosed.maxY());
WebCore::FloatRect maxIntRect(INT_MIN, INT_MIN, 0, 0);
- maxIntRect.shiftMaxXEdgeTo(INT_MAX);
- maxIntRect.shiftMaxYEdgeTo(INT_MAX);
+ maxIntRect.shiftMaxXEdgeTo(30);
+ maxIntRect.shiftMaxYEdgeTo(30);
auto enclosed2 = WebCore::enclosingIntRect(maxIntRect);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes