|
|
@@ -93,3 +93,32 @@ TEST_F(UnitSquareTest, PointOutsideSquare) {
|
|
|
INSTANTIATE_TEST_CASE_P(Contains, UnitSquareTest,
|
|
|
Combine(ValuesIn(generate(0.f, 1.f, 0.25f)),
|
|
|
ValuesIn(generate(0.f, 1.f, 0.25f))));
|
|
|
+
|
|
|
+struct LineQuadTest : TestWithParam<point> {};
|
|
|
+
|
|
|
+TEST_P(LineQuadTest, OriginLineIntersectsUnitSquare) {
|
|
|
+ square const unit{{{0, 0}}, 1};
|
|
|
+ line const ln{{{0, 0}}, GetParam()};
|
|
|
+ EXPECT_TRUE(math::intersects(ln, unit));
|
|
|
+}
|
|
|
+
|
|
|
+TEST_F(LineQuadTest, JustPointIntersection) {
|
|
|
+ square const unit{{{0, 0}}, 1};
|
|
|
+ line const ln{{{1, 1}}, {{2, 1}}};
|
|
|
+ EXPECT_TRUE(math::intersects(ln, unit));
|
|
|
+}
|
|
|
+
|
|
|
+TEST_F(LineQuadTest, EntirelyEncasedIntersection) {
|
|
|
+ square const unit{{{0, 0}}, 1};
|
|
|
+ line const ln{{{0.5, 0.5}}, {{0.75, 0.75}}};
|
|
|
+ EXPECT_TRUE(math::intersects(ln, unit));
|
|
|
+}
|
|
|
+
|
|
|
+TEST_F(LineQuadTest, OutsideByAnInch) {
|
|
|
+ square const unit{{{0, 0}}, 1};
|
|
|
+ line const ln{{{1.001, 1}}, {{2, 1}}};
|
|
|
+ math::intersects(ln, unit);
|
|
|
+ EXPECT_FALSE(math::intersects(ln, unit));
|
|
|
+}
|
|
|
+
|
|
|
+INSTANTIATE_TEST_CASE_P(Intersects, LineQuadTest, ValuesIn(line_ends));
|