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

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sat May 1 07:30:01 UTC 2021


 svgio/CppunitTest_svgio_tools.mk   |   35 ++++++++++++++++++++++
 svgio/Module_svgio.mk              |    1 
 svgio/qa/cppunit/SvgNumberTest.cxx |   58 +++++++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+)

New commits:
commit e61cbca254fb0c060d06abbea669822f0a8582ad
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat May 1 12:16:27 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat May 1 09:29:18 2021 +0200

    svgio: add test for svgtools starting with SvgNumber
    
    Change-Id: I1f903a947fb1c338cf62980256c5369fefb7740e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114956
    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
new file mode 100644
index 000000000000..0a39459e6599
--- /dev/null
+++ b/svgio/CppunitTest_svgio_tools.mk
@@ -0,0 +1,35 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,svgio_tools))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,svgio_tools,\
+    svgio/qa/cppunit/SvgNumberTest \
+))
+
+$(eval $(call gb_CppunitTest_set_include,svgio_tools,\
+    $$(INCLUDE) \
+    -I$(SRCDIR)/svgio/inc \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,svgio_tools,\
+    boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,svgio_tools,\
+    basegfx \
+    drawinglayer \
+    sal \
+    sax \
+    svt \
+    vcl \
+    svgio \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/svgio/Module_svgio.mk b/svgio/Module_svgio.mk
index 26b659f59991..bb75ea9d11ce 100644
--- a/svgio/Module_svgio.mk
+++ b/svgio/Module_svgio.mk
@@ -25,6 +25,7 @@ $(eval $(call gb_Module_add_targets,svgio,\
 $(eval $(call gb_Module_add_check_targets,svgio,\
     CppunitTest_svgio \
     CppunitTest_svgio_read \
+    CppunitTest_svgio_tools \
 ))
 
 # vim: set noet ts=4 sw=4:
diff --git a/svgio/qa/cppunit/SvgNumberTest.cxx b/svgio/qa/cppunit/SvgNumberTest.cxx
new file mode 100644
index 000000000000..1880178cc360
--- /dev/null
+++ b/svgio/qa/cppunit/SvgNumberTest.cxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <SvgNumber.hxx>
+
+namespace
+{
+class TestNumber : public CppUnit::TestFixture
+{
+    void test();
+
+public:
+    CPPUNIT_TEST_SUITE(TestNumber);
+    CPPUNIT_TEST(test);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void TestNumber::test()
+{
+    {
+        svgio::svgreader::SvgNumber aNumber;
+        CPPUNIT_ASSERT_EQUAL(svgio::svgreader::SvgUnit::px, aNumber.getUnit());
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, aNumber.getNumber(), 1e-8);
+        CPPUNIT_ASSERT_EQUAL(false, aNumber.isSet());
+    }
+    {
+        svgio::svgreader::SvgNumber aNumber(0.01);
+        CPPUNIT_ASSERT_EQUAL(svgio::svgreader::SvgUnit::px, aNumber.getUnit());
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.01, aNumber.getNumber(), 1e-8);
+        CPPUNIT_ASSERT_EQUAL(true, aNumber.isSet());
+    }
+    {
+        svgio::svgreader::SvgNumber aNumber(1.01, svgio::svgreader::SvgUnit::cm);
+        CPPUNIT_ASSERT_EQUAL(svgio::svgreader::SvgUnit::cm, aNumber.getUnit());
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(1.01, aNumber.getNumber(), 1e-8);
+        CPPUNIT_ASSERT_EQUAL(true, aNumber.isSet());
+    }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(TestNumber);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list