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 |