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