Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / cppu / qa / test_any.cxx
blob757040314844f14c1379766ba48ec22b2e9ac24f
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 <stdlib.h>
24 #include <cppunit/TestFixture.h>
25 #include <cppunit/plugin/TestPlugIn.h>
26 #include <cppunit/extensions/HelperMacros.h>
28 #include <Enum1.hpp>
29 #include <Enum2.hpp>
30 #include <Exception1.hpp>
31 #include <Exception2.hpp>
32 #include <Exception2a.hpp>
33 #include <Exception2b.hpp>
34 #include <Interface1.hpp>
35 #include <Interface2.hpp>
36 #include <Interface2a.hpp>
37 #include <Interface2b.hpp>
38 #include <Interface3.hpp>
39 #include <Poly.hpp>
40 #include <Struct1.hpp>
41 #include <Struct2.hpp>
42 #include <Struct2a.hpp>
43 #include <Struct2b.hpp>
44 #include <com/sun/star/uno/Any.hxx>
45 #include <com/sun/star/uno/Reference.hxx>
46 #include <com/sun/star/uno/Sequence.hxx>
47 #include <com/sun/star/uno/Type.hxx>
48 #include <o3tl/cppunittraitshelper.hxx>
49 #include <osl/interlck.h>
50 #include <rtl/ustring.hxx>
52 namespace {
54 class Base {
55 public:
56 Base(): m_count(0) {}
58 Base(const Base&) = delete;
59 const Base& operator=(const Base&) = delete;
61 void acquire() {
62 if (osl_atomic_increment(&m_count) == SAL_MAX_INT32) {
63 abort();
67 void release() {
68 if (osl_atomic_decrement(&m_count) == 0) {
69 delete this;
73 protected:
74 virtual ~Base() {}
76 private:
77 oslInterlockedCount m_count;
80 class Impl1: public Interface1, private Base {
81 public:
82 virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const & type) override
84 if (type == cppu::UnoType<css::uno::XInterface>::get()) {
85 css::uno::Reference< css::uno::XInterface > ref(
86 static_cast< css::uno::XInterface * >(this));
87 return css::uno::Any(&ref, type);
89 if (type == cppu::UnoType<Interface1>::get()) {
90 css::uno::Reference< Interface1 > ref(this);
91 return css::uno::Any(&ref, type);
93 return css::uno::Any();
96 virtual void SAL_CALL acquire() noexcept override {
97 Base::acquire();
100 virtual void SAL_CALL release() noexcept override {
101 Base::release();
105 class Impl2: public Interface2a, public Interface3, private Base {
106 public:
107 virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const & type) override
109 if (type == cppu::UnoType<css::uno::XInterface>::get()) {
110 css::uno::Reference< css::uno::XInterface > ref(
111 static_cast< css::uno::XInterface * >(
112 static_cast< Interface2a * >(this)));
113 return css::uno::Any(&ref, type);
115 if (type == cppu::UnoType<Interface2>::get()) {
116 css::uno::Reference< Interface2 > ref(this);
117 return css::uno::Any(&ref, type);
119 if (type == cppu::UnoType<Interface2a>::get()) {
120 css::uno::Reference< Interface2a > ref(this);
121 return css::uno::Any(&ref, type);
123 if (type == cppu::UnoType<Interface3>::get()) {
124 css::uno::Reference< Interface3 > ref(this);
125 return css::uno::Any(&ref, type);
127 return css::uno::Any();
130 virtual void SAL_CALL acquire() noexcept override {
131 Base::acquire();
134 virtual void SAL_CALL release() noexcept override {
135 Base::release();
139 class Impl2b: public Interface2b, private Base {
140 public:
141 virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const & type) override
143 if (type == cppu::UnoType<css::uno::XInterface>::get()) {
144 css::uno::Reference< css::uno::XInterface > ref(
145 static_cast< css::uno::XInterface * >(
146 static_cast< Interface2a * >(this)));
147 return css::uno::Any(&ref, type);
149 if (type == cppu::UnoType<Interface2>::get()) {
150 css::uno::Reference< Interface2 > ref(this);
151 return css::uno::Any(&ref, type);
153 if (type == cppu::UnoType<Interface2a>::get()) {
154 css::uno::Reference< Interface2a > ref(this);
155 return css::uno::Any(&ref, type);
157 if (type == cppu::UnoType<Interface2b>::get()) {
158 css::uno::Reference< Interface2b > ref(this);
159 return css::uno::Any(&ref, type);
161 return css::uno::Any();
164 virtual void SAL_CALL acquire() noexcept override {
165 Base::acquire();
168 virtual void SAL_CALL release() noexcept override {
169 Base::release();
173 class Test: public CppUnit::TestFixture {
174 public:
175 void testVoid();
176 void testBoolean();
177 void testByte();
178 void testShort();
179 void testUnsignedShort();
180 void testLong();
181 void testUnsignedLong();
182 void testHyper();
183 void testUnsignedHyper();
184 void testFloat();
185 void testDouble();
186 void testChar();
187 void testString();
188 void testType();
189 void testSequence();
190 void testEnum();
191 void testStruct();
192 void testPoly();
193 void testException();
194 void testInterface();
195 void testNull();
197 CPPUNIT_TEST_SUITE(Test);
198 CPPUNIT_TEST(testVoid);
199 CPPUNIT_TEST(testBoolean);
200 CPPUNIT_TEST(testByte);
201 CPPUNIT_TEST(testShort);
202 CPPUNIT_TEST(testUnsignedShort);
203 CPPUNIT_TEST(testLong);
204 CPPUNIT_TEST(testUnsignedLong);
205 CPPUNIT_TEST(testHyper);
206 CPPUNIT_TEST(testUnsignedHyper);
207 CPPUNIT_TEST(testFloat);
208 CPPUNIT_TEST(testDouble);
209 CPPUNIT_TEST(testChar);
210 CPPUNIT_TEST(testString);
211 CPPUNIT_TEST(testType);
212 CPPUNIT_TEST(testSequence);
213 CPPUNIT_TEST(testEnum);
214 CPPUNIT_TEST(testStruct);
215 CPPUNIT_TEST(testPoly);
216 CPPUNIT_TEST(testException);
217 CPPUNIT_TEST(testInterface);
218 CPPUNIT_TEST(testNull);
219 CPPUNIT_TEST_SUITE_END();
222 void Test::testVoid() {
223 css::uno::Any a;
224 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<void>::get()));
226 bool b = true;
227 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
228 CPPUNIT_ASSERT_MESSAGE("bool", b);
231 // [-loplugin:fakebool] false positive:
232 sal_Bool b = true;
233 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
234 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
237 sal_Int8 b = 2;
238 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
239 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
242 sal_Int16 b = 2;
243 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
244 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
247 sal_uInt16 b = 2;
248 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
249 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
252 sal_Int32 b = 2;
253 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
254 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
257 sal_uInt32 b = 2;
258 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
259 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
262 sal_Int64 b = 2;
263 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
264 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
267 sal_uInt64 b = 2;
268 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
269 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
272 float b = 2;
273 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
274 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", 2.0f, b);
277 double b = 2;
278 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
279 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
282 sal_Unicode b = '2';
283 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
284 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
287 OUString b("2");
288 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
289 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
292 css::uno::Type b(cppu::UnoType<OUString>::get());
293 CPPUNIT_ASSERT_MESSAGE(
294 "css::uno::Type",
295 !(a >>= b));
296 CPPUNIT_ASSERT_EQUAL_MESSAGE(
297 "css::uno::Type",
298 cppu::UnoType<OUString>::get(), b);
301 css::uno::Sequence< OUString > b(2);
302 CPPUNIT_ASSERT_MESSAGE(
303 "css::uno::Sequence<OUString>", !(a >>= b));
304 CPPUNIT_ASSERT_EQUAL_MESSAGE(
305 "css::uno::Sequence<OUString>", sal_Int32(2), b.getLength());
308 Enum1 b = Enum1_M2;
309 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
310 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
313 Struct1 b(2);
314 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
315 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
318 Exception1 b(
319 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
320 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
321 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
324 css::uno::Reference< Interface1 > i(new Impl1);
325 css::uno::Reference< Interface1 > b(i);
326 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
327 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
331 void Test::testBoolean() {
332 css::uno::Any a(false);
333 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<bool>::get()));
335 bool b = true;
336 CPPUNIT_ASSERT_MESSAGE("bool", (a >>= b));
337 CPPUNIT_ASSERT_MESSAGE("bool", !b);
340 // [-loplugin:fakebool] false positive:
341 sal_Bool b = true;
342 CPPUNIT_ASSERT_MESSAGE("sal_Bool", (a >>= b));
343 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !b);
346 sal_Int8 b = 2;
347 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
348 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
351 sal_Int16 b = 2;
352 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
353 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
356 sal_uInt16 b = 2;
357 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
358 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
361 sal_Int32 b = 2;
362 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
363 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
366 sal_uInt32 b = 2;
367 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
368 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
371 sal_Int64 b = 2;
372 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
373 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
376 sal_uInt64 b = 2;
377 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
378 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
381 float b = 2;
382 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
383 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", 2.0f, b);
386 double b = 2;
387 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
388 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
391 sal_Unicode b = '2';
392 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
393 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
396 OUString b("2");
397 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
398 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
401 css::uno::Type b(cppu::UnoType<OUString>::get());
402 CPPUNIT_ASSERT_MESSAGE(
403 "css::uno::Type",
404 !(a >>= b));
405 CPPUNIT_ASSERT_EQUAL_MESSAGE(
406 "css::uno::Type",
407 cppu::UnoType<OUString>::get(), b);
410 css::uno::Sequence< OUString > b(2);
411 CPPUNIT_ASSERT_MESSAGE(
412 "css::uno::Sequence<OUString>",
413 !(a >>= b));
414 CPPUNIT_ASSERT_EQUAL_MESSAGE(
415 "css::uno::Sequence<OUString>",
416 sal_Int32(2), b.getLength());
419 Enum1 b = Enum1_M2;
420 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
421 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
424 Struct1 b(2);
425 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
426 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
429 Exception1 b(
430 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
431 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
432 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
435 css::uno::Reference< Interface1 > i(new Impl1);
436 css::uno::Reference< Interface1 > b(i);
437 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
438 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
442 void Test::testByte() {
443 css::uno::Any a(static_cast< sal_Int8 >(1));
444 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<sal_Int8>::get()));
446 bool b = true;
447 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
448 CPPUNIT_ASSERT_MESSAGE("bool", b);
451 // [-loplugin:fakebool] false positive:
452 sal_Bool b = true;
453 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
454 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
457 sal_Int8 b = 2;
458 CPPUNIT_ASSERT_MESSAGE("sal_Int8", (a >>= b));
459 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(1), b);
462 sal_Int16 b = 2;
463 CPPUNIT_ASSERT_MESSAGE("sal_Int16", (a >>= b));
464 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(1), b);
467 sal_uInt16 b = 2;
468 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", (a >>= b));
469 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(1), b);
472 sal_Int32 b = 2;
473 CPPUNIT_ASSERT_MESSAGE("sal_Int32", (a >>= b));
474 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(1), b);
477 sal_uInt32 b = 2;
478 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", (a >>= b));
479 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(1), b);
482 sal_Int64 b = 2;
483 CPPUNIT_ASSERT_MESSAGE("sal_Int64", (a >>= b));
484 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(1), b);
487 sal_uInt64 b = 2;
488 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", (a >>= b));
489 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(1), b);
492 float b = 2;
493 CPPUNIT_ASSERT_MESSAGE("float", (a >>= b));
494 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(1), b);
497 double b = 2;
498 CPPUNIT_ASSERT_MESSAGE("double", (a >>= b));
499 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 1.0, b);
502 sal_Unicode b = '2';
503 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
504 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
507 OUString b("2");
508 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
509 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
512 css::uno::Type b(cppu::UnoType<OUString>::get());
513 CPPUNIT_ASSERT_MESSAGE(
514 "css::uno::Type",
515 !(a >>= b));
516 CPPUNIT_ASSERT_EQUAL_MESSAGE(
517 "css::uno::Type",
518 cppu::UnoType<OUString>::get(), b);
521 css::uno::Sequence< OUString > b(2);
522 CPPUNIT_ASSERT_MESSAGE(
523 "css::uno::Sequence<OUString>",
524 !(a >>= b));
525 CPPUNIT_ASSERT_EQUAL_MESSAGE(
526 "css::uno::Sequence<OUString>",
527 sal_Int32(2), b.getLength());
530 Enum1 b = Enum1_M2;
531 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
532 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
535 Struct1 b(2);
536 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
537 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
540 Exception1 b(
541 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
542 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
543 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
546 css::uno::Reference< Interface1 > i(new Impl1);
547 css::uno::Reference< Interface1 > b(i);
548 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
549 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
553 void Test::testShort() {
554 css::uno::Any a(static_cast< sal_Int16 >(1));
555 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<sal_Int16>::get()));
557 bool b = true;
558 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
559 CPPUNIT_ASSERT_MESSAGE("bool", b);
562 // [-loplugin:fakebool] false positive:
563 sal_Bool b = true;
564 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
565 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
568 sal_Int8 b = 2;
569 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
570 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
573 sal_Int16 b = 2;
574 CPPUNIT_ASSERT_MESSAGE("sal_Int16", (a >>= b));
575 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(1), b);
578 sal_uInt16 b = 2;
579 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", (a >>= b));
580 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(1), b);
583 sal_Int32 b = 2;
584 CPPUNIT_ASSERT_MESSAGE("sal_Int32", (a >>= b));
585 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(1), b);
588 sal_uInt32 b = 2;
589 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", (a >>= b));
590 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(1), b);
593 sal_Int64 b = 2;
594 CPPUNIT_ASSERT_MESSAGE("sal_Int64", (a >>= b));
595 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(1), b);
598 sal_uInt64 b = 2;
599 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", (a >>= b));
600 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(1), b);
603 float b = 2;
604 CPPUNIT_ASSERT_MESSAGE("float", (a >>= b));
605 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(1), b);
608 double b = 2;
609 CPPUNIT_ASSERT_MESSAGE("double", (a >>= b));
610 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 1.0, b);
613 sal_Unicode b = '2';
614 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
615 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
618 OUString b("2");
619 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
620 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
623 css::uno::Type b(cppu::UnoType<OUString>::get());
624 CPPUNIT_ASSERT_MESSAGE(
625 "css::uno::Type",
626 !(a >>= b));
627 CPPUNIT_ASSERT_EQUAL_MESSAGE(
628 "css::uno::Type",
629 cppu::UnoType<OUString>::get(), b);
632 css::uno::Sequence< OUString > b(2);
633 CPPUNIT_ASSERT_MESSAGE(
634 "css::uno::Sequence<OUString>",
635 !(a >>= b));
636 CPPUNIT_ASSERT_EQUAL_MESSAGE(
637 "css::uno::Sequence<OUString>",
638 sal_Int32(2), b.getLength());
641 Enum1 b = Enum1_M2;
642 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
643 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
646 Struct1 b(2);
647 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
648 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
651 Exception1 b(
652 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
653 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
654 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
657 css::uno::Reference< Interface1 > i(new Impl1);
658 css::uno::Reference< Interface1 > b(i);
659 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
660 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
664 void Test::testUnsignedShort() {
665 sal_uInt16 n = 1;
666 css::uno::Any a(&n, cppu::UnoType<cppu::UnoUnsignedShortType>::get());
667 CPPUNIT_ASSERT(
668 bool(a.getValueType() == cppu::UnoType<cppu::UnoUnsignedShortType>::get()));
670 bool b = true;
671 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
672 CPPUNIT_ASSERT_MESSAGE("bool", b);
675 // [-loplugin:fakebool] false positive:
676 sal_Bool b = true;
677 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
678 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
681 sal_Int8 b = 2;
682 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
683 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
686 sal_Int16 b = 2;
687 CPPUNIT_ASSERT_MESSAGE("sal_Int16", (a >>= b));
688 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(1), b);
691 sal_uInt16 b = 2;
692 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", (a >>= b));
693 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(1), b);
696 sal_Int32 b = 2;
697 CPPUNIT_ASSERT_MESSAGE("sal_Int32", (a >>= b));
698 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(1), b);
701 sal_uInt32 b = 2;
702 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", (a >>= b));
703 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(1), b);
706 sal_Int64 b = 2;
707 CPPUNIT_ASSERT_MESSAGE("sal_Int64", (a >>= b));
708 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(1), b);
711 sal_uInt64 b = 2;
712 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", (a >>= b));
713 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(1), b);
716 float b = 2;
717 CPPUNIT_ASSERT_MESSAGE("float", (a >>= b));
718 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(1), b);
721 double b = 2;
722 CPPUNIT_ASSERT_MESSAGE("double", (a >>= b));
723 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 1.0, b);
726 sal_Unicode b = '2';
727 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
728 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
731 OUString b("2");
732 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
733 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
736 css::uno::Type b(cppu::UnoType<OUString>::get());
737 CPPUNIT_ASSERT_MESSAGE(
738 "css::uno::Type",
739 !(a >>= b));
740 CPPUNIT_ASSERT_EQUAL_MESSAGE(
741 "css::uno::Type",
742 cppu::UnoType<OUString>::get(), b);
745 css::uno::Sequence< OUString > b(2);
746 CPPUNIT_ASSERT_MESSAGE(
747 "css::uno::Sequence<OUString>",
748 !(a >>= b));
749 CPPUNIT_ASSERT_EQUAL_MESSAGE(
750 "css::uno::Sequence<OUString>",
751 sal_Int32(2), b.getLength());
754 Enum1 b = Enum1_M2;
755 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
756 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
759 Struct1 b(2);
760 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
761 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
764 Exception1 b(
765 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
766 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
767 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
770 css::uno::Reference< Interface1 > i(new Impl1);
771 css::uno::Reference< Interface1 > b(i);
772 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
773 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
777 void Test::testLong() {
778 css::uno::Any a(static_cast< sal_Int32 >(1));
779 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<sal_Int32>::get()));
781 bool b = true;
782 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
783 CPPUNIT_ASSERT_MESSAGE("bool", b);
786 // [-loplugin:fakebool] false positive:
787 sal_Bool b = true;
788 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
789 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
792 sal_Int8 b = 2;
793 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
794 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
797 sal_Int16 b = 2;
798 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
799 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
802 sal_uInt16 b = 2;
803 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
804 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
807 sal_Int32 b = 2;
808 CPPUNIT_ASSERT_MESSAGE("sal_Int32", (a >>= b));
809 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(1), b);
812 sal_uInt32 b = 2;
813 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", (a >>= b));
814 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(1), b);
817 sal_Int64 b = 2;
818 CPPUNIT_ASSERT_MESSAGE("sal_Int64", (a >>= b));
819 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(1), b);
822 sal_uInt64 b = 2;
823 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", (a >>= b));
824 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(1), b);
827 float b = 2;
828 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
829 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
832 double b = 2;
833 CPPUNIT_ASSERT_MESSAGE("double", (a >>= b));
834 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 1.0, b);
837 sal_Unicode b = '2';
838 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
839 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
842 OUString b("2");
843 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
844 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
847 css::uno::Type b(cppu::UnoType<OUString>::get());
848 CPPUNIT_ASSERT_MESSAGE(
849 "css::uno::Type",
850 !(a >>= b));
851 CPPUNIT_ASSERT_EQUAL_MESSAGE(
852 "css::uno::Type",
853 cppu::UnoType<OUString>::get(), b);
856 css::uno::Sequence< OUString > b(2);
857 CPPUNIT_ASSERT_MESSAGE(
858 "css::uno::Sequence<OUString>",
859 !(a >>= b));
860 CPPUNIT_ASSERT_EQUAL_MESSAGE(
861 "css::uno::Sequence<OUString>",
862 sal_Int32(2), b.getLength());
865 Enum1 b = Enum1_M2;
866 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
867 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
870 Struct1 b(2);
871 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
872 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
875 Exception1 b(
876 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
877 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
878 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
881 css::uno::Reference< Interface1 > i(new Impl1);
882 css::uno::Reference< Interface1 > b(i);
883 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
884 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
888 void Test::testUnsignedLong() {
889 css::uno::Any a(static_cast< sal_uInt32 >(1));
890 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<sal_uInt32>::get()));
892 bool b = true;
893 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
894 CPPUNIT_ASSERT_MESSAGE("bool", b);
897 // [-loplugin:fakebool] false positive:
898 sal_Bool b = true;
899 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
900 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
903 sal_Int8 b = 2;
904 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
905 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
908 sal_Int16 b = 2;
909 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
910 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
913 sal_uInt16 b = 2;
914 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
915 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
918 sal_Int32 b = 2;
919 CPPUNIT_ASSERT_MESSAGE("sal_Int32", (a >>= b));
920 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(1), b);
923 sal_uInt32 b = 2;
924 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", (a >>= b));
925 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(1), b);
928 sal_Int64 b = 2;
929 CPPUNIT_ASSERT_MESSAGE("sal_Int64", (a >>= b));
930 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(1), b);
933 sal_uInt64 b = 2;
934 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", (a >>= b));
935 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(1), b);
938 float b = 2;
939 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
940 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
943 double b = 2;
944 CPPUNIT_ASSERT_MESSAGE("double", (a >>= b));
945 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 1.0, b);
948 sal_Unicode b = '2';
949 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
950 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
953 OUString b("2");
954 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
955 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
958 css::uno::Type b(cppu::UnoType<OUString>::get());
959 CPPUNIT_ASSERT_MESSAGE(
960 "css::uno::Type",
961 !(a >>= b));
962 CPPUNIT_ASSERT_EQUAL_MESSAGE(
963 "css::uno::Type",
964 cppu::UnoType<OUString>::get(), b);
967 css::uno::Sequence< OUString > b(2);
968 CPPUNIT_ASSERT_MESSAGE(
969 "css::uno::Sequence<OUString>",
970 !(a >>= b));
971 CPPUNIT_ASSERT_EQUAL_MESSAGE(
972 "css::uno::Sequence<OUString>",
973 sal_Int32(2), b.getLength());
976 Enum1 b = Enum1_M2;
977 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
978 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
981 Struct1 b(2);
982 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
983 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
986 Exception1 b(
987 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
988 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
989 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
992 css::uno::Reference< Interface1 > i(new Impl1);
993 css::uno::Reference< Interface1 > b(i);
994 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
995 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
999 void Test::testHyper() {
1000 css::uno::Any a(static_cast< sal_Int64 >(1));
1001 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<sal_Int64>::get()));
1003 bool b = true;
1004 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
1005 CPPUNIT_ASSERT_MESSAGE("bool", b);
1008 // [-loplugin:fakebool] false positive:
1009 sal_Bool b = true;
1010 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
1011 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
1014 sal_Int8 b = 2;
1015 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
1016 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
1019 sal_Int16 b = 2;
1020 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
1021 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
1024 sal_uInt16 b = 2;
1025 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
1026 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
1029 sal_Int32 b = 2;
1030 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
1031 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
1034 sal_uInt32 b = 2;
1035 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
1036 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
1039 sal_Int64 b = 2;
1040 CPPUNIT_ASSERT_MESSAGE("sal_Int64", (a >>= b));
1041 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(1), b);
1044 sal_uInt64 b = 2;
1045 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", (a >>= b));
1046 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(1), b);
1049 float b = 2;
1050 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
1051 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
1054 double b = 2;
1055 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
1056 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
1059 sal_Unicode b = '2';
1060 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
1061 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
1064 OUString b("2");
1065 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
1066 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
1069 css::uno::Type b(cppu::UnoType<OUString>::get());
1070 CPPUNIT_ASSERT_MESSAGE(
1071 "css::uno::Type",
1072 !(a >>= b));
1073 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1074 "css::uno::Type",
1075 cppu::UnoType<OUString>::get(), b);
1078 css::uno::Sequence< OUString > b(2);
1079 CPPUNIT_ASSERT_MESSAGE(
1080 "css::uno::Sequence<OUString>",
1081 !(a >>= b));
1082 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1083 "css::uno::Sequence<OUString>",
1084 sal_Int32(2), b.getLength());
1087 Enum1 b = Enum1_M2;
1088 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
1089 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
1092 Struct1 b(2);
1093 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
1094 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
1097 Exception1 b(
1098 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
1099 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
1100 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
1103 css::uno::Reference< Interface1 > i(new Impl1);
1104 css::uno::Reference< Interface1 > b(i);
1105 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
1106 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
1110 void Test::testUnsignedHyper() {
1111 css::uno::Any a(static_cast< sal_uInt64 >(1));
1112 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<sal_uInt64>::get()));
1114 bool b = true;
1115 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
1116 CPPUNIT_ASSERT_MESSAGE("bool", b);
1119 // [-loplugin:fakebool] false positive:
1120 sal_Bool b = true;
1121 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
1122 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
1125 sal_Int8 b = 2;
1126 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
1127 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
1130 sal_Int16 b = 2;
1131 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
1132 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
1135 sal_uInt16 b = 2;
1136 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
1137 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
1140 sal_Int32 b = 2;
1141 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
1142 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
1145 sal_uInt32 b = 2;
1146 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
1147 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
1150 sal_Int64 b = 2;
1151 CPPUNIT_ASSERT_MESSAGE("sal_Int64", (a >>= b));
1152 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(1), b);
1155 sal_uInt64 b = 2;
1156 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", (a >>= b));
1157 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(1), b);
1160 float b = 2;
1161 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
1162 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
1165 double b = 2;
1166 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
1167 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
1170 sal_Unicode b = '2';
1171 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
1172 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
1175 OUString b("2");
1176 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
1177 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
1180 css::uno::Type b(cppu::UnoType<OUString>::get());
1181 CPPUNIT_ASSERT_MESSAGE(
1182 "css::uno::Type",
1183 !(a >>= b));
1184 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1185 "css::uno::Type",
1186 cppu::UnoType<OUString>::get(), b);
1189 css::uno::Sequence< OUString > b(2);
1190 CPPUNIT_ASSERT_MESSAGE(
1191 "css::uno::Sequence<OUString>",
1192 !(a >>= b));
1193 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1194 "css::uno::Sequence<OUString>",
1195 sal_Int32(2), b.getLength());
1198 Enum1 b = Enum1_M2;
1199 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
1200 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
1203 Struct1 b(2);
1204 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
1205 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
1208 Exception1 b(
1209 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
1210 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
1211 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
1214 css::uno::Reference< Interface1 > i(new Impl1);
1215 css::uno::Reference< Interface1 > b(i);
1216 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
1217 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
1221 void Test::testFloat() {
1222 css::uno::Any a(1.f);
1223 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<float>::get()));
1225 bool b = true;
1226 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
1227 CPPUNIT_ASSERT_MESSAGE("bool", b);
1230 // [-loplugin:fakebool] false positive:
1231 sal_Bool b = true;
1232 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
1233 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
1236 sal_Int8 b = 2;
1237 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
1238 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
1241 sal_Int16 b = 2;
1242 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
1243 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
1246 sal_uInt16 b = 2;
1247 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
1248 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
1251 sal_Int32 b = 2;
1252 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
1253 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
1256 sal_uInt32 b = 2;
1257 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
1258 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
1261 sal_Int64 b = 2;
1262 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
1263 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
1266 sal_uInt64 b = 2;
1267 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
1268 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
1271 float b = 2;
1272 CPPUNIT_ASSERT_MESSAGE("float", (a >>= b));
1273 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(1), b);
1276 double b = 2;
1277 CPPUNIT_ASSERT_MESSAGE("double", (a >>= b));
1278 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 1.0, b);
1281 sal_Unicode b = '2';
1282 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
1283 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
1286 OUString b("2");
1287 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
1288 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
1291 css::uno::Type b(cppu::UnoType<OUString>::get());
1292 CPPUNIT_ASSERT_MESSAGE(
1293 "css::uno::Type",
1294 !(a >>= b));
1295 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1296 "css::uno::Type",
1297 cppu::UnoType<OUString>::get(), b);
1300 css::uno::Sequence< OUString > b(2);
1301 CPPUNIT_ASSERT_MESSAGE(
1302 "css::uno::Sequence<OUString>",
1303 !(a >>= b));
1304 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1305 "css::uno::Sequence<OUString>",
1306 sal_Int32(2), b.getLength());
1309 Enum1 b = Enum1_M2;
1310 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
1311 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
1314 Struct1 b(2);
1315 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
1316 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
1319 Exception1 b(
1320 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
1321 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
1322 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
1325 css::uno::Reference< Interface1 > i(new Impl1);
1326 css::uno::Reference< Interface1 > b(i);
1327 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
1328 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
1332 void Test::testDouble() {
1333 css::uno::Any a(1.);
1334 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<double>::get()));
1336 bool b = true;
1337 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
1338 CPPUNIT_ASSERT_MESSAGE("bool", b);
1341 // [-loplugin:fakebool] false positive:
1342 sal_Bool b = true;
1343 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
1344 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
1347 sal_Int8 b = 2;
1348 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
1349 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
1352 sal_Int16 b = 2;
1353 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
1354 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
1357 sal_uInt16 b = 2;
1358 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
1359 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
1362 sal_Int32 b = 2;
1363 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
1364 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
1367 sal_uInt32 b = 2;
1368 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
1369 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
1372 sal_Int64 b = 2;
1373 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
1374 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
1377 sal_uInt64 b = 2;
1378 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
1379 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
1382 float b = 2;
1383 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
1384 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
1387 double b = 2;
1388 CPPUNIT_ASSERT_MESSAGE("double", (a >>= b));
1389 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 1.0, b);
1392 sal_Unicode b = '2';
1393 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
1394 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
1397 OUString b("2");
1398 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
1399 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
1402 css::uno::Type b(cppu::UnoType<OUString>::get());
1403 CPPUNIT_ASSERT_MESSAGE(
1404 "css::uno::Type",
1405 !(a >>= b));
1406 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1407 "css::uno::Type",
1408 cppu::UnoType<OUString>::get(), b);
1411 css::uno::Sequence< OUString > b(2);
1412 CPPUNIT_ASSERT_MESSAGE(
1413 "css::uno::Sequence<OUString>",
1414 !(a >>= b));
1415 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1416 "css::uno::Sequence<OUString>",
1417 sal_Int32(2), b.getLength());
1420 Enum1 b = Enum1_M2;
1421 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
1422 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
1425 Struct1 b(2);
1426 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
1427 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
1430 Exception1 b(
1431 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
1432 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
1433 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
1436 css::uno::Reference< Interface1 > i(new Impl1);
1437 css::uno::Reference< Interface1 > b(i);
1438 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
1439 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
1443 void Test::testChar() {
1444 sal_Unicode c = '1';
1445 css::uno::Any a(&c, cppu::UnoType<cppu::UnoCharType>::get());
1446 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<cppu::UnoCharType>::get()));
1448 bool b = true;
1449 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
1450 CPPUNIT_ASSERT_MESSAGE("bool", b);
1453 // [-loplugin:fakebool] false positive:
1454 sal_Bool b = true;
1455 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
1456 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
1459 sal_Int8 b = 2;
1460 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
1461 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
1464 sal_Int16 b = 2;
1465 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
1466 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
1469 sal_uInt16 b = 2;
1470 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
1471 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
1474 sal_Int32 b = 2;
1475 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
1476 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
1479 sal_uInt32 b = 2;
1480 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
1481 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
1484 sal_Int64 b = 2;
1485 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
1486 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
1489 sal_uInt64 b = 2;
1490 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
1491 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
1494 float b = 2;
1495 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
1496 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
1499 double b = 2;
1500 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
1501 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
1504 sal_Unicode b = '2';
1505 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", (a >>= b));
1506 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'1', b);
1509 OUString b("2");
1510 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
1511 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
1514 css::uno::Type b(cppu::UnoType<OUString>::get());
1515 CPPUNIT_ASSERT_MESSAGE(
1516 "css::uno::Type",
1517 !(a >>= b));
1518 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1519 "css::uno::Type",
1520 cppu::UnoType<OUString>::get(), b);
1523 css::uno::Sequence< OUString > b(2);
1524 CPPUNIT_ASSERT_MESSAGE(
1525 "css::uno::Sequence<OUString>",
1526 !(a >>= b));
1527 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1528 "css::uno::Sequence<OUString>",
1529 sal_Int32(2), b.getLength());
1532 Enum1 b = Enum1_M2;
1533 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
1534 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
1537 Struct1 b(2);
1538 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
1539 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
1542 Exception1 b(
1543 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
1544 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
1545 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
1548 css::uno::Reference< Interface1 > i(new Impl1);
1549 css::uno::Reference< Interface1 > b(i);
1550 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
1551 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
1555 void Test::testString() {
1556 css::uno::Any a(OUString("1"));
1557 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<OUString>::get()));
1559 bool b = true;
1560 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
1561 CPPUNIT_ASSERT_MESSAGE("bool", b);
1564 // [-loplugin:fakebool] false positive:
1565 sal_Bool b = true;
1566 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
1567 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
1570 sal_Int8 b = 2;
1571 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
1572 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
1575 sal_Int16 b = 2;
1576 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
1577 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
1580 sal_uInt16 b = 2;
1581 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
1582 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
1585 sal_Int32 b = 2;
1586 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
1587 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
1590 sal_uInt32 b = 2;
1591 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
1592 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
1595 sal_Int64 b = 2;
1596 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
1597 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
1600 sal_uInt64 b = 2;
1601 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
1602 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
1605 float b = 2;
1606 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
1607 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
1610 double b = 2;
1611 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
1612 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
1615 sal_Unicode b = '2';
1616 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
1617 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
1620 OUString b("2");
1621 CPPUNIT_ASSERT_MESSAGE( "OUString", (a >>= b) );
1622 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("1"), b );
1625 css::uno::Type b(cppu::UnoType<OUString>::get());
1626 CPPUNIT_ASSERT_MESSAGE(
1627 "css::uno::Type",
1628 !(a >>= b));
1629 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1630 "css::uno::Type",
1631 cppu::UnoType<OUString>::get(), b);
1634 css::uno::Sequence< OUString > b(2);
1635 CPPUNIT_ASSERT_MESSAGE(
1636 "css::uno::Sequence<OUString>",
1637 !(a >>= b));
1638 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1639 "css::uno::Sequence<OUString>",
1640 sal_Int32(2), b.getLength());
1643 Enum1 b = Enum1_M2;
1644 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
1645 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
1648 Struct1 b(2);
1649 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
1650 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
1653 Exception1 b(
1654 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
1655 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
1656 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
1659 css::uno::Reference< Interface1 > i(new Impl1);
1660 css::uno::Reference< Interface1 > b(i);
1661 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
1662 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
1666 void Test::testType() {
1667 css::uno::Any a(cppu::UnoType<sal_Int32>::get());
1668 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<css::uno::Type>::get()));
1670 bool b = true;
1671 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
1672 CPPUNIT_ASSERT_MESSAGE("bool", b);
1675 // [-loplugin:fakebool] false positive:
1676 sal_Bool b = true;
1677 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
1678 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
1681 sal_Int8 b = 2;
1682 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
1683 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
1686 sal_Int16 b = 2;
1687 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
1688 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
1691 sal_uInt16 b = 2;
1692 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
1693 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
1696 sal_Int32 b = 2;
1697 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
1698 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
1701 sal_uInt32 b = 2;
1702 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
1703 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
1706 sal_Int64 b = 2;
1707 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
1708 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
1711 sal_uInt64 b = 2;
1712 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
1713 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
1716 float b = 2;
1717 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
1718 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
1721 double b = 2;
1722 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
1723 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
1726 sal_Unicode b = '2';
1727 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
1728 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
1731 OUString b("2");
1732 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
1733 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
1736 css::uno::Type b(cppu::UnoType<OUString>::get());
1737 CPPUNIT_ASSERT_MESSAGE(
1738 "css::uno::Type", (a >>= b));
1739 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1740 "css::uno::Type", cppu::UnoType<sal_Int32>::get(), b);
1743 css::uno::Sequence< OUString > b(2);
1744 CPPUNIT_ASSERT_MESSAGE(
1745 "css::uno::Sequence<OUString>",
1746 !(a >>= b));
1747 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1748 "css::uno::Sequence<OUString>",
1749 sal_Int32(2), b.getLength());
1752 Enum1 b = Enum1_M2;
1753 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
1754 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
1757 Struct1 b(2);
1758 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
1759 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
1762 Exception1 b(
1763 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
1764 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
1765 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
1768 css::uno::Reference< Interface1 > i(new Impl1);
1769 css::uno::Reference< Interface1 > b(i);
1770 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
1771 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
1775 void Test::testSequence() {
1776 sal_Int32 n = 1;
1777 css::uno::Any a(css::uno::Sequence< sal_Int32 >(&n, 1));
1778 CPPUNIT_ASSERT(
1779 bool(a.getValueType()
1780 == cppu::UnoType<css::uno::Sequence<sal_Int32>>::get()));
1782 bool b = true;
1783 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
1784 CPPUNIT_ASSERT_MESSAGE("bool", b);
1787 // [-loplugin:fakebool] false positive:
1788 sal_Bool b = true;
1789 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
1790 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
1793 sal_Int8 b = 2;
1794 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
1795 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
1798 sal_Int16 b = 2;
1799 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
1800 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
1803 sal_uInt16 b = 2;
1804 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
1805 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
1808 sal_Int32 b = 2;
1809 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
1810 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
1813 sal_uInt32 b = 2;
1814 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
1815 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
1818 sal_Int64 b = 2;
1819 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
1820 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
1823 sal_uInt64 b = 2;
1824 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
1825 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
1828 float b = 2;
1829 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
1830 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
1833 double b = 2;
1834 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
1835 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
1838 sal_Unicode b = '2';
1839 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
1840 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
1843 OUString b("2");
1844 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
1845 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
1848 css::uno::Type b(cppu::UnoType<OUString>::get());
1849 CPPUNIT_ASSERT_MESSAGE(
1850 "css::uno::Type",
1851 !(a >>= b));
1852 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1853 "css::uno::Type",
1854 cppu::UnoType<OUString>::get(), b);
1857 css::uno::Sequence< OUString > b(2);
1858 CPPUNIT_ASSERT_MESSAGE(
1859 "css::uno::Sequence<OUString>",
1860 !(a >>= b));
1861 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1862 "css::uno::Sequence<OUString>",
1863 sal_Int32(2), b.getLength());
1866 css::uno::Sequence< sal_Int32 > b(2);
1867 CPPUNIT_ASSERT_MESSAGE(
1868 "css::uno::Sequence<sal_Int32>",
1869 (a >>= b));
1870 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1871 "css::uno::Sequence<sal_Int32>",
1872 sal_Int32(1), b.getLength());
1873 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1874 "css::uno::Sequence<sal_Int32>",
1875 sal_Int32(1), b[0]);
1878 Enum1 b = Enum1_M2;
1879 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
1880 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
1883 Struct1 b(2);
1884 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
1885 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
1888 Exception1 b(
1889 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
1890 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
1891 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
1894 css::uno::Reference< Interface1 > i(new Impl1);
1895 css::uno::Reference< Interface1 > b(i);
1896 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
1897 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
1900 // The two default-constructed sequences both refer to the same static cppu::g_emptySeq
1901 css::uno::Sequence<sal_Int32> aEmptyIntSequence;
1902 css::uno::Sequence<OUString> aEmptyStringSequence;
1903 a <<= aEmptyStringSequence;
1904 CPPUNIT_ASSERT(!(a >>= aEmptyIntSequence));
1908 void Test::testEnum() {
1909 css::uno::Any a(Enum2_M1);
1910 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<Enum2>::get()));
1912 bool b = true;
1913 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
1914 CPPUNIT_ASSERT_MESSAGE("bool", b);
1917 // [-loplugin:fakebool] false positive:
1918 sal_Bool b = true;
1919 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
1920 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
1923 sal_Int8 b = 2;
1924 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
1925 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
1928 sal_Int16 b = 2;
1929 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
1930 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
1933 sal_uInt16 b = 2;
1934 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
1935 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
1938 sal_Int32 b = 2;
1939 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
1940 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
1943 sal_uInt32 b = 2;
1944 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
1945 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
1948 sal_Int64 b = 2;
1949 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
1950 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
1953 sal_uInt64 b = 2;
1954 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
1955 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
1958 float b = 2;
1959 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
1960 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
1963 double b = 2;
1964 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
1965 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
1968 sal_Unicode b = '2';
1969 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
1970 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
1973 OUString b("2");
1974 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
1975 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
1978 css::uno::Type b(cppu::UnoType<OUString>::get());
1979 CPPUNIT_ASSERT_MESSAGE(
1980 "css::uno::Type",
1981 !(a >>= b));
1982 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1983 "css::uno::Type",
1984 cppu::UnoType<OUString>::get(), b);
1987 css::uno::Sequence< OUString > b(2);
1988 CPPUNIT_ASSERT_MESSAGE(
1989 "css::uno::Sequence<OUString>",
1990 !(a >>= b));
1991 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1992 "css::uno::Sequence<OUString>",
1993 sal_Int32(2), b.getLength());
1996 Enum1 b = Enum1_M2;
1997 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
1998 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
2001 Enum2 b = Enum2_M2;
2002 CPPUNIT_ASSERT_MESSAGE("Enum2", (a >>= b));
2003 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum2", Enum2_M1, b);
2006 Struct1 b(2);
2007 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
2008 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
2011 Exception1 b(
2012 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
2013 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
2014 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
2017 css::uno::Reference< Interface1 > i(new Impl1);
2018 css::uno::Reference< Interface1 > b(i);
2019 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
2020 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
2024 void Test::testStruct() {
2025 css::uno::Any a(Struct2a(1, 3));
2026 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<Struct2a>::get()));
2028 bool b = true;
2029 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
2030 CPPUNIT_ASSERT_MESSAGE("bool", b);
2033 // [-loplugin:fakebool] false positive:
2034 sal_Bool b = true;
2035 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
2036 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
2039 sal_Int8 b = 2;
2040 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
2041 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
2044 sal_Int16 b = 2;
2045 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
2046 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
2049 sal_uInt16 b = 2;
2050 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
2051 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
2054 sal_Int32 b = 2;
2055 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
2056 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
2059 sal_uInt32 b = 2;
2060 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
2061 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
2064 sal_Int64 b = 2;
2065 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
2066 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
2069 sal_uInt64 b = 2;
2070 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
2071 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
2074 float b = 2;
2075 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
2076 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
2079 double b = 2;
2080 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
2081 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
2084 sal_Unicode b = '2';
2085 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
2086 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
2089 OUString b("2");
2090 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
2091 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
2094 css::uno::Type b(cppu::UnoType<OUString>::get());
2095 CPPUNIT_ASSERT_MESSAGE(
2096 "css::uno::Type",
2097 !(a >>= b));
2098 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2099 "css::uno::Type",
2100 cppu::UnoType<OUString>::get(), b);
2103 css::uno::Sequence< OUString > b(2);
2104 CPPUNIT_ASSERT_MESSAGE(
2105 "css::uno::Sequence<OUString>",
2106 !(a >>= b));
2107 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2108 "css::uno::Sequence<OUString>",
2109 sal_Int32(2), b.getLength());
2112 Enum1 b = Enum1_M2;
2113 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
2114 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
2117 Struct1 b(2);
2118 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
2119 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
2122 Struct2 b(2);
2123 CPPUNIT_ASSERT_MESSAGE("Struct2", (a >>= b));
2124 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct2", sal_Int32(1), b.member);
2127 Struct2a b(2, 2);
2128 CPPUNIT_ASSERT_MESSAGE(
2129 "Struct2a", (a >>= b));
2130 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2131 "Struct2a", sal_Int32(1), b.member);
2132 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2133 "Struct2a", sal_Int32(3), b.member2);
2136 Struct2b b(2, 2, 2);
2137 CPPUNIT_ASSERT_MESSAGE("Struct2b", !(a >>= b));
2138 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct2b", sal_Int32(2), b.member);
2141 Exception1 b(
2142 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
2143 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
2144 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
2147 css::uno::Reference< Interface1 > i(new Impl1);
2148 css::uno::Reference< Interface1 > b(i);
2149 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
2150 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
2154 void Test::testPoly() {
2155 css::uno::Any a;
2156 a <<= Poly< css::uno::Sequence< ::sal_Unicode > >();
2157 CPPUNIT_ASSERT_EQUAL_MESSAGE( "type name", OUString("Poly<[]char>"), a.getValueType().getTypeName() );
2158 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2159 "constructor",
2160 css::uno::Any(Poly< css::uno::Sequence< ::sal_Unicode > >()), a);
2163 void Test::testException() {
2164 css::uno::Any a(
2165 Exception2a(
2166 OUString(), css::uno::Reference< css::uno::XInterface >(), 1,
2167 3));
2168 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<Exception2a>::get()));
2170 bool b = true;
2171 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
2172 CPPUNIT_ASSERT_MESSAGE("bool", b);
2175 // [-loplugin:fakebool] false positive:
2176 sal_Bool b = true;
2177 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
2178 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
2181 sal_Int8 b = 2;
2182 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
2183 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
2186 sal_Int16 b = 2;
2187 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
2188 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
2191 sal_uInt16 b = 2;
2192 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
2193 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
2196 sal_Int32 b = 2;
2197 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
2198 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
2201 sal_uInt32 b = 2;
2202 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
2203 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
2206 sal_Int64 b = 2;
2207 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
2208 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
2211 sal_uInt64 b = 2;
2212 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
2213 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
2216 float b = 2;
2217 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
2218 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
2221 double b = 2;
2222 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
2223 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
2226 sal_Unicode b = '2';
2227 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
2228 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
2231 OUString b("2");
2232 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
2233 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
2236 css::uno::Type b(cppu::UnoType<OUString>::get());
2237 CPPUNIT_ASSERT_MESSAGE(
2238 "css::uno::Type",
2239 !(a >>= b));
2240 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2241 "css::uno::Type",
2242 cppu::UnoType<OUString>::get(), b);
2245 css::uno::Sequence< OUString > b(2);
2246 CPPUNIT_ASSERT_MESSAGE(
2247 "css::uno::Sequence<OUString>",
2248 !(a >>= b));
2249 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2250 "css::uno::Sequence<OUString>",
2251 sal_Int32(2), b.getLength());
2254 Enum1 b = Enum1_M2;
2255 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
2256 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
2259 Struct1 b(2);
2260 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
2261 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
2264 Exception1 b(
2265 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
2266 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
2267 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
2270 Exception2 b(
2271 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
2272 CPPUNIT_ASSERT_MESSAGE("Exception2", (a >>= b));
2273 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception2", sal_Int32(1), b.member);
2276 Exception2a b(
2277 OUString(), css::uno::Reference< css::uno::XInterface >(), 2,
2279 CPPUNIT_ASSERT_MESSAGE(
2280 "Exception2a", (a >>= b));
2281 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2282 "Exception2a", sal_Int32(1), b.member);
2283 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2284 "Exception2a", sal_Int32(3), b.member2);
2287 Exception2b b(
2288 OUString(), css::uno::Reference< css::uno::XInterface >(), 2,
2290 CPPUNIT_ASSERT_MESSAGE("Exception2b", !(a >>= b));
2291 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception2b", sal_Int32(2), b.member);
2294 css::uno::Reference< Interface1 > i(new Impl1);
2295 css::uno::Reference< Interface1 > b(i);
2296 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
2297 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
2301 void Test::testInterface() {
2302 css::uno::Reference< Interface2a > i2(new Impl2);
2303 css::uno::Any a(i2);
2304 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<Interface2a>::get()));
2306 bool b = true;
2307 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
2308 CPPUNIT_ASSERT_MESSAGE("bool", b);
2311 // [-loplugin:fakebool] false positive:
2312 sal_Bool b = true;
2313 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
2314 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
2317 sal_Int8 b = 2;
2318 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
2319 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
2322 sal_Int16 b = 2;
2323 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
2324 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
2327 sal_uInt16 b = 2;
2328 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
2329 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
2332 sal_Int32 b = 2;
2333 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
2334 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
2337 sal_uInt32 b = 2;
2338 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
2339 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
2342 sal_Int64 b = 2;
2343 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
2344 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
2347 sal_uInt64 b = 2;
2348 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
2349 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
2352 float b = 2;
2353 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
2354 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
2357 double b = 2;
2358 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
2359 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
2362 sal_Unicode b = '2';
2363 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
2364 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
2367 OUString b("2");
2368 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
2369 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
2372 css::uno::Type b(cppu::UnoType<OUString>::get());
2373 CPPUNIT_ASSERT_MESSAGE(
2374 "css::uno::Type",
2375 !(a >>= b));
2376 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2377 "css::uno::Type",
2378 cppu::UnoType<OUString>::get(), b);
2381 css::uno::Sequence< OUString > b(2);
2382 CPPUNIT_ASSERT_MESSAGE(
2383 "css::uno::Sequence<OUString>",
2384 !(a >>= b));
2385 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2386 "css::uno::Sequence<OUString>",
2387 sal_Int32(2), b.getLength());
2390 Enum1 b = Enum1_M2;
2391 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
2392 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
2395 Struct1 b(2);
2396 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
2397 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
2400 Exception1 b(
2401 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
2402 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
2403 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
2406 css::uno::Reference< Interface1 > i(new Impl1);
2407 css::uno::Reference< Interface1 > b(i);
2408 CPPUNIT_ASSERT_MESSAGE("Interface1", !(a >>= b));
2409 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface1", i, b);
2412 css::uno::Reference< Interface2 > b(new Impl2);
2413 CPPUNIT_ASSERT_MESSAGE("Interface2", (a >>= b));
2414 CPPUNIT_ASSERT_MESSAGE("Interface2", b.operator ==(i2));
2417 css::uno::Reference< Interface2a > b(new Impl2);
2418 CPPUNIT_ASSERT_MESSAGE("Interface2a", (a >>= b));
2419 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface2a", i2, b);
2422 css::uno::Reference< Interface2b > i(new Impl2b);
2423 css::uno::Reference< Interface2b > b(i);
2424 CPPUNIT_ASSERT_MESSAGE("Interface2b", !(a >>= b));
2425 CPPUNIT_ASSERT_EQUAL_MESSAGE("Interface2b", i, b);
2428 css::uno::Reference< Interface3 > b(new Impl2);
2429 CPPUNIT_ASSERT_MESSAGE("Interface3", (a >>= b));
2430 CPPUNIT_ASSERT_MESSAGE("Interface3", b.operator ==(i2));
2434 void Test::testNull() {
2435 css::uno::Any a { css::uno::Reference< Interface2a >() };
2436 CPPUNIT_ASSERT(bool(a.getValueType() == cppu::UnoType<Interface2a>::get()));
2438 bool b = true;
2439 CPPUNIT_ASSERT_MESSAGE("bool", !(a >>= b));
2440 CPPUNIT_ASSERT_MESSAGE("bool", b);
2443 // [-loplugin:fakebool] false positive:
2444 sal_Bool b = true;
2445 CPPUNIT_ASSERT_MESSAGE("sal_Bool", !(a >>= b));
2446 CPPUNIT_ASSERT_MESSAGE("sal_Bool", b);
2449 sal_Int8 b = 2;
2450 CPPUNIT_ASSERT_MESSAGE("sal_Int8", !(a >>= b));
2451 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8", sal_Int8(2), b);
2454 sal_Int16 b = 2;
2455 CPPUNIT_ASSERT_MESSAGE("sal_Int16", !(a >>= b));
2456 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16", sal_Int16(2), b);
2459 sal_uInt16 b = 2;
2460 CPPUNIT_ASSERT_MESSAGE("sal_uInt16", !(a >>= b));
2461 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16", sal_uInt16(2), b);
2464 sal_Int32 b = 2;
2465 CPPUNIT_ASSERT_MESSAGE("sal_Int32", !(a >>= b));
2466 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32", sal_Int32(2), b);
2469 sal_uInt32 b = 2;
2470 CPPUNIT_ASSERT_MESSAGE("sal_uInt32", !(a >>= b));
2471 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32", sal_uInt32(2), b);
2474 sal_Int64 b = 2;
2475 CPPUNIT_ASSERT_MESSAGE("sal_Int64", !(a >>= b));
2476 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64", sal_Int64(2), b);
2479 sal_uInt64 b = 2;
2480 CPPUNIT_ASSERT_MESSAGE("sal_uInt64", !(a >>= b));
2481 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64", sal_uInt64(2), b);
2484 float b = 2;
2485 CPPUNIT_ASSERT_MESSAGE("float", !(a >>= b));
2486 CPPUNIT_ASSERT_EQUAL_MESSAGE("float", float(2), b);
2489 double b = 2;
2490 CPPUNIT_ASSERT_MESSAGE("double", !(a >>= b));
2491 CPPUNIT_ASSERT_EQUAL_MESSAGE("double", 2.0, b);
2494 sal_Unicode b = '2';
2495 CPPUNIT_ASSERT_MESSAGE("sal_Unicode", !(a >>= b));
2496 CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Unicode", u'2', b);
2499 OUString b("2");
2500 CPPUNIT_ASSERT_MESSAGE( "OUString", !(a >>= b) );
2501 CPPUNIT_ASSERT_EQUAL_MESSAGE( "OUString", OUString("2"), b );
2504 css::uno::Type b(cppu::UnoType<OUString>::get());
2505 CPPUNIT_ASSERT_MESSAGE(
2506 "css::uno::Type",
2507 !(a >>= b));
2508 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2509 "css::uno::Type",
2510 cppu::UnoType<OUString>::get(), b);
2513 css::uno::Sequence< OUString > b(2);
2514 CPPUNIT_ASSERT_MESSAGE(
2515 "css::uno::Sequence<OUString>",
2516 !(a >>= b));
2517 CPPUNIT_ASSERT_EQUAL_MESSAGE(
2518 "css::uno::Sequence<OUString>",
2519 sal_Int32(2), b.getLength());
2522 Enum1 b = Enum1_M2;
2523 CPPUNIT_ASSERT_MESSAGE("Enum1", !(a >>= b));
2524 CPPUNIT_ASSERT_EQUAL_MESSAGE("Enum1", Enum1_M2, b);
2527 Struct1 b(2);
2528 CPPUNIT_ASSERT_MESSAGE("Struct1", !(a >>= b));
2529 CPPUNIT_ASSERT_EQUAL_MESSAGE("Struct1", sal_Int32(2), b.member);
2532 Exception1 b(
2533 OUString(), css::uno::Reference< css::uno::XInterface >(), 2);
2534 CPPUNIT_ASSERT_MESSAGE("Exception1", !(a >>= b));
2535 CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception1", sal_Int32(2), b.member);
2538 css::uno::Reference< Interface1 > b(new Impl1);
2539 CPPUNIT_ASSERT_MESSAGE(
2540 "Interface1", (a >>= b));
2541 CPPUNIT_ASSERT_MESSAGE(
2542 "Interface1", !b.is());
2545 css::uno::Reference< Interface2 > b(new Impl2);
2546 CPPUNIT_ASSERT_MESSAGE(
2547 "Interface2", (a >>= b));
2548 CPPUNIT_ASSERT_MESSAGE(
2549 "Interface2", !b.is());
2552 css::uno::Reference< Interface2a > b(new Impl2);
2553 CPPUNIT_ASSERT_MESSAGE("Interface2a", (a >>= b));
2554 CPPUNIT_ASSERT_MESSAGE("Interface2a", !b.is());
2557 css::uno::Reference< Interface2b > b(new Impl2b);
2558 CPPUNIT_ASSERT_MESSAGE(
2559 "Interface2b", (a >>= b));
2560 CPPUNIT_ASSERT_MESSAGE(
2561 "Interface2b", !b.is());
2564 css::uno::Reference< Interface3 > b(new Impl2);
2565 CPPUNIT_ASSERT_MESSAGE(
2566 "Interface3", (a >>= b));
2567 CPPUNIT_ASSERT_MESSAGE(
2568 "Interface3", !b.is());
2572 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
2576 CPPUNIT_PLUGIN_IMPLEMENT();
2578 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */