diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-05-01 12:16:27 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-05-01 09:29:18 +0200 |
commit | e61cbca254fb0c060d06abbea669822f0a8582ad (patch) | |
tree | 909f69843247a9f2a01ff7d6bdfcd2c8c974f7c2 /svgio | |
parent | 0d62ee66d6c02f0b3c38d1d0fa52f9cd86207a98 (diff) |
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@gmail.com>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/CppunitTest_svgio_tools.mk | 35 | ||||
-rw-r--r-- | svgio/Module_svgio.mk | 1 | ||||
-rw-r--r-- | svgio/qa/cppunit/SvgNumberTest.cxx | 58 |
3 files changed, 94 insertions, 0 deletions
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: */ |