From bd614b91352b5a0a291f33a428c95d7bcbf34679 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 18 Oct 2016 18:14:14 +0200 Subject: Delete the "Any-to-Any" template specializations for LIBO_INTERNAL_ONLY i.e., css::uno::Any function template specializations Any::has() const Any::get(Any const &) const operator >>=(Any const &, Any &) operator <<=(Any &, Any const &) that don't make much sense (the first is always true, the rest can be replaced with operator =, which additionally supports move semantics). For 3rd-party compatibility, do this only for LIBO_INTERNAL_ONLY, however. However, some generic template code did benefit from operator >>= working also for Any, so make up for that with a new (LIBO_INTERNAL_ONLY, given that operator >>= still covers if fine for !LIBO_INTERNAL_ONLY) fromAny, complementing the existing toAny. Change-Id: I8b1b5f803f0b909808159916366d53c948206a88 Reviewed-on: https://gerrit.libreoffice.org/30022 Reviewed-by: Stephan Bergmann Tested-by: Stephan Bergmann --- cppu/qa/any-external.cxx | 63 ++++++++++++++++++++++++++++++++++++++ cppu/qa/test_any.cxx | 80 ------------------------------------------------ 2 files changed, 63 insertions(+), 80 deletions(-) create mode 100644 cppu/qa/any-external.cxx (limited to 'cppu/qa') diff --git a/cppu/qa/any-external.cxx b/cppu/qa/any-external.cxx new file mode 100644 index 000000000000..bac61342786c --- /dev/null +++ b/cppu/qa/any-external.cxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include +#include +#include + +#include +#include + +namespace { + +class Test: public CppUnit::TestFixture { +private: + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testGet); + CPPUNIT_TEST(testHas); + CPPUNIT_TEST(testExtract); + CPPUNIT_TEST(testInsert); + CPPUNIT_TEST_SUITE_END(); + + void testGet() { + css::uno::Any a(false); + CPPUNIT_ASSERT_EQUAL(a, a.get()); + CPPUNIT_ASSERT_EQUAL(false, a.get()); + } + + void testHas() { + css::uno::Any a(false); + CPPUNIT_ASSERT_EQUAL(true, a.has()); + CPPUNIT_ASSERT_EQUAL(true, a.has()); + } + + void testExtract() { + css::uno::Any a1(false); + css::uno::Any a2; + CPPUNIT_ASSERT(a1 >>= a2); + CPPUNIT_ASSERT_EQUAL(a1, a2); + } + + void testInsert() { + css::uno::Any a; + a <<= css::uno::Any(false); + CPPUNIT_ASSERT_EQUAL(css::uno::Any(false), a); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/cppu/qa/test_any.cxx b/cppu/qa/test_any.cxx index 5959974b0c6e..b6b69eaf9e6b 100644 --- a/cppu/qa/test_any.cxx +++ b/cppu/qa/test_any.cxx @@ -286,10 +286,6 @@ void Test::testVoid() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -376,10 +372,6 @@ void Test::testBoolean() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -471,10 +463,6 @@ void Test::testByte() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -566,10 +554,6 @@ void Test::testShort() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -663,10 +647,6 @@ void Test::testUnsignedShort() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -754,10 +734,6 @@ void Test::testLong() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -845,10 +821,6 @@ void Test::testUnsignedLong() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -936,10 +908,6 @@ void Test::testHyper() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -1027,10 +995,6 @@ void Test::testUnsignedHyper() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -1118,10 +1082,6 @@ void Test::testFloat() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -1209,10 +1169,6 @@ void Test::testDouble() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -1305,10 +1261,6 @@ void Test::testChar() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -1396,10 +1348,6 @@ void Test::testString() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -1486,10 +1434,6 @@ void Test::testType() { CPPUNIT_ASSERT_MESSAGE( "css::uno::Type", (a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -1580,10 +1524,6 @@ void Test::testSequence() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -1677,10 +1617,6 @@ void Test::testEnum() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -1772,10 +1708,6 @@ void Test::testStruct() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -1888,10 +1820,6 @@ void Test::testException() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -1998,10 +1926,6 @@ void Test::testInterface() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( @@ -2106,10 +2030,6 @@ void Test::testNull() { "css::uno::Type", !(a >>= b) && b == cppu::UnoType::get()); } - { - css::uno::Any b(rtl::OUString("2")); - CPPUNIT_ASSERT_MESSAGE("css::uno::Any", (a >>= b) && b == a); - } { css::uno::Sequence< rtl::OUString > b(2); CPPUNIT_ASSERT_MESSAGE( -- cgit