bump product version to 4.1.6.2
[LibreOffice.git] / cppu / qa / test_unotype.cxx
blob06f6763f580cb19717cd49fef87e221bbc0db85b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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/TestSuite.h>
23 #include <cppunit/TestFixture.h>
24 #include <cppunit/TestCase.h>
25 #include <cppunit/plugin/TestPlugIn.h>
26 #include <cppunit/extensions/HelperMacros.h>
28 #include <typeinfo>
30 #include "com/sun/star/beans/Optional.hpp"
31 #include "com/sun/star/beans/PropertyChangeEvent.hpp"
32 #include "com/sun/star/lang/EventObject.hpp"
33 #include "com/sun/star/uno/Exception.hpp"
34 #include "com/sun/star/uno/Reference.hxx"
35 #include "com/sun/star/uno/RuntimeException.hpp"
36 #include "com/sun/star/uno/Sequence.hxx"
37 #include "com/sun/star/uno/Type.hxx"
38 #include "com/sun/star/uno/TypeClass.hpp"
39 #include "com/sun/star/uno/XComponentContext.hpp"
40 #include "com/sun/star/uno/XInterface.hpp"
41 #include "cppu/unotype.hxx"
42 #include "rtl/ustring.hxx"
44 namespace com { namespace sun { namespace star { namespace uno {
45 class Any;
46 } } } }
48 namespace {
50 struct DerivedStruct1: css::lang::EventObject {};
52 struct DerivedStruct2: css::beans::PropertyChangeEvent {};
54 struct DerivedException1: css::uno::Exception {};
56 struct DerivedException2: css::uno::RuntimeException {};
58 struct DerivedInterface1: css::uno::XInterface {
59 private:
60 ~DerivedInterface1() {}
61 // avoid warnings about virtual members and non-virtual dtor
64 struct DerivedInterface2: css::uno::XComponentContext {
65 private:
66 ~DerivedInterface2() {}
67 // avoid warnings about virtual members and non-virtual dtor
70 class Test: public ::CppUnit::TestFixture {
71 public:
72 void testUnoType();
74 void testGetTypeFavourUnsigned();
76 void testGetTypeFavourChar();
78 CPPUNIT_TEST_SUITE(Test);
79 CPPUNIT_TEST(testUnoType);
80 CPPUNIT_TEST(testGetTypeFavourUnsigned);
81 CPPUNIT_TEST(testGetTypeFavourChar);
82 CPPUNIT_TEST_SUITE_END();
85 void Test::testUnoType() {
86 css::uno::Type t;
87 t = ::cppu::UnoType< ::cppu::UnoVoidType >::get();
88 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_VOID, +t.getTypeClass());
89 CPPUNIT_ASSERT_EQUAL(
90 ::rtl::OUString("void"), t.getTypeName());
91 t = ::cppu::UnoType< bool >::get();
92 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_BOOLEAN, +t.getTypeClass());
93 CPPUNIT_ASSERT_EQUAL(
94 ::rtl::OUString("boolean"),
95 t.getTypeName());
96 CPPUNIT_ASSERT(::cppu::UnoType< ::sal_Bool >::get() == t);
97 t = ::cppu::UnoType< ::sal_Int8 >::get();
98 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_BYTE, +t.getTypeClass());
99 CPPUNIT_ASSERT_EQUAL(
100 ::rtl::OUString("byte"), t.getTypeName());
101 t = ::cppu::UnoType< ::sal_Int16 >::get();
102 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SHORT, +t.getTypeClass());
103 CPPUNIT_ASSERT_EQUAL(
104 ::rtl::OUString("short"), t.getTypeName());
105 t = ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
106 CPPUNIT_ASSERT_EQUAL(
107 +css::uno::TypeClass_UNSIGNED_SHORT, +t.getTypeClass());
108 CPPUNIT_ASSERT_EQUAL(
109 ::rtl::OUString("unsigned short"),
110 t.getTypeName());
111 t = ::cppu::UnoType< ::sal_Int32 >::get();
112 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_LONG, +t.getTypeClass());
113 CPPUNIT_ASSERT_EQUAL(
114 ::rtl::OUString("long"), t.getTypeName());
115 t = ::cppu::UnoType< ::sal_uInt32 >::get();
116 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_UNSIGNED_LONG, +t.getTypeClass());
117 CPPUNIT_ASSERT_EQUAL(
118 ::rtl::OUString("unsigned long"),
119 t.getTypeName());
120 t = ::cppu::UnoType< ::sal_Int64 >::get();
121 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_HYPER, +t.getTypeClass());
122 CPPUNIT_ASSERT_EQUAL(
123 ::rtl::OUString("hyper"), t.getTypeName());
124 t = ::cppu::UnoType< ::sal_uInt64 >::get();
125 CPPUNIT_ASSERT_EQUAL(
126 +css::uno::TypeClass_UNSIGNED_HYPER, +t.getTypeClass());
127 CPPUNIT_ASSERT_EQUAL(
128 ::rtl::OUString("unsigned hyper"),
129 t.getTypeName());
130 t = ::cppu::UnoType< float >::get();
131 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_FLOAT, +t.getTypeClass());
132 CPPUNIT_ASSERT_EQUAL(
133 ::rtl::OUString("float"), t.getTypeName());
134 t = ::cppu::UnoType< double >::get();
135 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_DOUBLE, +t.getTypeClass());
136 CPPUNIT_ASSERT_EQUAL(
137 ::rtl::OUString("double"),
138 t.getTypeName());
139 t = ::cppu::UnoType< ::cppu::UnoCharType >::get();
140 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_CHAR, +t.getTypeClass());
141 CPPUNIT_ASSERT_EQUAL(
142 ::rtl::OUString("char"), t.getTypeName());
143 t = ::cppu::UnoType< ::rtl::OUString >::get();
144 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_STRING, +t.getTypeClass());
145 CPPUNIT_ASSERT_EQUAL(
146 ::rtl::OUString("string"),
147 t.getTypeName());
148 t = ::cppu::UnoType< css::uno::Type >::get();
149 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_TYPE, +t.getTypeClass());
150 CPPUNIT_ASSERT_EQUAL(
151 ::rtl::OUString("type"), t.getTypeName());
152 t = ::cppu::UnoType< css::uno::Any >::get();
153 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_ANY, +t.getTypeClass());
154 CPPUNIT_ASSERT_EQUAL(
155 ::rtl::OUString("any"), t.getTypeName());
156 t = ::cppu::UnoType< ::cppu::UnoSequenceType< ::sal_Int8 > >::get();
157 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass());
158 CPPUNIT_ASSERT_EQUAL(
159 ::rtl::OUString("[]byte"),
160 t.getTypeName());
161 CPPUNIT_ASSERT(
162 ::cppu::UnoType< css::uno::Sequence< ::sal_Int8 > >::get() == t);
163 t = ::cppu::UnoType<
164 ::cppu::UnoSequenceType< ::cppu::UnoUnsignedShortType > >::get();
165 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass());
166 CPPUNIT_ASSERT_EQUAL(
167 ::rtl::OUString("[]unsigned short"),
168 t.getTypeName());
169 t = ::cppu::UnoType<
170 ::cppu::UnoSequenceType< ::cppu::UnoCharType > >::get();
171 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass());
172 CPPUNIT_ASSERT_EQUAL(
173 ::rtl::OUString("[]char"),
174 t.getTypeName());
175 t = ::cppu::UnoType< ::cppu::UnoSequenceType< ::cppu::UnoSequenceType<
176 ::sal_Int8 > > >::get();
177 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass());
178 CPPUNIT_ASSERT_EQUAL(
179 ::rtl::OUString("[][]byte"),
180 t.getTypeName());
181 CPPUNIT_ASSERT(
182 ::cppu::UnoType<
183 css::uno::Sequence< css::uno::Sequence< ::sal_Int8 > > >::get() == t);
184 t = ::cppu::UnoType< ::cppu::UnoSequenceType< ::cppu::UnoSequenceType<
185 ::cppu::UnoUnsignedShortType > > >::get();
186 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass());
187 CPPUNIT_ASSERT_EQUAL(
188 ::rtl::OUString("[][]unsigned short"),
189 t.getTypeName());
190 t = ::cppu::UnoType< ::cppu::UnoSequenceType< ::cppu::UnoSequenceType<
191 ::cppu::UnoCharType > > >::get();
192 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_SEQUENCE, +t.getTypeClass());
193 CPPUNIT_ASSERT_EQUAL(
194 ::rtl::OUString("[][]char"),
195 t.getTypeName());
196 t = ::cppu::UnoType< css::uno::TypeClass >::get();
197 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_ENUM, +t.getTypeClass());
198 CPPUNIT_ASSERT_EQUAL(
199 ::rtl::OUString("com.sun.star.uno.TypeClass"),
200 t.getTypeName());
201 t = ::cppu::UnoType< css::lang::EventObject >::get();
202 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_STRUCT, +t.getTypeClass());
203 CPPUNIT_ASSERT_EQUAL(
204 ::rtl::OUString("com.sun.star.lang.EventObject"),
205 t.getTypeName());
206 CPPUNIT_ASSERT(::cppu::UnoType< DerivedStruct1 >::get() == t);
207 t = ::cppu::UnoType< css::beans::PropertyChangeEvent >::get();
208 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_STRUCT, +t.getTypeClass());
209 CPPUNIT_ASSERT_EQUAL(
210 ::rtl::OUString(
211 "com.sun.star.beans.PropertyChangeEvent"),
212 t.getTypeName());
213 #if !(defined __SUNPRO_CC && __SUNPRO_CC <= 0x550) // erroneous ambiguity stated
214 CPPUNIT_ASSERT(::cppu::UnoType< DerivedStruct2 >::get() == t);
215 #endif
216 t = ::cppu::UnoType< css::beans::Optional< ::sal_Int8 > >::get();
217 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_STRUCT, +t.getTypeClass());
218 CPPUNIT_ASSERT_EQUAL(
219 ::rtl::OUString("com.sun.star.beans.Optional<byte>"),
220 t.getTypeName());
221 t = ::cppu::UnoType< css::uno::Exception >::get();
222 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_EXCEPTION, +t.getTypeClass());
223 CPPUNIT_ASSERT_EQUAL(
224 ::rtl::OUString("com.sun.star.uno.Exception"),
225 t.getTypeName());
226 CPPUNIT_ASSERT(::cppu::UnoType< DerivedException1 >::get() == t);
227 t = ::cppu::UnoType< css::uno::RuntimeException >::get();
228 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_EXCEPTION, +t.getTypeClass());
229 CPPUNIT_ASSERT_EQUAL(
230 ::rtl::OUString("com.sun.star.uno.RuntimeException"),
231 t.getTypeName());
232 #if !(defined __SUNPRO_CC && __SUNPRO_CC <= 0x550) // erroneous ambiguity stated
233 CPPUNIT_ASSERT(::cppu::UnoType< DerivedException2 >::get() == t);
234 #endif
235 t = ::cppu::UnoType< css::uno::XInterface >::get();
236 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_INTERFACE, +t.getTypeClass());
237 CPPUNIT_ASSERT_EQUAL(
238 ::rtl::OUString("com.sun.star.uno.XInterface"),
239 t.getTypeName());
240 CPPUNIT_ASSERT(
241 ::cppu::UnoType< css::uno::Reference< css::uno::XInterface > >::get() ==
243 CPPUNIT_ASSERT(::cppu::UnoType< DerivedInterface1 >::get() == t);
244 CPPUNIT_ASSERT(
245 ::cppu::UnoType< css::uno::Reference< DerivedInterface1 > >::get() ==
247 t = ::cppu::UnoType< css::uno::XComponentContext >::get();
248 CPPUNIT_ASSERT_EQUAL(+css::uno::TypeClass_INTERFACE, +t.getTypeClass());
249 CPPUNIT_ASSERT_EQUAL(
250 ::rtl::OUString("com.sun.star.uno.XComponentContext"),
251 t.getTypeName());
252 CPPUNIT_ASSERT(
253 ::cppu::UnoType<
254 css::uno::Reference< css::uno::XComponentContext > >::get() == t);
255 #if !(defined __SUNPRO_CC && __SUNPRO_CC <= 0x550) // erroneous ambiguity stated
256 CPPUNIT_ASSERT(::cppu::UnoType< DerivedInterface2 >::get() == t);
257 CPPUNIT_ASSERT(
258 ::cppu::UnoType< css::uno::Reference< DerivedInterface2 > >::get() ==
260 #endif
263 void Test::testGetTypeFavourUnsigned() {
264 CPPUNIT_ASSERT(typeid(::sal_Unicode) == typeid(::sal_uInt16));
265 CPPUNIT_ASSERT(
266 ::getCppuType(static_cast< ::sal_Unicode * >(0)) ==
267 ::getCppuType(static_cast< ::sal_uInt16 * >(0)));
268 CPPUNIT_ASSERT(
269 ::cppu::getTypeFavourUnsigned(
270 static_cast< ::cppu::UnoVoidType * >(0)) ==
271 ::cppu::UnoType< ::cppu::UnoVoidType >::get());
272 CPPUNIT_ASSERT(
273 ::cppu::getTypeFavourUnsigned(static_cast< bool * >(0)) ==
274 ::cppu::UnoType< bool >::get());
275 CPPUNIT_ASSERT(
276 ::cppu::getTypeFavourUnsigned(static_cast< bool * >(0)) ==
277 ::getCppuType(static_cast< bool * >(0)));
278 CPPUNIT_ASSERT(
279 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Bool * >(0)) ==
280 ::cppu::UnoType< bool >::get());
281 CPPUNIT_ASSERT(
282 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Bool * >(0)) ==
283 ::getCppuType(static_cast< ::sal_Bool * >(0)));
284 CPPUNIT_ASSERT(
285 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Int8 * >(0)) ==
286 ::cppu::UnoType< ::sal_Int8 >::get());
287 CPPUNIT_ASSERT(
288 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Int8 * >(0)) ==
289 ::getCppuType(static_cast< ::sal_Int8 * >(0)));
290 CPPUNIT_ASSERT(
291 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Int16 * >(0)) ==
292 ::cppu::UnoType< ::sal_Int16 >::get());
293 CPPUNIT_ASSERT(
294 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Int16 * >(0)) ==
295 ::getCppuType(static_cast< ::sal_Int16 * >(0)));
296 CPPUNIT_ASSERT(
297 ::cppu::getTypeFavourUnsigned(
298 static_cast< ::cppu::UnoUnsignedShortType * >(0)) ==
299 ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get());
300 CPPUNIT_ASSERT(
301 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_uInt16 * >(0)) ==
302 ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get());
303 CPPUNIT_ASSERT(
304 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_uInt16 * >(0)) ==
305 ::getCppuType(static_cast< ::sal_uInt16 * >(0)));
306 CPPUNIT_ASSERT(
307 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Int32 * >(0)) ==
308 ::cppu::UnoType< ::sal_Int32 >::get());
309 CPPUNIT_ASSERT(
310 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Int32 * >(0)) ==
311 ::getCppuType(static_cast< ::sal_Int32 * >(0)));
312 CPPUNIT_ASSERT(
313 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_uInt32 * >(0)) ==
314 ::cppu::UnoType< ::sal_uInt32 >::get());
315 CPPUNIT_ASSERT(
316 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_uInt32 * >(0)) ==
317 ::getCppuType(static_cast< ::sal_uInt32 * >(0)));
318 CPPUNIT_ASSERT(
319 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Int64 * >(0)) ==
320 ::cppu::UnoType< ::sal_Int64 >::get());
321 CPPUNIT_ASSERT(
322 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Int64 * >(0)) ==
323 ::getCppuType(static_cast< ::sal_Int64 * >(0)));
324 CPPUNIT_ASSERT(
325 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_uInt64 * >(0)) ==
326 ::cppu::UnoType< ::sal_uInt64 >::get());
327 CPPUNIT_ASSERT(
328 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_uInt64 * >(0)) ==
329 ::getCppuType(static_cast< ::sal_uInt64 * >(0)));
330 CPPUNIT_ASSERT(
331 ::cppu::getTypeFavourUnsigned(static_cast< float * >(0)) ==
332 ::cppu::UnoType< float >::get());
333 CPPUNIT_ASSERT(
334 ::cppu::getTypeFavourUnsigned(static_cast< float * >(0)) ==
335 ::getCppuType(static_cast< float * >(0)));
336 CPPUNIT_ASSERT(
337 ::cppu::getTypeFavourUnsigned(static_cast< double * >(0)) ==
338 ::cppu::UnoType< double >::get());
339 CPPUNIT_ASSERT(
340 ::cppu::getTypeFavourUnsigned(static_cast< double * >(0)) ==
341 ::getCppuType(static_cast< double * >(0)));
342 CPPUNIT_ASSERT(
343 ::cppu::getTypeFavourUnsigned(
344 static_cast< ::cppu::UnoCharType * >(0)) ==
345 ::cppu::UnoType< ::cppu::UnoCharType >::get());
346 CPPUNIT_ASSERT(
347 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Unicode * >(0)) ==
348 ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get());
349 CPPUNIT_ASSERT(
350 ::cppu::getTypeFavourUnsigned(static_cast< ::sal_Unicode * >(0)) ==
351 ::getCppuType(static_cast< ::sal_Unicode * >(0)));
352 CPPUNIT_ASSERT(
353 ::cppu::getTypeFavourUnsigned(static_cast< ::rtl::OUString * >(0)) ==
354 ::cppu::UnoType< ::rtl::OUString >::get());
355 CPPUNIT_ASSERT(
356 ::cppu::getTypeFavourUnsigned(static_cast< ::rtl::OUString * >(0)) ==
357 ::getCppuType(static_cast< ::rtl::OUString * >(0)));
358 CPPUNIT_ASSERT(
359 ::cppu::getTypeFavourUnsigned(static_cast< css::uno::Type * >(0)) ==
360 ::cppu::UnoType< css::uno::Type >::get());
361 CPPUNIT_ASSERT(
362 ::cppu::getTypeFavourUnsigned(static_cast< css::uno::Type * >(0)) ==
363 ::getCppuType(static_cast< css::uno::Type * >(0)));
364 CPPUNIT_ASSERT(
365 ::cppu::getTypeFavourUnsigned(static_cast< css::uno::Any * >(0)) ==
366 ::cppu::UnoType< css::uno::Any >::get());
367 CPPUNIT_ASSERT(
368 ::cppu::getTypeFavourUnsigned(static_cast< css::uno::Any * >(0)) ==
369 ::getCppuType(static_cast< css::uno::Any * >(0)));
370 CPPUNIT_ASSERT(
371 ::cppu::getTypeFavourUnsigned(
372 static_cast<
373 ::cppu::UnoSequenceType< ::cppu::UnoUnsignedShortType > * >(0)) ==
374 ::cppu::UnoType<
375 ::cppu::UnoSequenceType< ::cppu::UnoUnsignedShortType > >::get());
376 CPPUNIT_ASSERT(
377 ::cppu::getTypeFavourUnsigned(
378 static_cast< css::uno::Sequence< ::sal_uInt16 > * >(0)) ==
379 ::cppu::UnoType<
380 ::cppu::UnoSequenceType< ::cppu::UnoUnsignedShortType > >::get());
381 CPPUNIT_ASSERT(
382 ::cppu::getTypeFavourUnsigned(
383 static_cast< css::uno::Sequence< ::sal_uInt16 > * >(0)) ==
384 ::getCppuType(static_cast< css::uno::Sequence< ::sal_uInt16 > * >(0)));
385 CPPUNIT_ASSERT(
386 ::cppu::getTypeFavourUnsigned(
387 static_cast< ::cppu::UnoSequenceType< ::cppu::UnoSequenceType<
388 ::cppu::UnoUnsignedShortType > > * >(0)) ==
389 ::cppu::UnoType< ::cppu::UnoSequenceType< ::cppu::UnoSequenceType<
390 ::cppu::UnoUnsignedShortType > > >::get());
391 CPPUNIT_ASSERT(
392 ::cppu::getTypeFavourUnsigned(
393 static_cast< css::uno::Sequence< css::uno::Sequence<
394 ::sal_uInt16 > > * >(0)) ==
395 ::cppu::UnoType< ::cppu::UnoSequenceType< ::cppu::UnoSequenceType<
396 ::cppu::UnoUnsignedShortType > > >::get());
397 CPPUNIT_ASSERT(
398 ::cppu::getTypeFavourUnsigned(
399 static_cast< css::uno::Sequence< css::uno::Sequence<
400 ::sal_uInt16 > > * >(0)) ==
401 ::getCppuType(
402 static_cast< css::uno::Sequence< css::uno::Sequence<
403 ::sal_uInt16 > > * >(0)));
404 CPPUNIT_ASSERT(
405 ::cppu::getTypeFavourUnsigned(
406 static_cast< css::uno::Sequence< ::sal_Unicode > * >(0)) ==
407 ::cppu::UnoType<
408 ::cppu::UnoSequenceType< ::cppu::UnoUnsignedShortType > >::get());
409 CPPUNIT_ASSERT(
410 ::cppu::getTypeFavourUnsigned(
411 static_cast< css::uno::Sequence< ::sal_Unicode > * >(0)) ==
412 ::getCppuType(static_cast< css::uno::Sequence< ::sal_Unicode > * >(0)));
413 CPPUNIT_ASSERT(
414 ::cppu::getTypeFavourUnsigned(
415 static_cast< css::uno::Sequence< css::uno::Sequence<
416 ::sal_Unicode > > * >(0)) ==
417 ::cppu::UnoType< ::cppu::UnoSequenceType< ::cppu::UnoSequenceType<
418 ::cppu::UnoUnsignedShortType > > >::get());
419 CPPUNIT_ASSERT(
420 ::cppu::getTypeFavourUnsigned(
421 static_cast< css::uno::Sequence< css::uno::Sequence<
422 ::sal_Unicode > > * >(0)) ==
423 ::getCppuType(
424 static_cast< css::uno::Sequence< css::uno::Sequence<
425 ::sal_Unicode > > * >(0)));
426 CPPUNIT_ASSERT(
427 ::cppu::getTypeFavourUnsigned(
428 static_cast< css::uno::TypeClass * >(0)) ==
429 ::cppu::UnoType< css::uno::TypeClass >::get());
430 CPPUNIT_ASSERT(
431 ::cppu::getTypeFavourUnsigned(
432 static_cast< css::uno::TypeClass * >(0)) ==
433 ::getCppuType(static_cast< css::uno::TypeClass * >(0)));
434 CPPUNIT_ASSERT(
435 ::cppu::getTypeFavourUnsigned(
436 static_cast< css::lang::EventObject * >(0)) ==
437 ::cppu::UnoType< css::lang::EventObject >::get());
438 CPPUNIT_ASSERT(
439 ::cppu::getTypeFavourUnsigned(
440 static_cast< css::lang::EventObject * >(0)) ==
441 ::getCppuType(static_cast< css::lang::EventObject * >(0)));
442 CPPUNIT_ASSERT(
443 ::cppu::getTypeFavourUnsigned(static_cast< DerivedStruct1 * >(0)) ==
444 ::cppu::UnoType< css::lang::EventObject >::get());
445 CPPUNIT_ASSERT(
446 ::cppu::getTypeFavourUnsigned(static_cast< DerivedStruct1 * >(0)) ==
447 ::getCppuType(static_cast< DerivedStruct1 * >(0)));
448 CPPUNIT_ASSERT(
449 ::cppu::getTypeFavourUnsigned(
450 static_cast< css::beans::PropertyChangeEvent * >(0)) ==
451 ::cppu::UnoType< css::beans::PropertyChangeEvent >::get());
452 CPPUNIT_ASSERT(
453 ::cppu::getTypeFavourUnsigned(
454 static_cast< css::beans::PropertyChangeEvent * >(0)) ==
455 ::getCppuType(static_cast< css::beans::PropertyChangeEvent * >(0)));
456 #if !(defined __SUNPRO_CC && __SUNPRO_CC <= 0x550) // erroneous ambiguity stated
457 CPPUNIT_ASSERT(
458 ::cppu::getTypeFavourUnsigned(static_cast< DerivedStruct2 * >(0)) ==
459 ::cppu::UnoType< css::beans::PropertyChangeEvent >::get());
460 CPPUNIT_ASSERT(
461 ::cppu::getTypeFavourUnsigned(static_cast< DerivedStruct2 * >(0)) ==
462 ::getCppuType(static_cast< DerivedStruct2 * >(0)));
463 #endif
464 CPPUNIT_ASSERT(
465 ::cppu::getTypeFavourUnsigned(
466 static_cast< css::beans::Optional< ::sal_Int8 > * >(0)) ==
467 ::cppu::UnoType< css::beans::Optional< ::sal_Int8 > >::get());
468 CPPUNIT_ASSERT(
469 ::cppu::getTypeFavourUnsigned(
470 static_cast< css::beans::Optional< ::sal_Int8 > * >(0)) ==
471 ::getCppuType(static_cast< css::beans::Optional< ::sal_Int8 > * >(0)));
472 CPPUNIT_ASSERT(
473 ::cppu::getTypeFavourUnsigned(
474 static_cast< css::uno::Exception * >(0)) ==
475 ::cppu::UnoType< css::uno::Exception >::get());
476 CPPUNIT_ASSERT(
477 ::cppu::getTypeFavourUnsigned(
478 static_cast< css::uno::Exception * >(0)) ==
479 ::getCppuType(static_cast< css::uno::Exception * >(0)));
480 CPPUNIT_ASSERT(
481 ::cppu::getTypeFavourUnsigned(static_cast< DerivedException1 * >(0)) ==
482 ::cppu::UnoType< css::uno::Exception >::get());
483 CPPUNIT_ASSERT(
484 ::cppu::getTypeFavourUnsigned(static_cast< DerivedException1 * >(0)) ==
485 ::getCppuType(static_cast< DerivedException1 * >(0)));
486 CPPUNIT_ASSERT(
487 ::cppu::getTypeFavourUnsigned(
488 static_cast< css::uno::RuntimeException * >(0)) ==
489 ::cppu::UnoType< css::uno::RuntimeException >::get());
490 CPPUNIT_ASSERT(
491 ::cppu::getTypeFavourUnsigned(
492 static_cast< css::uno::RuntimeException * >(0)) ==
493 ::getCppuType(static_cast< css::uno::RuntimeException * >(0)));
494 #if !(defined __SUNPRO_CC && __SUNPRO_CC <= 0x550) // erroneous ambiguity stated
495 CPPUNIT_ASSERT(
496 ::cppu::getTypeFavourUnsigned(static_cast< DerivedException2 * >(0)) ==
497 ::cppu::UnoType< css::uno::RuntimeException >::get());
498 CPPUNIT_ASSERT(
499 ::cppu::getTypeFavourUnsigned(static_cast< DerivedException2 * >(0)) ==
500 ::getCppuType(static_cast< DerivedException2 * >(0)));
501 #endif
502 CPPUNIT_ASSERT(
503 ::cppu::getTypeFavourUnsigned(
504 static_cast< css::uno::XInterface * >(0)) ==
505 ::cppu::UnoType< css::uno::XInterface >::get());
506 CPPUNIT_ASSERT(
507 ::cppu::getTypeFavourUnsigned(
508 static_cast< css::uno::Reference< css::uno::XInterface > * >(0)) ==
509 ::cppu::UnoType< css::uno::XInterface >::get());
510 CPPUNIT_ASSERT(
511 ::cppu::getTypeFavourUnsigned(
512 static_cast< css::uno::Reference< css::uno::XInterface > * >(0)) ==
513 ::getCppuType(
514 static_cast< css::uno::Reference< css::uno::XInterface > * >(0)));
515 CPPUNIT_ASSERT(
516 ::cppu::getTypeFavourUnsigned(static_cast< DerivedInterface1 * >(0)) ==
517 ::cppu::UnoType< css::uno::XInterface >::get());
518 CPPUNIT_ASSERT(
519 ::cppu::getTypeFavourUnsigned(
520 static_cast< css::uno::Reference< DerivedInterface1 > * >(0)) ==
521 ::cppu::UnoType< css::uno::XInterface >::get());
522 CPPUNIT_ASSERT(
523 ::cppu::getTypeFavourUnsigned(
524 static_cast< css::uno::XComponentContext * >(0)) ==
525 ::cppu::UnoType< css::uno::XComponentContext >::get());
526 CPPUNIT_ASSERT(
527 ::cppu::getTypeFavourUnsigned(
528 static_cast<
529 css::uno::Reference< css::uno::XComponentContext > * >(0)) ==
530 ::cppu::UnoType< css::uno::XComponentContext >::get());
531 CPPUNIT_ASSERT(
532 ::cppu::getTypeFavourUnsigned(
533 static_cast<
534 css::uno::Reference< css::uno::XComponentContext > * >(0)) ==
535 ::getCppuType(
536 static_cast<
537 css::uno::Reference< css::uno::XComponentContext > * >(0)));
538 #if !(defined __SUNPRO_CC && __SUNPRO_CC <= 0x550) // erroneous ambiguity stated
539 CPPUNIT_ASSERT(
540 ::cppu::getTypeFavourUnsigned(static_cast< DerivedInterface2 * >(0)) ==
541 ::cppu::UnoType< css::uno::XComponentContext >::get());
542 CPPUNIT_ASSERT(
543 ::cppu::getTypeFavourUnsigned(
544 static_cast< css::uno::Reference< DerivedInterface2 > * >(0)) ==
545 ::cppu::UnoType< css::uno::XComponentContext >::get());
546 #endif
549 void Test::testGetTypeFavourChar() {
550 CPPUNIT_ASSERT(typeid(::sal_Unicode) == typeid(::sal_uInt16));
551 CPPUNIT_ASSERT(
552 ::getCppuType< ::sal_Unicode >() == ::getCppuType< ::sal_uInt16 >());
553 CPPUNIT_ASSERT(
554 ::cppu::getTypeFavourChar(static_cast< ::cppu::UnoVoidType * >(0)) ==
555 ::cppu::UnoType< ::cppu::UnoVoidType >::get());
556 CPPUNIT_ASSERT(
557 ::cppu::getTypeFavourChar(static_cast< bool * >(0)) ==
558 ::cppu::UnoType< bool >::get());
559 CPPUNIT_ASSERT(
560 ::cppu::getTypeFavourChar(static_cast< bool * >(0)) ==
561 ::getCppuType< bool >());
562 CPPUNIT_ASSERT(
563 ::cppu::getTypeFavourChar(static_cast< ::sal_Bool * >(0)) ==
564 ::cppu::UnoType< bool >::get());
565 CPPUNIT_ASSERT(
566 ::cppu::getTypeFavourChar(static_cast< ::sal_Bool * >(0)) ==
567 ::getCppuType< ::sal_Bool >());
568 CPPUNIT_ASSERT(
569 ::cppu::getTypeFavourChar(static_cast< ::sal_Int8 * >(0)) ==
570 ::cppu::UnoType< ::sal_Int8 >::get());
571 CPPUNIT_ASSERT(
572 ::cppu::getTypeFavourChar(static_cast< ::sal_Int8 * >(0)) ==
573 ::getCppuType< ::sal_Int8 >());
574 CPPUNIT_ASSERT(
575 ::cppu::getTypeFavourChar(static_cast< ::sal_Int16 * >(0)) ==
576 ::cppu::UnoType< ::sal_Int16 >::get());
577 CPPUNIT_ASSERT(
578 ::cppu::getTypeFavourChar(static_cast< ::sal_Int16 * >(0)) ==
579 ::getCppuType< ::sal_Int16 >());
580 CPPUNIT_ASSERT(
581 ::cppu::getTypeFavourChar(
582 static_cast< ::cppu::UnoUnsignedShortType * >(0)) ==
583 ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get());
584 CPPUNIT_ASSERT(
585 ::cppu::getTypeFavourChar(static_cast< ::sal_uInt16 * >(0)) ==
586 ::cppu::UnoType< ::cppu::UnoCharType >::get());
587 CPPUNIT_ASSERT(
588 ::cppu::getTypeFavourChar(static_cast< ::sal_Int32 * >(0)) ==
589 ::cppu::UnoType< ::sal_Int32 >::get());
590 CPPUNIT_ASSERT(
591 ::cppu::getTypeFavourChar(static_cast< ::sal_Int32 * >(0)) ==
592 ::getCppuType< ::sal_Int32 >());
593 CPPUNIT_ASSERT(
594 ::cppu::getTypeFavourChar(static_cast< ::sal_uInt32 * >(0)) ==
595 ::cppu::UnoType< ::sal_uInt32 >::get());
596 CPPUNIT_ASSERT(
597 ::cppu::getTypeFavourChar(static_cast< ::sal_uInt32 * >(0)) ==
598 ::getCppuType< ::sal_uInt32 >());
599 CPPUNIT_ASSERT(
600 ::cppu::getTypeFavourChar(static_cast< ::sal_Int64 * >(0)) ==
601 ::cppu::UnoType< ::sal_Int64 >::get());
602 CPPUNIT_ASSERT(
603 ::cppu::getTypeFavourChar(static_cast< ::sal_Int64 * >(0)) ==
604 ::getCppuType< ::sal_Int64 >());
605 CPPUNIT_ASSERT(
606 ::cppu::getTypeFavourChar(static_cast< ::sal_uInt64 * >(0)) ==
607 ::cppu::UnoType< ::sal_uInt64 >::get());
608 CPPUNIT_ASSERT(
609 ::cppu::getTypeFavourChar(static_cast< ::sal_uInt64 * >(0)) ==
610 ::getCppuType< ::sal_uInt64 >());
611 CPPUNIT_ASSERT(
612 ::cppu::getTypeFavourChar(static_cast< float * >(0)) ==
613 ::cppu::UnoType< float >::get());
614 CPPUNIT_ASSERT(
615 ::cppu::getTypeFavourChar(static_cast< float * >(0)) ==
616 ::getCppuType< float >());
617 CPPUNIT_ASSERT(
618 ::cppu::getTypeFavourChar(static_cast< double * >(0)) ==
619 ::cppu::UnoType< double >::get());
620 CPPUNIT_ASSERT(
621 ::cppu::getTypeFavourChar(static_cast< double * >(0)) ==
622 ::getCppuType< double >());
623 CPPUNIT_ASSERT(
624 ::cppu::getTypeFavourChar(static_cast< ::cppu::UnoCharType * >(0)) ==
625 ::cppu::UnoType< ::cppu::UnoCharType >::get());
626 CPPUNIT_ASSERT(
627 ::cppu::getTypeFavourChar(static_cast< ::sal_Unicode * >(0)) ==
628 ::cppu::UnoType< ::cppu::UnoCharType >::get());
629 CPPUNIT_ASSERT(
630 ::cppu::getTypeFavourChar(static_cast< ::sal_Unicode * >(0)) ==
631 ::getCppuType< ::sal_Unicode >());
632 CPPUNIT_ASSERT(
633 ::cppu::getTypeFavourChar(static_cast< ::rtl::OUString * >(0)) ==
634 ::cppu::UnoType< ::rtl::OUString >::get());
635 CPPUNIT_ASSERT(
636 ::cppu::getTypeFavourChar(static_cast< ::rtl::OUString * >(0)) ==
637 ::getCppuType< ::rtl::OUString >());
638 CPPUNIT_ASSERT(
639 ::cppu::getTypeFavourChar(static_cast< css::uno::Type * >(0)) ==
640 ::cppu::UnoType< css::uno::Type >::get());
641 CPPUNIT_ASSERT(
642 ::cppu::getTypeFavourChar(static_cast< css::uno::Type * >(0)) ==
643 ::getCppuType< css::uno::Type >());
644 CPPUNIT_ASSERT(
645 ::cppu::getTypeFavourChar(static_cast< css::uno::Any * >(0)) ==
646 ::cppu::UnoType< css::uno::Any >::get());
647 CPPUNIT_ASSERT(
648 ::cppu::getTypeFavourChar(static_cast< css::uno::Any * >(0)) ==
649 ::getCppuType< css::uno::Any >());
650 CPPUNIT_ASSERT(
651 ::cppu::getTypeFavourChar(
652 static_cast<
653 ::cppu::UnoSequenceType< ::cppu::UnoUnsignedShortType > * >(0)) ==
654 ::cppu::UnoType<
655 ::cppu::UnoSequenceType< ::cppu::UnoUnsignedShortType > >::get());
656 CPPUNIT_ASSERT(
657 ::cppu::getTypeFavourChar(
658 static_cast< css::uno::Sequence< ::sal_uInt16 > * >(0)) ==
659 ::cppu::UnoType<
660 ::cppu::UnoSequenceType< ::cppu::UnoCharType > >::get());
661 CPPUNIT_ASSERT(
662 ::cppu::getTypeFavourChar(
663 static_cast< ::cppu::UnoSequenceType< ::cppu::UnoSequenceType<
664 ::cppu::UnoUnsignedShortType > > * >(0)) ==
665 ::cppu::UnoType< ::cppu::UnoSequenceType< ::cppu::UnoSequenceType<
666 ::cppu::UnoUnsignedShortType > > >::get());
667 CPPUNIT_ASSERT(
668 ::cppu::getTypeFavourChar(
669 static_cast< css::uno::Sequence< css::uno::Sequence<
670 ::sal_uInt16 > > * >(0)) ==
671 ::cppu::UnoType< ::cppu::UnoSequenceType< ::cppu::UnoSequenceType<
672 ::cppu::UnoCharType > > >::get());
673 CPPUNIT_ASSERT(
674 ::cppu::getTypeFavourChar(
675 static_cast< css::uno::Sequence< ::sal_Unicode > * >(0)) ==
676 ::cppu::UnoType<
677 ::cppu::UnoSequenceType< ::cppu::UnoCharType > >::get());
678 CPPUNIT_ASSERT(
679 ::cppu::getTypeFavourChar(
680 static_cast< css::uno::Sequence< css::uno::Sequence<
681 ::sal_Unicode > > * >(0)) ==
682 ::cppu::UnoType< ::cppu::UnoSequenceType< ::cppu::UnoSequenceType<
683 ::cppu::UnoCharType > > >::get());
684 CPPUNIT_ASSERT(
685 ::cppu::getTypeFavourChar(static_cast< css::uno::TypeClass * >(0)) ==
686 ::cppu::UnoType< css::uno::TypeClass >::get());
687 CPPUNIT_ASSERT(
688 ::cppu::getTypeFavourChar(static_cast< css::uno::TypeClass * >(0)) ==
689 ::getCppuType< css::uno::TypeClass >());
690 CPPUNIT_ASSERT(
691 ::cppu::getTypeFavourChar(
692 static_cast< css::lang::EventObject * >(0)) ==
693 ::cppu::UnoType< css::lang::EventObject >::get());
694 CPPUNIT_ASSERT(
695 ::cppu::getTypeFavourChar(
696 static_cast< css::lang::EventObject * >(0)) ==
697 ::getCppuType< css::lang::EventObject >());
698 CPPUNIT_ASSERT(
699 ::cppu::getTypeFavourChar(static_cast< DerivedStruct1 * >(0)) ==
700 ::cppu::UnoType< css::lang::EventObject >::get());
701 CPPUNIT_ASSERT(
702 ::cppu::getTypeFavourChar(static_cast< DerivedStruct1 * >(0)) ==
703 ::getCppuType< DerivedStruct1 >());
704 CPPUNIT_ASSERT(
705 ::cppu::getTypeFavourChar(
706 static_cast< css::beans::PropertyChangeEvent * >(0)) ==
707 ::cppu::UnoType< css::beans::PropertyChangeEvent >::get());
708 CPPUNIT_ASSERT(
709 ::cppu::getTypeFavourChar(
710 static_cast< css::beans::PropertyChangeEvent * >(0)) ==
711 ::getCppuType< css::beans::PropertyChangeEvent >());
712 #if !(defined __SUNPRO_CC && __SUNPRO_CC <= 0x550) // erroneous ambiguity stated
713 CPPUNIT_ASSERT(
714 ::cppu::getTypeFavourChar(static_cast< DerivedStruct2 * >(0)) ==
715 ::cppu::UnoType< css::beans::PropertyChangeEvent >::get());
716 CPPUNIT_ASSERT(
717 ::cppu::getTypeFavourChar(static_cast< DerivedStruct2 * >(0)) ==
718 ::getCppuType< DerivedStruct2 >());
719 #endif
720 CPPUNIT_ASSERT(
721 ::cppu::getTypeFavourChar(
722 static_cast< css::beans::Optional< ::sal_Int8 > * >(0)) ==
723 ::cppu::UnoType< css::beans::Optional< ::sal_Int8 > >::get());
724 CPPUNIT_ASSERT(
725 ::cppu::getTypeFavourChar(
726 static_cast< css::beans::Optional< ::sal_Int8 > * >(0)) ==
727 ::getCppuType< css::beans::Optional< ::sal_Int8 > >());
728 CPPUNIT_ASSERT(
729 ::cppu::getTypeFavourChar(static_cast< css::uno::Exception * >(0)) ==
730 ::cppu::UnoType< css::uno::Exception >::get());
731 CPPUNIT_ASSERT(
732 ::cppu::getTypeFavourChar(static_cast< css::uno::Exception * >(0)) ==
733 ::getCppuType< css::uno::Exception >());
734 CPPUNIT_ASSERT(
735 ::cppu::getTypeFavourChar(static_cast< DerivedException1 * >(0)) ==
736 ::cppu::UnoType< css::uno::Exception >::get());
737 CPPUNIT_ASSERT(
738 ::cppu::getTypeFavourChar(static_cast< DerivedException1 * >(0)) ==
739 ::getCppuType< DerivedException1 >());
740 CPPUNIT_ASSERT(
741 ::cppu::getTypeFavourChar(
742 static_cast< css::uno::RuntimeException * >(0)) ==
743 ::cppu::UnoType< css::uno::RuntimeException >::get());
744 CPPUNIT_ASSERT(
745 ::cppu::getTypeFavourChar(
746 static_cast< css::uno::RuntimeException * >(0)) ==
747 ::getCppuType< css::uno::RuntimeException >());
748 #if !(defined __SUNPRO_CC && __SUNPRO_CC <= 0x550) // erroneous ambiguity stated
749 CPPUNIT_ASSERT(
750 ::cppu::getTypeFavourChar(static_cast< DerivedException2 * >(0)) ==
751 ::cppu::UnoType< css::uno::RuntimeException >::get());
752 CPPUNIT_ASSERT(
753 ::cppu::getTypeFavourChar(static_cast< DerivedException2 * >(0)) ==
754 ::getCppuType< DerivedException2 >());
755 #endif
756 CPPUNIT_ASSERT(
757 ::cppu::getTypeFavourChar(
758 static_cast< css::uno::XInterface * >(0)) ==
759 ::cppu::UnoType< css::uno::XInterface >::get());
760 CPPUNIT_ASSERT(
761 ::cppu::getTypeFavourChar(
762 static_cast< css::uno::Reference< css::uno::XInterface > * >(0)) ==
763 ::cppu::UnoType< css::uno::XInterface >::get());
764 CPPUNIT_ASSERT(
765 ::cppu::getTypeFavourChar(
766 static_cast< css::uno::Reference< css::uno::XInterface > * >(0)) ==
767 ::getCppuType< css::uno::Reference< css::uno::XInterface > >());
768 CPPUNIT_ASSERT(
769 ::cppu::getTypeFavourChar(static_cast< DerivedInterface1 * >(0)) ==
770 ::cppu::UnoType< css::uno::XInterface >::get());
771 CPPUNIT_ASSERT(
772 ::cppu::getTypeFavourChar(
773 static_cast< css::uno::Reference< DerivedInterface1 > * >(0)) ==
774 ::cppu::UnoType< css::uno::XInterface >::get());
775 CPPUNIT_ASSERT(
776 ::cppu::getTypeFavourChar(
777 static_cast< css::uno::XComponentContext * >(0)) ==
778 ::cppu::UnoType< css::uno::XComponentContext >::get());
779 CPPUNIT_ASSERT(
780 ::cppu::getTypeFavourChar(
781 static_cast<
782 css::uno::Reference< css::uno::XComponentContext > * >(0)) ==
783 ::cppu::UnoType< css::uno::XComponentContext >::get());
784 CPPUNIT_ASSERT(
785 ::cppu::getTypeFavourChar(
786 static_cast<
787 css::uno::Reference< css::uno::XComponentContext > * >(0)) ==
788 ::getCppuType< css::uno::Reference< css::uno::XComponentContext > >());
789 #if !(defined __SUNPRO_CC && __SUNPRO_CC <= 0x550) // erroneous ambiguity stated
790 CPPUNIT_ASSERT(
791 ::cppu::getTypeFavourChar(static_cast< DerivedInterface2 * >(0)) ==
792 ::cppu::UnoType< css::uno::XComponentContext >::get());
793 CPPUNIT_ASSERT(
794 ::cppu::getTypeFavourChar(
795 static_cast< css::uno::Reference< DerivedInterface2 > * >(0)) ==
796 ::cppu::UnoType< css::uno::XComponentContext >::get());
797 #endif
800 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
804 CPPUNIT_PLUGIN_IMPLEMENT();
806 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */