Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / comphelper / qa / unit / types_test.cxx
blobc69b07199127515610556c798e4a610b5ec5b33a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
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/.
8 */
10 #include <comphelper/types.hxx>
11 #include <sal/types.h>
13 #include <cppunit/TestAssert.h>
14 #include <cppunit/TestFixture.h>
15 #include <cppunit/extensions/HelperMacros.h>
17 using namespace css;
19 namespace
21 class TypesTest : public CppUnit::TestFixture
23 public:
24 void testGetINT64();
25 void testGetINT32();
26 void testGetINT16();
27 void testGetDouble();
28 void testGetFloat();
29 void testGetString();
31 CPPUNIT_TEST_SUITE(TypesTest);
33 CPPUNIT_TEST(testGetINT64);
34 CPPUNIT_TEST(testGetINT32);
35 CPPUNIT_TEST(testGetINT16);
36 CPPUNIT_TEST(testGetDouble);
37 CPPUNIT_TEST(testGetFloat);
38 CPPUNIT_TEST(testGetString);
40 CPPUNIT_TEST_SUITE_END();
43 void TypesTest::testGetINT64()
45 CPPUNIT_ASSERT_EQUAL(sal_Int64(1337), ::comphelper::getINT64(uno::Any(sal_Int64(1337))));
47 uno::Any aValue;
48 CPPUNIT_ASSERT_EQUAL(sal_Int64(0), ::comphelper::getINT64(aValue));
51 void TypesTest::testGetINT32()
53 CPPUNIT_ASSERT_EQUAL(sal_Int32(1337), ::comphelper::getINT32(uno::Any(sal_Int32(1337))));
55 uno::Any aValue;
56 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ::comphelper::getINT32(aValue));
59 void TypesTest::testGetINT16()
61 CPPUNIT_ASSERT_EQUAL(sal_Int16(1337), ::comphelper::getINT16(uno::Any(sal_Int16(1337))));
63 uno::Any aValue;
64 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), ::comphelper::getINT16(aValue));
67 void TypesTest::testGetDouble()
69 CPPUNIT_ASSERT_EQUAL(1337.1337, ::comphelper::getDouble(uno::Any(1337.1337)));
71 uno::Any aValue;
72 CPPUNIT_ASSERT_EQUAL(0.0, ::comphelper::getDouble(aValue));
75 void TypesTest::testGetFloat()
77 CPPUNIT_ASSERT_EQUAL(static_cast<float>(1337.0),
78 ::comphelper::getFloat(uno::Any(static_cast<float>(1337.0))));
80 uno::Any aValue;
81 CPPUNIT_ASSERT_EQUAL(static_cast<float>(0.0), ::comphelper::getFloat(aValue));
84 void TypesTest::testGetString()
86 CPPUNIT_ASSERT_EQUAL(OUString("1337"), ::comphelper::getString(uno::Any(OUString("1337"))));
88 uno::Any aValue;
89 CPPUNIT_ASSERT_EQUAL(OUString(""), ::comphelper::getString(aValue));
92 CPPUNIT_TEST_SUITE_REGISTRATION(TypesTest);
94 } // namespace
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */