1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/types.h>
22 #include <cppunit/TestFixture.h>
23 #include <cppunit/extensions/HelperMacros.h>
25 #include <tools/helpers.hxx>
26 #include <tools/UnitConversion.hxx>
28 class UnitConversionTest
: public CppUnit::TestFixture
31 void testSanitiseMm100ToTwip()
33 CPPUNIT_ASSERT_EQUAL(sal_Int64(145), sanitiseMm100ToTwip(255));
34 CPPUNIT_ASSERT_EQUAL(sal_Int64(-145), sanitiseMm100ToTwip(-255));
37 void testConvertMm100ToTwip()
39 CPPUNIT_ASSERT_EQUAL(sal_Int64(145), convertMm100ToTwip(255));
40 CPPUNIT_ASSERT_EQUAL(sal_Int64(-145), convertMm100ToTwip(-255));
43 void testConvertPointToMm100()
45 CPPUNIT_ASSERT_DOUBLES_EQUAL(599.72, convertPointToMm100(17.0), 1E-2);
46 CPPUNIT_ASSERT_EQUAL(sal_Int64(600), convertPointToMm100(sal_Int64(17)));
48 CPPUNIT_ASSERT_DOUBLES_EQUAL(22930.55, convertPointToMm100(650.0), 1E-2);
49 CPPUNIT_ASSERT_EQUAL(sal_Int64(22931), convertPointToMm100(sal_Int64(650)));
52 CPPUNIT_TEST_SUITE(UnitConversionTest
);
53 CPPUNIT_TEST(testSanitiseMm100ToTwip
);
54 CPPUNIT_TEST(testConvertMm100ToTwip
);
55 CPPUNIT_TEST(testConvertPointToMm100
);
56 CPPUNIT_TEST_SUITE_END();
59 CPPUNIT_TEST_SUITE_REGISTRATION(UnitConversionTest
);
61 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */