diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-02-07 12:27:55 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-02-08 02:44:02 +0000 |
commit | c97950cdb22fd9135ebb127a78f8497da7478ebd (patch) | |
tree | 1b872e7cd08793b54a76ba30b1b110db081ff5e8 /basegfx/test/B2DRangeTest.cxx | |
parent | 9d44236a62bf59d120dda89924d0d1407b2bd52b (diff) |
basegfx: restructure B1DRange and B2DRange tests and add use cases
Change-Id: I423171e886e56a0fa107c58edee7bf8a2259a6fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146600
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'basegfx/test/B2DRangeTest.cxx')
-rw-r--r-- | basegfx/test/B2DRangeTest.cxx | 28 |
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(); }; |