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

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

Issue 2354783004: Fix overflow/underflow in gfx geometry once and for all (Closed)
Patch Set: Remove accessibility test changes Created 4 years, 2 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
« no previous file with comments | « ui/gfx/geometry/vector2d.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/vector2d_unittest.cc
diff --git a/ui/gfx/geometry/vector2d_unittest.cc b/ui/gfx/geometry/vector2d_unittest.cc
index 98d75f22bf8db6f5842e53aa1261ed8c504905b0..4bdf24cba4acefd6109bafb7ca7d890d8933678c 100644
--- a/ui/gfx/geometry/vector2d_unittest.cc
+++ b/ui/gfx/geometry/vector2d_unittest.cc
@@ -249,4 +249,45 @@ TEST(Vector2dTest, ClampVector2dF) {
EXPECT_EQ(Vector2dF(3.5f, 5.5f).ToString(), a.ToString());
}
+TEST(Vector2dTest, IntegerOverflow) {
+ int int_max = std::numeric_limits<int>::max();
+ int int_min = std::numeric_limits<int>::min();
+
+ Vector2d max_vector(int_max, int_max);
+ Vector2d min_vector(int_min, int_min);
+ Vector2d test;
+
+ test = Vector2d();
+ test += Vector2d(int_max, int_max);
+ EXPECT_EQ(test, max_vector);
+
+ test = Vector2d();
+ test += Vector2d(int_min, int_min);
+ EXPECT_EQ(test, min_vector);
+
+ test = Vector2d(10, 20);
+ test += Vector2d(int_max, int_max);
+ EXPECT_EQ(test, max_vector);
+
+ test = Vector2d(-10, -20);
+ test += Vector2d(int_min, int_min);
+ EXPECT_EQ(test, min_vector);
+
+ test = Vector2d();
+ test -= Vector2d(int_max, int_max);
+ EXPECT_EQ(test, Vector2d(-int_max, -int_max));
+
+ test = Vector2d();
+ test -= Vector2d(int_min, int_min);
+ EXPECT_EQ(test, max_vector);
+
+ test = Vector2d(10, 20);
+ test -= Vector2d(int_min, int_min);
+ EXPECT_EQ(test, max_vector);
+
+ test = Vector2d(-10, -20);
+ test -= Vector2d(int_max, int_max);
+ EXPECT_EQ(test, min_vector);
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/geometry/vector2d.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698