summaryrefslogtreecommitdiff
path: root/tools/qa/cppunit
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-08-17 11:18:39 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-08-17 22:32:22 +0200
commit17f524a37c81a05e6d448a7186df858a69ada635 (patch)
treeef6e48e8ba4850788e6773d5a438031b862cdd01 /tools/qa/cppunit
parente8180aa5e7c03fe62d958e9e147136abd99ddf82 (diff)
Fix o3tl::convert for Rectangle, to operate on right/bottom values
... instead of using confusing/ambiguous size having two interpretations. This reverts some of the unit test changes made in commit fa339b3adb53300ae68913bed87e18caf9f2e262. Change-Id: Ic56417703e32c1d92bcee76ad8ff494824bd4a1f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120564 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'tools/qa/cppunit')
-rw-r--r--tools/qa/cppunit/test_rectangle.cxx24
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);