summaryrefslogtreecommitdiff
path: root/basegfx/test/B2DRangeTest.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx/test/B2DRangeTest.cxx')
-rw-r--r--basegfx/test/B2DRangeTest.cxx28
1 files changed, 25 insertions, 3 deletions
diff --git a/basegfx/test/B2DRangeTest.cxx b/basegfx/test/B2DRangeTest.cxx
index 862fe7e5ba64..59384e26b697 100644
--- a/basegfx/test/B2DRangeTest.cxx
+++ b/basegfx/test/B2DRangeTest.cxx
@@ -30,6 +30,9 @@ class B2DRangeTest : public CppUnit::TestFixture
void testCreation()
{
basegfx::B2DRange aRange(1.2, 2.3, 3.5, 4.8);
+
+ CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(1.2, 2.3, 3.5, 4.8), aRange);
+
CPPUNIT_ASSERT_EQUAL(1.2, aRange.getMinX());
CPPUNIT_ASSERT_EQUAL(3.5, aRange.getMaxX());
CPPUNIT_ASSERT_EQUAL(2.3, aRange.getMinY());
@@ -37,6 +40,20 @@ class B2DRangeTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(2.3, aRange.getWidth());
CPPUNIT_ASSERT_EQUAL(2.5, aRange.getHeight());
+
+ // wrong order of the interval
+ basegfx::B2DRange aRange2(1.0, 1.0, 0.0, 0.0);
+
+ CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(1.0, 1.0, 0.0, 0.0), aRange2);
+ CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0), aRange2);
+
+ CPPUNIT_ASSERT_EQUAL(0.0, aRange2.getMinX());
+ CPPUNIT_ASSERT_EQUAL(0.0, aRange2.getMinY());
+ CPPUNIT_ASSERT_EQUAL(1.0, aRange2.getMaxX());
+ CPPUNIT_ASSERT_EQUAL(1.0, aRange2.getMaxY());
+
+ CPPUNIT_ASSERT_EQUAL(1.0, aRange2.getWidth());
+ CPPUNIT_ASSERT_EQUAL(1.0, aRange2.getHeight());
}
void testRound()
@@ -53,14 +70,19 @@ class B2DRangeTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(2.5, aRange.getCenterY());
}
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+ void testIntersect()
+ {
+ basegfx::B2DRange aRange(1.0, 1.0, 4.0, 4.0);
+ aRange.intersect(basegfx::B2DRange(0.0, 0.0, 2.0, 2.0));
+
+ CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(1.0, 1.0, 2.0, 2.0), aRange);
+ }
CPPUNIT_TEST_SUITE(B2DRangeTest);
CPPUNIT_TEST(testCreation);
CPPUNIT_TEST(testRound);
CPPUNIT_TEST(testCenter);
+ CPPUNIT_TEST(testIntersect);
CPPUNIT_TEST_SUITE_END();
};