summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-05-21 11:47:34 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-06-01 18:45:13 +0200
commitb1c007cd06c01078df481e020d9d81afd4de6a91 (patch)
tree2df8aafe3b4fd25ab9c6ae7887d293c1261edc1a /tools
parentd5e222cd86b82a429c28cb19583521d581efaf2b (diff)
tools: extend test for UnitConversion
Change-Id: I8fbc2a83f40fb04656f690b4b63d3cac9f0410c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95273 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/qa/cppunit/test_100mm2twips.cxx38
1 files changed, 24 insertions, 14 deletions
diff --git a/tools/qa/cppunit/test_100mm2twips.cxx b/tools/qa/cppunit/test_100mm2twips.cxx
index 80ceda2ffb3f..bfed8c2e2ba9 100644
--- a/tools/qa/cppunit/test_100mm2twips.cxx
+++ b/tools/qa/cppunit/test_100mm2twips.cxx
@@ -23,29 +23,39 @@
#include <cppunit/extensions/HelperMacros.h>
#include <tools/helpers.hxx>
+#include <tools/UnitConversion.hxx>
-namespace tools
-{
-class cm2TwipsTest : public CppUnit::TestFixture
+class UnitConversionTest : public CppUnit::TestFixture
{
public:
- void testConvert()
+ void testSanitiseMm100ToTwip()
+ {
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(145), sanitiseMm100ToTwip(255));
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(-145), sanitiseMm100ToTwip(-255));
+ }
+
+ void testConvertMm100ToTwip()
+ {
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(145), convertMm100ToTwip(255));
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(-145), convertMm100ToTwip(-255));
+ }
+
+ void testConvertPointToMm100()
{
- sal_Int32 nActual = sanitiseMm100ToTwip(255);
- sal_Int32 nExpected = 145;
- CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(599.72, convertPointToMm100(17.0), 1E-2);
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(600), convertPointToMm100(sal_Int64(17)));
- nActual = sanitiseMm100ToTwip(-255);
- nExpected = -145;
- CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(22930.55, convertPointToMm100(650.0), 1E-2);
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(22931), convertPointToMm100(sal_Int64(650)));
}
- CPPUNIT_TEST_SUITE(cm2TwipsTest);
- CPPUNIT_TEST(testConvert);
+ CPPUNIT_TEST_SUITE(UnitConversionTest);
+ CPPUNIT_TEST(testSanitiseMm100ToTwip);
+ CPPUNIT_TEST(testConvertMm100ToTwip);
+ CPPUNIT_TEST(testConvertPointToMm100);
CPPUNIT_TEST_SUITE_END();
};
-CPPUNIT_TEST_SUITE_REGISTRATION(cm2TwipsTest);
-} // namespace tools
+CPPUNIT_TEST_SUITE_REGISTRATION(UnitConversionTest);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */