Browse Source

Add tests for circle-intersects circle.

Sam Jaffe 6 năm trước cách đây
mục cha
commit
bb7d0a9260
1 tập tin đã thay đổi với 30 bổ sung0 xóa
  1. 30 0
      math/test/common_test.cxx

+ 30 - 0
math/test/common_test.cxx

@@ -140,3 +140,33 @@ TEST_F(LineQuadTest, OutsideByAnInch) {
 }
 
 INSTANTIATE_TEST_CASE_P(Intersects, LineQuadTest, ValuesIn(line_ends));
+
+TEST(CircleTest, IntersectsSelf) {
+  circle const c1{{{0, 0}}, 1};
+  circle const c2{{{0, 0}}, 1};
+  EXPECT_TRUE(math::intersects(c1, c2));
+}
+
+TEST(CircleTest, IntersectsAtOnePoint) {
+  circle const c1{{{0, 0}}, 1};
+  circle const c2{{{0, 2}}, 1};
+  EXPECT_TRUE(math::intersects(c1, c2));
+}
+
+TEST(CircleTest, IntersectsWithChord) {
+  circle const c1{{{0, 0}}, 0.5};
+  circle const c2{{{0, 1}}, 0.5};
+  EXPECT_TRUE(math::intersects(c1, c2));
+}
+
+TEST(CircleTest, ContainedWithin) {
+  circle const c1{{{0, 0}}, 2};
+  circle const c2{{{0, 1}}, 0.5};
+  EXPECT_TRUE(math::intersects(c1, c2));
+}
+
+TEST(CircleTest, Outside) {
+  circle const c1{{{0, 0}}, 1};
+  circle const c2{{{1.5, 1.5}}, 1};
+  EXPECT_FALSE(math::intersects(c1, c2));
+}