Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Unified Diff: ui/gfx/geometry/rect_unittest.cc

Issue 2268423003: Adjust gfx::Rect's width and height to avoid integer overflow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also fix width Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/gfx/geometry/rect.h ('K') | « ui/gfx/geometry/rect.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/rect_unittest.cc
diff --git a/ui/gfx/geometry/rect_unittest.cc b/ui/gfx/geometry/rect_unittest.cc
index be4b462073671ccef217627f2c6977be5299ff08..aad1acfb13f367c97987e2fb85e46450c28d04fc 100644
--- a/ui/gfx/geometry/rect_unittest.cc
+++ b/ui/gfx/geometry/rect_unittest.cc
@@ -915,4 +915,20 @@ TEST(RectTest, ManhattanInternalDistance) {
f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.5f, 1.0f)));
}
+TEST(RectTest, IntegerOverflow) {
+ Rect height_overflow(0, std::numeric_limits<int>::max() - 10, 100, 100);
+ EXPECT_EQ(10, height_overflow.height());
danakj 2016/08/25 17:59:21 can you EXPECT_EQ(max(), height_overflow.bottom())
sunxd 2016/08/25 19:25:09 Acknowledged.
+
+ Rect width_overflow(std::numeric_limits<int>::max() - 10, 0, 100, 100);
+ EXPECT_EQ(10, width_overflow.width());
+
+ Rect size_height_overflow(Point(0, std::numeric_limits<int>::max() - 10),
+ Size(100, 100));
+ EXPECT_EQ(10, size_height_overflow.height());
+
+ Rect size_width_overflow(Point(std::numeric_limits<int>::max() - 10, 0),
+ Size(100, 100));
+ EXPECT_EQ(10, size_width_overflow.width());
+}
+
} // namespace gfx
« ui/gfx/geometry/rect.h ('K') | « ui/gfx/geometry/rect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698