diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-05-01 15:06:14 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-05-01 13:45:43 +0200 |
commit | afad6ba0f841985ee87a0a0871e10cda5d8913cc (patch) | |
tree | 24af51a61352b5c2862c09756d1643a406b04686 /svgio | |
parent | 0acc9af66dd2d35c8335291ff3e72d98e4359bd5 (diff) |
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@gmail.com>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/CppunitTest_svgio_tools.mk | 10 | ||||
-rw-r--r-- | svgio/qa/cppunit/SvgNumberTest.cxx | 43 |
2 files changed, 49 insertions, 4 deletions
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); } |