[Libreoffice-commits] core.git: include/tools tools/qa

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 30 06:20:54 UTC 2021


 include/tools/gen.hxx               |    2 +-
 tools/qa/cppunit/test_rectangle.cxx |    5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

New commits:
commit eb31491b2a419ba7e67cc0a59a9b295fe49526e5
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Jul 25 21:12:15 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Jul 30 08:20:21 2021 +0200

    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 at gmail.com>

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);


More information about the Libreoffice-commits mailing list