summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-07-25 21:12:15 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-07-30 08:20:21 +0200
commiteb31491b2a419ba7e67cc0a59a9b295fe49526e5 (patch)
tree6f69a4022be636c2420bf9f03d89ba1928c9a289
parent151237558c3da083a45b29a98523366a8d438aeb (diff)
tools: use upper case GetWidth/GetHeight for Rect for repr. string
When a rectangle is written to a string stream (usually used for representation string in CPP unit tests) we used getWidth and getHeight. It turns out that this methods don't return the correct value for width / height (off by one) in many cases so instead we need to use the upper-case variants GetWidth/GetHeight. Change-Id: Id655236155f94e092d9e9c24f9bd6857e9b0a558 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119489 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--include/tools/gen.hxx2
-rw-r--r--tools/qa/cppunit/test_rectangle.cxx5
2 files changed, 6 insertions, 1 deletions
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 34ac425b7fc1..5386de129c56 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -813,7 +813,7 @@ inline std::basic_ostream<charT, traits> & operator <<(
if (rectangle.IsEmpty())
return stream << "EMPTY";
else
- return stream << rectangle.getWidth() << 'x' << rectangle.getHeight()
+ return stream << rectangle.GetWidth() << 'x' << rectangle.GetHeight()
<< "@(" << rectangle.getX() << ',' << rectangle.getY() << ")";
}
}
diff --git a/tools/qa/cppunit/test_rectangle.cxx b/tools/qa/cppunit/test_rectangle.cxx
index 00970e47c792..4e12b1d5933a 100644
--- a/tools/qa/cppunit/test_rectangle.cxx
+++ b/tools/qa/cppunit/test_rectangle.cxx
@@ -47,6 +47,11 @@ void Test::test_rectangle()
CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetWidth());
CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetHeight());
+ // Annoyingly getWidth and getHeight returns the wrong size
+ // that was explicitly inputed.
+ CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect.getWidth());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect.getHeight());
+
aRect.setX(12);
CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetHeight());
aRect.setY(12);