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 <sal/config.h>
12 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
13 #include <com/sun/star/reflection/Dump.hpp>
14 #include <com/sun/star/uno/Any.hxx>
15 #include <com/sun/star/uno/Reference.hxx>
16 #include <com/sun/star/uno/TypeClass.hpp>
17 #include <cppuhelper/bootstrap.hxx>
18 #include <cppunit/TestAssert.h>
19 #include <cppunit/TestFixture.h>
20 #include <cppunit/extensions/HelperMacros.h>
21 #include <cppunit/plugin/TestPlugIn.h>
22 #include <test/codemaker/cppumaker/ByteBits.hpp>
23 #include <test/codemaker/cppumaker/Constants.hpp>
24 #include <test/codemaker/cppumaker/ShortBits.hpp>
25 #include <test/codemaker/cppumaker/UnsignedHyperBits.hpp>
29 class Dump
: public CppUnit::TestFixture
34 dump_
= css::reflection::Dump::get(cppu::defaultBootstrap_InitialComponentContext());
39 CPPUNIT_ASSERT_EQUAL(u
"[]"_ustr
,
40 dump_
->dumpValue(css::uno::Any(css::uno::Sequence
<sal_Int32
>{})));
41 CPPUNIT_ASSERT_EQUAL(u
"[1]"_ustr
,
42 dump_
->dumpValue(css::uno::Any(css::uno::Sequence
<sal_Int32
>{ 1 })));
43 CPPUNIT_ASSERT_EQUAL(u
"[1, 2, 3]"_ustr
, dump_
->dumpValue(css::uno::Any(
44 css::uno::Sequence
<sal_Int32
>{ 1, 2, 3 })));
45 CPPUNIT_ASSERT_EQUAL(u
"[[long: 1], [string: \"2\"], [[]long: [1, 2]]]"_ustr
,
46 (dump_
->dumpValue(css::uno::Any(css::uno::Sequence
<css::uno::Any
>{
47 css::uno::Any(sal_Int32(1)), css::uno::Any(u
"2"_ustr
),
48 css::uno::Any(css::uno::Sequence
<sal_Int32
>{ 1, 2 }) }))));
53 CPPUNIT_ASSERT_EQUAL(u
"ENUM"_ustr
,
54 dump_
->dumpValue(css::uno::Any(css::uno::TypeClass_ENUM
)));
55 CPPUNIT_ASSERT_EQUAL(u
"-1"_ustr
, dump_
->dumpValue(css::uno::Any(css::uno::TypeClass(-1))));
56 CPPUNIT_ASSERT_EQUAL(u
"12345"_ustr
,
57 dump_
->dumpValue(css::uno::Any(css::uno::TypeClass(12345))));
63 u
"[Source: null, PropertyName: \"test\", Further: false, PropertyHandle: 3, "
64 "OldValue: [void: void], NewValue: [long: 5]]"_ustr
,
65 dump_
->dumpValue(css::uno::Any(css::beans::PropertyChangeEvent(
66 {}, u
"test"_ustr
, false, 3, {}, css::uno::Any(sal_Int32(5))))));
69 void testConstantsGroup()
71 CPPUNIT_ASSERT_EQUAL(u
"byteMin"_ustr
,
72 dump_
->dumpConstant(u
"test.codemaker.cppumaker.Constants"_ustr
,
73 css::uno::Any(sal_Int8(-128))));
74 CPPUNIT_ASSERT_EQUAL(u
"byteMax"_ustr
,
75 dump_
->dumpConstant(u
"test.codemaker.cppumaker.Constants"_ustr
,
76 css::uno::Any(sal_Int8(127))));
77 CPPUNIT_ASSERT_EQUAL(u
"longMin"_ustr
,
78 dump_
->dumpConstant(u
"test.codemaker.cppumaker.Constants"_ustr
,
79 css::uno::Any(sal_Int32(-2147483648))));
80 CPPUNIT_ASSERT_EQUAL(u
"longMax"_ustr
,
81 dump_
->dumpConstant(u
"test.codemaker.cppumaker.Constants"_ustr
,
82 css::uno::Any(sal_Int32(2147483647))));
83 CPPUNIT_ASSERT_EQUAL(u
"hyperMin"_ustr
,
84 dump_
->dumpConstant(u
"test.codemaker.cppumaker.Constants"_ustr
,
85 css::uno::Any(SAL_MIN_INT64
)));
86 CPPUNIT_ASSERT_EQUAL(u
"hyperMax"_ustr
,
87 dump_
->dumpConstant(u
"test.codemaker.cppumaker.Constants"_ustr
,
88 css::uno::Any(SAL_MAX_INT64
)));
89 CPPUNIT_ASSERT_EQUAL(u
"17"_ustr
,
90 dump_
->dumpConstant(u
"test.codemaker.cppumaker.Constants"_ustr
,
91 css::uno::Any(sal_Int32(17))));
92 CPPUNIT_ASSERT_EQUAL(u
"2147483646"_ustr
,
93 dump_
->dumpConstant(u
"test.codemaker.cppumaker.Constants"_ustr
,
94 css::uno::Any(sal_Int32(2147483646))));
96 CPPUNIT_ASSERT_EQUAL(u
"0"_ustr
,
97 dump_
->dumpConstant(u
"test.codemaker.cppumaker.ByteBits"_ustr
,
98 css::uno::Any(sal_Int8(0))));
99 CPPUNIT_ASSERT_EQUAL(u
"BIT0+BIT2"_ustr
,
100 dump_
->dumpConstant(u
"test.codemaker.cppumaker.ByteBits"_ustr
,
101 css::uno::Any(sal_Int8(5))));
102 CPPUNIT_ASSERT_EQUAL(u
"BIT4"_ustr
,
103 dump_
->dumpConstant(u
"test.codemaker.cppumaker.ByteBits"_ustr
,
104 css::uno::Any(sal_Int8(16))));
105 CPPUNIT_ASSERT_EQUAL(u
"BIT0+BIT4"_ustr
,
106 dump_
->dumpConstant(u
"test.codemaker.cppumaker.ByteBits"_ustr
,
107 css::uno::Any(sal_Int8(17))));
108 CPPUNIT_ASSERT_EQUAL(u
"BIT7"_ustr
,
109 dump_
->dumpConstant(u
"test.codemaker.cppumaker.ByteBits"_ustr
,
110 css::uno::Any(sal_Int8(-128))));
111 CPPUNIT_ASSERT_EQUAL(u
"ALL"_ustr
,
112 dump_
->dumpConstant(u
"test.codemaker.cppumaker.ByteBits"_ustr
,
113 css::uno::Any(sal_Int8(-1))));
115 CPPUNIT_ASSERT_EQUAL(u
"BIT7"_ustr
,
116 dump_
->dumpConstant(u
"test.codemaker.cppumaker.ShortBits"_ustr
,
117 css::uno::Any(sal_Int16(128))));
118 CPPUNIT_ASSERT_EQUAL(u
"ALL"_ustr
,
119 dump_
->dumpConstant(u
"test.codemaker.cppumaker.ShortBits"_ustr
,
120 css::uno::Any(sal_Int16(-1))));
122 CPPUNIT_ASSERT_EQUAL(u
"BIT63"_ustr
,
123 dump_
->dumpConstant(u
"test.codemaker.cppumaker.UnsignedHyperBits"_ustr
,
124 css::uno::Any(sal_uInt64(9223372036854775808u))));
125 CPPUNIT_ASSERT_EQUAL(u
"BIT0+BIT62"_ustr
,
126 dump_
->dumpConstant(u
"test.codemaker.cppumaker.UnsignedHyperBits"_ustr
,
127 css::uno::Any(sal_uInt64(4611686018427387905))));
128 CPPUNIT_ASSERT_EQUAL(u
"BIT0+BIT63"_ustr
,
129 dump_
->dumpConstant(u
"test.codemaker.cppumaker.UnsignedHyperBits"_ustr
,
130 css::uno::Any(sal_uInt64(9223372036854775809u))));
131 CPPUNIT_ASSERT_EQUAL(u
"ALL"_ustr
,
132 dump_
->dumpConstant(u
"test.codemaker.cppumaker.UnsignedHyperBits"_ustr
,
133 css::uno::Any(SAL_MAX_UINT64
)));
136 CPPUNIT_TEST_SUITE(Dump
);
137 CPPUNIT_TEST(testSequence
);
138 CPPUNIT_TEST(testEnum
);
139 CPPUNIT_TEST(testStruct
);
140 CPPUNIT_TEST(testConstantsGroup
);
141 CPPUNIT_TEST_SUITE_END();
144 css::uno::Reference
<css::reflection::XDump
> dump_
;
147 CPPUNIT_TEST_SUITE_REGISTRATION(Dump
);
150 CPPUNIT_PLUGIN_IMPLEMENT();
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */