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/plugin/TestPlugIn.h>
24 #include <cppunit/extensions/HelperMacros.h>
28 #include <com/sun/star/beans/Optional.hpp>
29 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
30 #include <com/sun/star/lang/EventObject.hpp>
31 #include <com/sun/star/uno/Exception.hpp>
32 #include <com/sun/star/uno/RuntimeException.hpp>
33 #include <com/sun/star/uno/Sequence.hxx>
34 #include <com/sun/star/uno/Type.hxx>
35 #include <com/sun/star/uno/TypeClass.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/uno/XInterface.hpp>
38 #include <cppu/unotype.hxx>
39 #include <rtl/ustring.hxx>
41 namespace com::sun::star::uno
{
45 namespace com::sun::star::uno
{ template <class interface_type
> class Reference
; }
49 struct DerivedStruct1
: css::lang::EventObject
{};
51 struct DerivedStruct2
: css::beans::PropertyChangeEvent
{};
53 struct DerivedException1
: css::uno::Exception
{};
55 struct DerivedException2
: css::uno::RuntimeException
{};
57 struct DerivedInterface1
: css::uno::XInterface
{
59 ~DerivedInterface1() {}
60 // avoid warnings about virtual members and non-virtual dtor
63 static void dummy(DerivedInterface1
* p
)
64 { p
->DerivedInterface1::~DerivedInterface1(); }
65 // ...and avoid warnings about unused ~DerivedInterface1 (see below)
68 struct DerivedInterface2
: css::uno::XComponentContext
{
70 ~DerivedInterface2() {}
71 // avoid warnings about virtual members and non-virtual dtor
74 static void dummy(DerivedInterface2
* p
)
75 { p
->DerivedInterface2::~DerivedInterface2(); }
76 // ...and avoid warnings about unused ~DerivedInterface2 (see below)
79 class Test
: public CppUnit::TestFixture
{
83 void testGetTypeFavourUnsigned();
85 void testGetTypeFavourChar();
87 CPPUNIT_TEST_SUITE(Test
);
88 CPPUNIT_TEST(testUnoType
);
89 CPPUNIT_TEST(testGetTypeFavourUnsigned
);
90 CPPUNIT_TEST(testGetTypeFavourChar
);
91 CPPUNIT_TEST_SUITE_END();
94 void Test::testUnoType() {
95 // Avoid warnings about unused ~DerivedInterface1/2 (see above):
97 DerivedInterface1::dummy(nullptr);
98 DerivedInterface2::dummy(nullptr);
102 t
= cppu::UnoType
<cppu::UnoVoidType
>::get();
103 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_VOID
, t
.getTypeClass());
104 CPPUNIT_ASSERT_EQUAL(OUString("void"), t
.getTypeName());
105 CPPUNIT_ASSERT(bool(cppu::UnoType
<void>::get() == t
));
106 t
= cppu::UnoType
<bool>::get();
107 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_BOOLEAN
, t
.getTypeClass());
108 CPPUNIT_ASSERT_EQUAL(OUString("boolean"), t
.getTypeName());
109 CPPUNIT_ASSERT(bool(cppu::UnoType
<sal_Bool
>::get() == t
));
110 t
= cppu::UnoType
<sal_Int8
>::get();
111 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_BYTE
, t
.getTypeClass());
112 CPPUNIT_ASSERT_EQUAL(OUString("byte"), t
.getTypeName());
113 t
= cppu::UnoType
<sal_Int16
>::get();
114 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SHORT
, t
.getTypeClass());
115 CPPUNIT_ASSERT_EQUAL(OUString("short"), t
.getTypeName());
116 t
= cppu::UnoType
<cppu::UnoUnsignedShortType
>::get();
117 CPPUNIT_ASSERT_EQUAL(
118 css::uno::TypeClass_UNSIGNED_SHORT
, t
.getTypeClass());
119 CPPUNIT_ASSERT_EQUAL(OUString("unsigned short"), t
.getTypeName());
120 t
= cppu::UnoType
<sal_Int32
>::get();
121 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_LONG
, t
.getTypeClass());
122 CPPUNIT_ASSERT_EQUAL(OUString("long"), t
.getTypeName());
123 t
= cppu::UnoType
<sal_uInt32
>::get();
124 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_UNSIGNED_LONG
, t
.getTypeClass());
125 CPPUNIT_ASSERT_EQUAL(OUString("unsigned long"), t
.getTypeName());
126 t
= cppu::UnoType
<sal_Int64
>::get();
127 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_HYPER
, t
.getTypeClass());
128 CPPUNIT_ASSERT_EQUAL(OUString("hyper"), t
.getTypeName());
129 t
= cppu::UnoType
<sal_uInt64
>::get();
130 CPPUNIT_ASSERT_EQUAL(
131 css::uno::TypeClass_UNSIGNED_HYPER
, t
.getTypeClass());
132 CPPUNIT_ASSERT_EQUAL(OUString("unsigned hyper"), t
.getTypeName());
133 t
= cppu::UnoType
<float>::get();
134 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_FLOAT
, t
.getTypeClass());
135 CPPUNIT_ASSERT_EQUAL(OUString("float"), t
.getTypeName());
136 t
= cppu::UnoType
<double>::get();
137 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_DOUBLE
, t
.getTypeClass());
138 CPPUNIT_ASSERT_EQUAL(OUString("double"), t
.getTypeName());
139 t
= cppu::UnoType
<cppu::UnoCharType
>::get();
140 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_CHAR
, t
.getTypeClass());
141 CPPUNIT_ASSERT_EQUAL(OUString("char"), t
.getTypeName());
142 t
= cppu::UnoType
<OUString
>::get();
143 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_STRING
, t
.getTypeClass());
144 CPPUNIT_ASSERT_EQUAL(OUString("string"), t
.getTypeName());
145 t
= cppu::UnoType
<css::uno::Type
>::get();
146 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_TYPE
, t
.getTypeClass());
147 CPPUNIT_ASSERT_EQUAL(OUString("type"), t
.getTypeName());
148 t
= cppu::UnoType
<css::uno::Any
>::get();
149 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_ANY
, t
.getTypeClass());
150 CPPUNIT_ASSERT_EQUAL(OUString("any"), t
.getTypeName());
151 t
= cppu::UnoType
<cppu::UnoSequenceType
<sal_Int8
>>::get();
152 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE
, t
.getTypeClass());
153 CPPUNIT_ASSERT_EQUAL(OUString("[]byte"), t
.getTypeName());
154 CPPUNIT_ASSERT(bool(cppu::UnoType
<css::uno::Sequence
<sal_Int8
>>::get() == t
));
155 t
= cppu::UnoType
<cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
>>::get();
156 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE
, t
.getTypeClass());
157 CPPUNIT_ASSERT_EQUAL(OUString("[]unsigned short"), t
.getTypeName());
158 t
= cppu::UnoType
<cppu::UnoSequenceType
<cppu::UnoCharType
>>::get();
159 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE
, t
.getTypeClass());
160 CPPUNIT_ASSERT_EQUAL(OUString("[]char"), t
.getTypeName());
162 cppu::UnoSequenceType
<cppu::UnoSequenceType
<sal_Int8
>>>::get();
163 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE
, t
.getTypeClass());
164 CPPUNIT_ASSERT_EQUAL(OUString("[][]byte"), t
.getTypeName());
165 CPPUNIT_ASSERT_EQUAL(
166 cppu::UnoType
<css::uno::Sequence
<css::uno::Sequence
<sal_Int8
>>>::get(),
169 cppu::UnoSequenceType
<
170 cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
>>>::get();
171 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE
, t
.getTypeClass());
172 CPPUNIT_ASSERT_EQUAL(OUString("[][]unsigned short"), t
.getTypeName());
174 cppu::UnoSequenceType
<cppu::UnoSequenceType
<cppu::UnoCharType
>>>::get();
175 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_SEQUENCE
, t
.getTypeClass());
176 CPPUNIT_ASSERT_EQUAL(OUString("[][]char"), t
.getTypeName());
177 t
= cppu::UnoType
<css::uno::TypeClass
>::get();
178 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_ENUM
, t
.getTypeClass());
179 CPPUNIT_ASSERT_EQUAL(
180 OUString("com.sun.star.uno.TypeClass"), t
.getTypeName());
181 t
= cppu::UnoType
<css::lang::EventObject
>::get();
182 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_STRUCT
, t
.getTypeClass());
183 CPPUNIT_ASSERT_EQUAL(
184 OUString("com.sun.star.lang.EventObject"), t
.getTypeName());
185 CPPUNIT_ASSERT_EQUAL(cppu::UnoType
<DerivedStruct1
>::get(), t
);
186 t
= cppu::UnoType
<css::beans::PropertyChangeEvent
>::get();
187 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_STRUCT
, t
.getTypeClass());
188 CPPUNIT_ASSERT_EQUAL(
189 OUString("com.sun.star.beans.PropertyChangeEvent"), t
.getTypeName());
190 CPPUNIT_ASSERT_EQUAL(cppu::UnoType
<DerivedStruct2
>::get(), t
);
191 t
= cppu::UnoType
<css::beans::Optional
<sal_Int8
>>::get();
192 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_STRUCT
, t
.getTypeClass());
193 CPPUNIT_ASSERT_EQUAL(
194 OUString("com.sun.star.beans.Optional<byte>"), t
.getTypeName());
195 t
= cppu::UnoType
<css::uno::Exception
>::get();
196 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_EXCEPTION
, t
.getTypeClass());
197 CPPUNIT_ASSERT_EQUAL(
198 OUString("com.sun.star.uno.Exception"), t
.getTypeName());
199 CPPUNIT_ASSERT_EQUAL(cppu::UnoType
<DerivedException1
>::get(), t
);
200 t
= cppu::UnoType
<css::uno::RuntimeException
>::get();
201 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_EXCEPTION
, t
.getTypeClass());
202 CPPUNIT_ASSERT_EQUAL(
203 OUString("com.sun.star.uno.RuntimeException"), t
.getTypeName());
204 CPPUNIT_ASSERT_EQUAL(cppu::UnoType
<DerivedException2
>::get(), t
);
205 t
= cppu::UnoType
<css::uno::XInterface
>::get();
206 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_INTERFACE
, t
.getTypeClass());
207 CPPUNIT_ASSERT_EQUAL(
208 OUString("com.sun.star.uno.XInterface"), t
.getTypeName());
209 CPPUNIT_ASSERT_EQUAL(
210 cppu::UnoType
<css::uno::Reference
<css::uno::XInterface
>>::get(), t
);
211 CPPUNIT_ASSERT_EQUAL(cppu::UnoType
<DerivedInterface1
>::get(), t
);
212 CPPUNIT_ASSERT_EQUAL(
213 cppu::UnoType
<css::uno::Reference
<DerivedInterface1
>>::get(), t
);
214 t
= cppu::UnoType
<css::uno::XComponentContext
>::get();
215 CPPUNIT_ASSERT_EQUAL(css::uno::TypeClass_INTERFACE
, t
.getTypeClass());
216 CPPUNIT_ASSERT_EQUAL(
217 OUString("com.sun.star.uno.XComponentContext"), t
.getTypeName());
218 CPPUNIT_ASSERT_EQUAL(
219 cppu::UnoType
<css::uno::Reference
<css::uno::XComponentContext
>>::get(),
221 CPPUNIT_ASSERT_EQUAL(cppu::UnoType
<DerivedInterface2
>::get(), t
);
222 CPPUNIT_ASSERT_EQUAL(
223 cppu::UnoType
<css::uno::Reference
<DerivedInterface2
>>::get(), t
);
226 void Test::testGetTypeFavourUnsigned() {
227 CPPUNIT_ASSERT(typeid(sal_Unicode
) != typeid(sal_uInt16
));
228 CPPUNIT_ASSERT_EQUAL(
229 cppu::getTypeFavourUnsigned(static_cast<cppu::UnoVoidType
*>(nullptr)),
230 cppu::UnoType
<cppu::UnoVoidType
>::get());
231 CPPUNIT_ASSERT_EQUAL(
232 cppu::getTypeFavourUnsigned(static_cast<bool *>(nullptr)),
233 cppu::UnoType
<bool>::get());
234 CPPUNIT_ASSERT_EQUAL(
235 cppu::getTypeFavourUnsigned(static_cast<sal_Bool
*>(nullptr)),
236 cppu::UnoType
<bool>::get());
237 CPPUNIT_ASSERT_EQUAL(
238 cppu::getTypeFavourUnsigned(static_cast<sal_Int8
*>(nullptr)),
239 cppu::UnoType
<sal_Int8
>::get());
240 CPPUNIT_ASSERT_EQUAL(
241 cppu::getTypeFavourUnsigned(static_cast<sal_Int16
*>(nullptr)),
242 cppu::UnoType
<sal_Int16
>::get());
243 CPPUNIT_ASSERT_EQUAL(
244 cppu::getTypeFavourUnsigned(
245 static_cast<cppu::UnoUnsignedShortType
*>(nullptr)),
246 cppu::UnoType
<cppu::UnoUnsignedShortType
>::get());
247 CPPUNIT_ASSERT_EQUAL(
248 cppu::getTypeFavourUnsigned(static_cast<sal_uInt16
*>(nullptr)),
249 cppu::UnoType
<cppu::UnoUnsignedShortType
>::get());
250 CPPUNIT_ASSERT_EQUAL(
251 cppu::getTypeFavourUnsigned(static_cast<sal_Int32
*>(nullptr)),
252 cppu::UnoType
<sal_Int32
>::get());
253 CPPUNIT_ASSERT_EQUAL(
254 cppu::getTypeFavourUnsigned(static_cast<sal_uInt32
*>(nullptr)),
255 cppu::UnoType
<sal_uInt32
>::get());
256 CPPUNIT_ASSERT_EQUAL(
257 cppu::getTypeFavourUnsigned(static_cast<sal_Int64
*>(nullptr)),
258 cppu::UnoType
<sal_Int64
>::get());
259 CPPUNIT_ASSERT_EQUAL(
260 cppu::getTypeFavourUnsigned(static_cast<sal_uInt64
*>(nullptr)),
261 cppu::UnoType
<sal_uInt64
>::get());
262 CPPUNIT_ASSERT_EQUAL(
263 cppu::getTypeFavourUnsigned(static_cast<float *>(nullptr)),
264 cppu::UnoType
<float>::get());
265 CPPUNIT_ASSERT_EQUAL(
266 cppu::getTypeFavourUnsigned(static_cast<double *>(nullptr)),
267 cppu::UnoType
<double>::get());
268 CPPUNIT_ASSERT_EQUAL(
269 cppu::getTypeFavourUnsigned(static_cast<cppu::UnoCharType
*>(nullptr)),
270 cppu::UnoType
<cppu::UnoCharType
>::get());
271 CPPUNIT_ASSERT_EQUAL(
272 cppu::getTypeFavourUnsigned(static_cast<sal_Unicode
*>(nullptr)),
273 cppu::UnoType
<cppu::UnoCharType
>::get());
274 CPPUNIT_ASSERT_EQUAL(
275 cppu::getTypeFavourUnsigned(static_cast<OUString
*>(nullptr)),
276 cppu::UnoType
<OUString
>::get());
277 CPPUNIT_ASSERT_EQUAL(
278 cppu::getTypeFavourUnsigned(static_cast<css::uno::Type
*>(nullptr)),
279 cppu::UnoType
<css::uno::Type
>::get());
280 CPPUNIT_ASSERT_EQUAL(
281 cppu::getTypeFavourUnsigned(static_cast<css::uno::Any
*>(nullptr)),
282 cppu::UnoType
<css::uno::Any
>::get());
283 CPPUNIT_ASSERT_EQUAL(
284 cppu::getTypeFavourUnsigned(
286 cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
> *>(nullptr)),
288 cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
>>::get());
289 CPPUNIT_ASSERT_EQUAL(
290 cppu::getTypeFavourUnsigned(
291 static_cast<css::uno::Sequence
<sal_uInt16
> *>(nullptr)),
293 cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
>>::get());
294 CPPUNIT_ASSERT_EQUAL(
295 cppu::getTypeFavourUnsigned(
297 cppu::UnoSequenceType
<
298 cppu::UnoSequenceType
<
299 cppu::UnoUnsignedShortType
>> *>(nullptr)),
301 cppu::UnoSequenceType
<
302 cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
>>>::get());
303 CPPUNIT_ASSERT_EQUAL(
304 cppu::getTypeFavourUnsigned(
306 css::uno::Sequence
<css::uno::Sequence
<sal_uInt16
>> *>(nullptr)),
308 cppu::UnoSequenceType
<
309 cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
>>>::get());
310 CPPUNIT_ASSERT_EQUAL(
311 cppu::getTypeFavourUnsigned(
312 static_cast<css::uno::Sequence
<sal_Unicode
> *>(nullptr)),
313 cppu::UnoType
<cppu::UnoSequenceType
<cppu::UnoCharType
>>::get());
314 CPPUNIT_ASSERT_EQUAL(
315 cppu::getTypeFavourUnsigned(
318 css::uno::Sequence
<sal_Unicode
>> *>(nullptr)),
320 cppu::UnoSequenceType
<
321 cppu::UnoSequenceType
<cppu::UnoCharType
>>>::get());
322 CPPUNIT_ASSERT_EQUAL(
323 cppu::getTypeFavourUnsigned(
324 static_cast<css::uno::TypeClass
*>(nullptr)),
325 cppu::UnoType
<css::uno::TypeClass
>::get());
326 CPPUNIT_ASSERT_EQUAL(
327 cppu::getTypeFavourUnsigned(
328 static_cast<css::lang::EventObject
*>(nullptr)),
329 cppu::UnoType
<css::lang::EventObject
>::get());
330 CPPUNIT_ASSERT_EQUAL(
331 cppu::getTypeFavourUnsigned(static_cast<DerivedStruct1
*>(nullptr)),
332 cppu::UnoType
<css::lang::EventObject
>::get());
333 CPPUNIT_ASSERT_EQUAL(
334 cppu::getTypeFavourUnsigned(
335 static_cast<css::beans::PropertyChangeEvent
*>(nullptr)),
336 cppu::UnoType
<css::beans::PropertyChangeEvent
>::get());
337 CPPUNIT_ASSERT_EQUAL(
338 cppu::getTypeFavourUnsigned(static_cast<DerivedStruct2
*>(nullptr)),
339 cppu::UnoType
<css::beans::PropertyChangeEvent
>::get());
340 CPPUNIT_ASSERT_EQUAL(
341 cppu::getTypeFavourUnsigned(
342 static_cast<css::beans::Optional
<sal_Int8
> *>(nullptr)),
343 cppu::UnoType
<css::beans::Optional
<sal_Int8
>>::get());
344 CPPUNIT_ASSERT_EQUAL(
345 cppu::getTypeFavourUnsigned(
346 static_cast<css::uno::Exception
*>(nullptr)),
347 cppu::UnoType
<css::uno::Exception
>::get());
348 CPPUNIT_ASSERT_EQUAL(
349 cppu::getTypeFavourUnsigned(static_cast<DerivedException1
*>(nullptr)),
350 cppu::UnoType
<css::uno::Exception
>::get());
351 CPPUNIT_ASSERT_EQUAL(
352 cppu::getTypeFavourUnsigned(
353 static_cast<css::uno::RuntimeException
*>(nullptr)),
354 cppu::UnoType
<css::uno::RuntimeException
>::get());
355 CPPUNIT_ASSERT_EQUAL(
356 cppu::getTypeFavourUnsigned(static_cast<DerivedException2
*>(nullptr)),
357 cppu::UnoType
<css::uno::RuntimeException
>::get());
358 CPPUNIT_ASSERT_EQUAL(
359 cppu::getTypeFavourUnsigned(
360 static_cast<css::uno::XInterface
*>(nullptr)),
361 cppu::UnoType
<css::uno::XInterface
>::get());
362 CPPUNIT_ASSERT_EQUAL(
363 cppu::getTypeFavourUnsigned(
364 static_cast<css::uno::Reference
<css::uno::XInterface
> *>(nullptr)),
365 cppu::UnoType
<css::uno::XInterface
>::get());
366 CPPUNIT_ASSERT_EQUAL(
367 cppu::getTypeFavourUnsigned(static_cast<DerivedInterface1
*>(nullptr)),
368 cppu::UnoType
<css::uno::XInterface
>::get());
369 CPPUNIT_ASSERT_EQUAL(
370 cppu::getTypeFavourUnsigned(
371 static_cast<css::uno::Reference
<DerivedInterface1
> *>(nullptr)),
372 cppu::UnoType
<css::uno::XInterface
>::get());
373 CPPUNIT_ASSERT_EQUAL(
374 cppu::getTypeFavourUnsigned(
375 static_cast<css::uno::XComponentContext
*>(nullptr)),
376 cppu::UnoType
<css::uno::XComponentContext
>::get());
377 CPPUNIT_ASSERT_EQUAL(
378 cppu::getTypeFavourUnsigned(
380 css::uno::Reference
<css::uno::XComponentContext
> *>(nullptr)),
381 cppu::UnoType
<css::uno::XComponentContext
>::get());
382 CPPUNIT_ASSERT_EQUAL(
383 cppu::getTypeFavourUnsigned(static_cast<DerivedInterface2
*>(nullptr)),
384 cppu::UnoType
<css::uno::XComponentContext
>::get());
385 CPPUNIT_ASSERT_EQUAL(
386 cppu::getTypeFavourUnsigned(
387 static_cast<css::uno::Reference
<DerivedInterface2
> *>(nullptr)),
388 cppu::UnoType
<css::uno::XComponentContext
>::get());
391 void Test::testGetTypeFavourChar() {
392 CPPUNIT_ASSERT(typeid(sal_Unicode
) != typeid(sal_uInt16
));
393 CPPUNIT_ASSERT_EQUAL(
394 cppu::getTypeFavourChar(static_cast<cppu::UnoVoidType
*>(nullptr)),
395 cppu::UnoType
<cppu::UnoVoidType
>::get());
396 CPPUNIT_ASSERT_EQUAL(
397 cppu::getTypeFavourChar(static_cast<bool *>(nullptr)),
398 cppu::UnoType
<bool>::get());
399 CPPUNIT_ASSERT_EQUAL(
400 cppu::getTypeFavourChar(static_cast<sal_Bool
*>(nullptr)),
401 cppu::UnoType
<bool>::get());
402 CPPUNIT_ASSERT_EQUAL(
403 cppu::getTypeFavourChar(static_cast<sal_Int8
*>(nullptr)),
404 cppu::UnoType
<sal_Int8
>::get());
405 CPPUNIT_ASSERT_EQUAL(
406 cppu::getTypeFavourChar(static_cast<sal_Int16
*>(nullptr)),
407 cppu::UnoType
<sal_Int16
>::get());
408 CPPUNIT_ASSERT_EQUAL(
409 cppu::getTypeFavourChar(
410 static_cast<cppu::UnoUnsignedShortType
*>(nullptr)),
411 cppu::UnoType
<cppu::UnoUnsignedShortType
>::get());
412 CPPUNIT_ASSERT_EQUAL(
413 cppu::getTypeFavourChar(static_cast<sal_uInt16
*>(nullptr)),
414 cppu::UnoType
<cppu::UnoUnsignedShortType
>::get());
415 CPPUNIT_ASSERT_EQUAL(
416 cppu::getTypeFavourChar(static_cast<sal_Int32
*>(nullptr)),
417 cppu::UnoType
<sal_Int32
>::get());
418 CPPUNIT_ASSERT_EQUAL(
419 cppu::getTypeFavourChar(static_cast<sal_uInt32
*>(nullptr)),
420 cppu::UnoType
<sal_uInt32
>::get());
421 CPPUNIT_ASSERT_EQUAL(
422 cppu::getTypeFavourChar(static_cast<sal_Int64
*>(nullptr)),
423 cppu::UnoType
<sal_Int64
>::get());
424 CPPUNIT_ASSERT_EQUAL(
425 cppu::getTypeFavourChar(static_cast<sal_uInt64
*>(nullptr)),
426 cppu::UnoType
<sal_uInt64
>::get());
427 CPPUNIT_ASSERT_EQUAL(
428 cppu::getTypeFavourChar(static_cast<float *>(nullptr)),
429 cppu::UnoType
<float>::get());
430 CPPUNIT_ASSERT_EQUAL(
431 cppu::getTypeFavourChar(static_cast<double *>(nullptr)),
432 cppu::UnoType
<double>::get());
433 CPPUNIT_ASSERT_EQUAL(
434 cppu::getTypeFavourChar(static_cast<cppu::UnoCharType
*>(nullptr)),
435 cppu::UnoType
<cppu::UnoCharType
>::get());
436 CPPUNIT_ASSERT_EQUAL(
437 cppu::getTypeFavourChar(static_cast<sal_Unicode
*>(nullptr)),
438 cppu::UnoType
<cppu::UnoCharType
>::get());
439 CPPUNIT_ASSERT_EQUAL(
440 cppu::getTypeFavourChar(static_cast<OUString
*>(nullptr)),
441 cppu::UnoType
<OUString
>::get());
442 CPPUNIT_ASSERT_EQUAL(
443 cppu::getTypeFavourChar(static_cast<css::uno::Type
*>(nullptr)),
444 cppu::UnoType
<css::uno::Type
>::get());
445 CPPUNIT_ASSERT_EQUAL(
446 cppu::getTypeFavourChar(static_cast<css::uno::Any
*>(nullptr)),
447 cppu::UnoType
<css::uno::Any
>::get());
448 CPPUNIT_ASSERT_EQUAL(
449 cppu::getTypeFavourChar(
451 cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
> *>(nullptr)),
453 cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
>>::get());
454 CPPUNIT_ASSERT_EQUAL(
455 cppu::getTypeFavourChar(
456 static_cast<css::uno::Sequence
<sal_uInt16
> *>(nullptr)),
458 cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
>>::get());
459 CPPUNIT_ASSERT_EQUAL(
460 cppu::getTypeFavourChar(
462 cppu::UnoSequenceType
<
463 cppu::UnoSequenceType
<
464 cppu::UnoUnsignedShortType
>> *>(nullptr)),
466 cppu::UnoSequenceType
<
467 cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
>>>::get());
468 CPPUNIT_ASSERT_EQUAL(
469 cppu::getTypeFavourChar(
471 css::uno::Sequence
<css::uno::Sequence
<sal_uInt16
>> *>(nullptr)),
473 cppu::UnoSequenceType
<
474 cppu::UnoSequenceType
<cppu::UnoUnsignedShortType
>>>::get());
475 CPPUNIT_ASSERT_EQUAL(
476 cppu::getTypeFavourChar(
477 static_cast<css::uno::Sequence
<sal_Unicode
> *>(nullptr)),
478 cppu::UnoType
<cppu::UnoSequenceType
<cppu::UnoCharType
>>::get());
479 CPPUNIT_ASSERT_EQUAL(
480 cppu::getTypeFavourChar(
483 css::uno::Sequence
<sal_Unicode
>> *>(nullptr)),
485 cppu::UnoSequenceType
<
486 cppu::UnoSequenceType
<cppu::UnoCharType
>>>::get());
487 CPPUNIT_ASSERT_EQUAL(
488 cppu::getTypeFavourChar(static_cast<css::uno::TypeClass
*>(nullptr)),
489 cppu::UnoType
<css::uno::TypeClass
>::get());
490 CPPUNIT_ASSERT_EQUAL(
491 cppu::getTypeFavourChar(static_cast<css::lang::EventObject
*>(nullptr)),
492 cppu::UnoType
<css::lang::EventObject
>::get());
493 CPPUNIT_ASSERT_EQUAL(
494 cppu::getTypeFavourChar(static_cast<DerivedStruct1
*>(nullptr)),
495 cppu::UnoType
<css::lang::EventObject
>::get());
496 CPPUNIT_ASSERT_EQUAL(
497 cppu::getTypeFavourChar(
498 static_cast<css::beans::PropertyChangeEvent
*>(nullptr)),
499 cppu::UnoType
<css::beans::PropertyChangeEvent
>::get());
500 CPPUNIT_ASSERT_EQUAL(
501 cppu::getTypeFavourChar(static_cast<DerivedStruct2
*>(nullptr)),
502 cppu::UnoType
<css::beans::PropertyChangeEvent
>::get());
503 CPPUNIT_ASSERT_EQUAL(
504 cppu::getTypeFavourChar(
505 static_cast<css::beans::Optional
<sal_Int8
> *>(nullptr)),
506 cppu::UnoType
<css::beans::Optional
<sal_Int8
>>::get());
507 CPPUNIT_ASSERT_EQUAL(
508 cppu::getTypeFavourChar(static_cast<css::uno::Exception
*>(nullptr)),
509 cppu::UnoType
<css::uno::Exception
>::get());
510 CPPUNIT_ASSERT_EQUAL(
511 cppu::getTypeFavourChar(static_cast<DerivedException1
*>(nullptr)),
512 cppu::UnoType
<css::uno::Exception
>::get());
513 CPPUNIT_ASSERT_EQUAL(
514 cppu::getTypeFavourChar(
515 static_cast<css::uno::RuntimeException
*>(nullptr)),
516 cppu::UnoType
<css::uno::RuntimeException
>::get());
517 CPPUNIT_ASSERT_EQUAL(
518 cppu::getTypeFavourChar(static_cast<DerivedException2
*>(nullptr)),
519 cppu::UnoType
<css::uno::RuntimeException
>::get());
520 CPPUNIT_ASSERT_EQUAL(
521 cppu::getTypeFavourChar(static_cast<css::uno::XInterface
*>(nullptr)),
522 cppu::UnoType
<css::uno::XInterface
>::get());
523 CPPUNIT_ASSERT_EQUAL(
524 cppu::getTypeFavourChar(
525 static_cast<css::uno::Reference
<css::uno::XInterface
> *>(nullptr)),
526 cppu::UnoType
<css::uno::XInterface
>::get());
527 CPPUNIT_ASSERT_EQUAL(
528 cppu::getTypeFavourChar(static_cast<DerivedInterface1
*>(nullptr)),
529 cppu::UnoType
<css::uno::XInterface
>::get());
530 CPPUNIT_ASSERT_EQUAL(
531 cppu::getTypeFavourChar(
532 static_cast<css::uno::Reference
<DerivedInterface1
> *>(nullptr)),
533 cppu::UnoType
<css::uno::XInterface
>::get());
534 CPPUNIT_ASSERT_EQUAL(
535 cppu::getTypeFavourChar(
536 static_cast<css::uno::XComponentContext
*>(nullptr)),
537 cppu::UnoType
<css::uno::XComponentContext
>::get());
538 CPPUNIT_ASSERT_EQUAL(
539 cppu::getTypeFavourChar(
541 css::uno::Reference
<css::uno::XComponentContext
> *>(nullptr)),
542 cppu::UnoType
<css::uno::XComponentContext
>::get());
543 CPPUNIT_ASSERT_EQUAL(
544 cppu::getTypeFavourChar(static_cast<DerivedInterface2
*>(nullptr)),
545 cppu::UnoType
<css::uno::XComponentContext
>::get());
546 CPPUNIT_ASSERT_EQUAL(
547 cppu::getTypeFavourChar(
548 static_cast<css::uno::Reference
<DerivedInterface2
> *>(nullptr)),
549 cppu::UnoType
<css::uno::XComponentContext
>::get());
552 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
556 CPPUNIT_PLUGIN_IMPLEMENT();
558 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */