1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
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>
21 class TypesTest
: public CppUnit::TestFixture
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))));
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))));
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))));
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)));
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))));
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"))));
89 CPPUNIT_ASSERT_EQUAL(OUString(""), ::comphelper::getString(aValue
));
92 CPPUNIT_TEST_SUITE_REGISTRATION(TypesTest
);
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */