diff options
Diffstat (limited to 'tools/qa/cppunit/test_rectangle.cxx')
-rw-r--r-- | tools/qa/cppunit/test_rectangle.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/qa/cppunit/test_rectangle.cxx b/tools/qa/cppunit/test_rectangle.cxx index 29aa6cde94df..e213ed28daf8 100644 --- a/tools/qa/cppunit/test_rectangle.cxx +++ b/tools/qa/cppunit/test_rectangle.cxx @@ -68,6 +68,30 @@ void Test::test_rectangle() aRect2.SetSize(Size(-1, -2)); CPPUNIT_ASSERT_EQUAL(aRect, aRect2); } + + { + constexpr tools::Rectangle aRectTwip(100, 100, 100, 100); + constexpr tools::Rectangle aRectMm100( + o3tl::convert(aRectTwip, o3tl::Length::twip, o3tl::Length::mm100)); + static_assert(!aRectMm100.IsEmpty()); + // Make sure that we use coordinates for conversion, not width/height: + // the latter is ambiguous, and e.g. GetWidth(aRectTwip) gives 1, which + // would had been converted to 2, resulting in different LR coordinates + static_assert(aRectMm100.Left() == aRectMm100.Right()); + static_assert(aRectMm100.Top() == aRectMm100.Bottom()); + } + + { + constexpr tools::Rectangle aRectTwip(1, 1); + constexpr tools::Rectangle aRectMm100( + o3tl::convert(aRectTwip, o3tl::Length::twip, o3tl::Length::mm100)); + // Make sure that result keeps the empty flag + static_assert(aRectMm100.IsEmpty()); + static_assert(aRectMm100.IsWidthEmpty()); + static_assert(aRectMm100.IsHeightEmpty()); + static_assert(aRectMm100.GetWidth() == 0); + static_assert(aRectMm100.GetHeight() == 0); + } } CPPUNIT_TEST_SUITE_REGISTRATION(Test); |