[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - tools/qa

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 9 11:42:58 UTC 2020


 tools/qa/cppunit/test_100mm2twips.cxx |   38 +++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 14 deletions(-)

New commits:
commit 20e02bc30ada3c824a6d025d96af1b1de8a608e9
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu May 21 11:47:34 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jun 9 13:42:27 2020 +0200

    tools: extend test for UnitConversion
    
    Change-Id: I8fbc2a83f40fb04656f690b4b63d3cac9f0410c1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95273
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit b1c007cd06c01078df481e020d9d81afd4de6a91)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95835
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/tools/qa/cppunit/test_100mm2twips.cxx b/tools/qa/cppunit/test_100mm2twips.cxx
index 80ceda2ffb3f..bfed8c2e2ba9 100644
--- a/tools/qa/cppunit/test_100mm2twips.cxx
+++ b/tools/qa/cppunit/test_100mm2twips.cxx
@@ -23,29 +23,39 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include <tools/helpers.hxx>
+#include <tools/UnitConversion.hxx>
 
-namespace tools
-{
-class cm2TwipsTest : public CppUnit::TestFixture
+class UnitConversionTest : public CppUnit::TestFixture
 {
 public:
-    void testConvert()
+    void testSanitiseMm100ToTwip()
+    {
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(145), sanitiseMm100ToTwip(255));
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(-145), sanitiseMm100ToTwip(-255));
+    }
+
+    void testConvertMm100ToTwip()
+    {
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(145), convertMm100ToTwip(255));
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(-145), convertMm100ToTwip(-255));
+    }
+
+    void testConvertPointToMm100()
     {
-        sal_Int32 nActual = sanitiseMm100ToTwip(255);
-        sal_Int32 nExpected = 145;
-        CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(599.72, convertPointToMm100(17.0), 1E-2);
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(600), convertPointToMm100(sal_Int64(17)));
 
-        nActual = sanitiseMm100ToTwip(-255);
-        nExpected = -145;
-        CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(22930.55, convertPointToMm100(650.0), 1E-2);
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(22931), convertPointToMm100(sal_Int64(650)));
     }
 
-    CPPUNIT_TEST_SUITE(cm2TwipsTest);
-    CPPUNIT_TEST(testConvert);
+    CPPUNIT_TEST_SUITE(UnitConversionTest);
+    CPPUNIT_TEST(testSanitiseMm100ToTwip);
+    CPPUNIT_TEST(testConvertMm100ToTwip);
+    CPPUNIT_TEST(testConvertPointToMm100);
     CPPUNIT_TEST_SUITE_END();
 };
 
-CPPUNIT_TEST_SUITE_REGISTRATION(cm2TwipsTest);
-} // namespace tools
+CPPUNIT_TEST_SUITE_REGISTRATION(UnitConversionTest);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list