diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/utils/rectangle.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/utils/rectangle.cpp b/test/utils/rectangle.cpp index f2fe93ea..0cfbece2 100644 --- a/test/utils/rectangle.cpp +++ b/test/utils/rectangle.cpp @@ -35,6 +35,8 @@ namespace usdx class RectangleTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(RectangleTest); CPPUNIT_TEST(testInit); + CPPUNIT_TEST(testIntersectInner); + CPPUNIT_TEST(testIntersectOuter); CPPUNIT_TEST_SUITE_END(); private: static log4cpp::Category& log; @@ -57,6 +59,30 @@ namespace usdx CPPUNIT_ASSERT(rect.get_width() == 200); CPPUNIT_ASSERT(rect.get_height() == 250); } + + void testIntersectInner() + { + Rectangle<int> outer(100, 150, 200, 250); + Rectangle<int> inner(120, 170, 180, 200); + Rectangle<int> intersect = outer.intersect(inner); + + CPPUNIT_ASSERT(intersect.get_point1().get_x() == 120); + CPPUNIT_ASSERT(intersect.get_point1().get_y() == 170); + CPPUNIT_ASSERT(intersect.get_point2().get_x() == 180); + CPPUNIT_ASSERT(intersect.get_point2().get_y() == 200); + } + + void testIntersectOuter() + { + Rectangle<int> outer(120, 170, 180, 200); + Rectangle<int> inner(100, 150, 200, 250); + Rectangle<int> intersect = outer.intersect(inner); + + CPPUNIT_ASSERT(intersect.get_point1().get_x() == 120); + CPPUNIT_ASSERT(intersect.get_point1().get_y() == 170); + CPPUNIT_ASSERT(intersect.get_point2().get_x() == 180); + CPPUNIT_ASSERT(intersect.get_point2().get_y() == 200); + } }; log4cpp::Category& RectangleTest::log = |