[Libreoffice-commits] core.git: svgio/CppunitTest_svgio_tools.mk svgio/qa

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sat May 1 11:46:33 UTC 2021


 svgio/CppunitTest_svgio_tools.mk   |   10 +++++++-
 svgio/qa/cppunit/SvgNumberTest.cxx |   43 ++++++++++++++++++++++++++++++++++---
 2 files changed, 49 insertions(+), 4 deletions(-)

New commits:
commit afad6ba0f841985ee87a0a0871e10cda5d8913cc
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat May 1 15:06:14 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat May 1 13:45:43 2021 +0200

    svgio: add test for SvgNumber::solve
    
    Change-Id: I38aa58f9be104754d32ca985022947c3c7225f0c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114963
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/svgio/CppunitTest_svgio_tools.mk b/svgio/CppunitTest_svgio_tools.mk
index 0a39459e6599..ad640520bc2e 100644
--- a/svgio/CppunitTest_svgio_tools.mk
+++ b/svgio/CppunitTest_svgio_tools.mk
@@ -22,14 +22,22 @@ $(eval $(call gb_CppunitTest_use_externals,svgio_tools,\
     boost_headers \
 ))
 
+$(eval $(call gb_CppunitTest_use_library_objects,svgio_tools,\
+    svgio \
+))
+
 $(eval $(call gb_CppunitTest_use_libraries,svgio_tools,\
     basegfx \
     drawinglayer \
+    comphelper \
+    cppu \
+    cppuhelper \
     sal \
     sax \
     svt \
+    tk \
+    tl \
     vcl \
-    svgio \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/svgio/qa/cppunit/SvgNumberTest.cxx b/svgio/qa/cppunit/SvgNumberTest.cxx
index 1880178cc360..f420a44b42fe 100644
--- a/svgio/qa/cppunit/SvgNumberTest.cxx
+++ b/svgio/qa/cppunit/SvgNumberTest.cxx
@@ -20,15 +20,30 @@ namespace
 {
 class TestNumber : public CppUnit::TestFixture
 {
-    void test();
+    void testSetting();
+    void testSolve();
 
 public:
     CPPUNIT_TEST_SUITE(TestNumber);
-    CPPUNIT_TEST(test);
+    CPPUNIT_TEST(testSetting);
+    CPPUNIT_TEST(testSolve);
     CPPUNIT_TEST_SUITE_END();
 };
 
-void TestNumber::test()
+class TestInfoProvider : public svgio::svgreader::InfoProvider
+{
+public:
+    basegfx::B2DRange getCurrentViewPort() const override
+    {
+        return basegfx::B2DRange(0.0, 0.0, 0.0, 0.0);
+    }
+
+    double getCurrentFontSizeInherited() const override { return 12.0; }
+
+    double getCurrentXHeightInherited() const override { return 5.0; }
+};
+
+void TestNumber::testSetting()
 {
     {
         svgio::svgreader::SvgNumber aNumber;
@@ -50,6 +65,28 @@ void TestNumber::test()
     }
 }
 
+void TestNumber::testSolve()
+{
+    {
+        svgio::svgreader::SvgNumber aNumber(1.01);
+        TestInfoProvider aInfoProvider;
+        double aSolvedNumber = aNumber.solve(aInfoProvider);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(1.01, aSolvedNumber, 1e-8);
+    }
+    {
+        svgio::svgreader::SvgNumber aNumber(1.0, svgio::svgreader::SvgUnit::pt);
+        TestInfoProvider aInfoProvider;
+        double aSolvedNumber = aNumber.solve(aInfoProvider);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(1.333, aSolvedNumber, 1e-3);
+    }
+    {
+        svgio::svgreader::SvgNumber aNumber(2.54, svgio::svgreader::SvgUnit::cm);
+        TestInfoProvider aInfoProvider;
+        double aSolvedNumber = aNumber.solve(aInfoProvider);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(96.0, aSolvedNumber, 1e-3);
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(TestNumber);
 }
 


More information about the Libreoffice-commits mailing list