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 + +#include +#include +#include +#include + +#include + +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: */