diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-05-07 10:14:01 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-05-07 10:14:01 +0200 |
commit | e67b072c8e7a2b6d2c9afcf72882083255ef5966 (patch) | |
tree | 116427d60cb5984f8ca097f8349da79dd6f1cd26 /cppu | |
parent | 904b3d1fceee5827076758ed2a81f80cb73493ca (diff) |
Avoid warnings about unused test functions
Change-Id: I6b2a40c4b95555c4d8bf0d8674fce46accd49965
Diffstat (limited to 'cppu')
-rw-r--r-- | cppu/qa/test_reference.cxx | 92 |
1 files changed, 49 insertions, 43 deletions
diff --git a/cppu/qa/test_reference.cxx b/cppu/qa/test_reference.cxx index a6e393692043..ab3bac5f6745 100644 --- a/cppu/qa/test_reference.cxx +++ b/cppu/qa/test_reference.cxx @@ -89,14 +89,55 @@ private: oslInterlockedCount m_refCount; }; +// Check that the up-casting Reference conversion constructor catches the +// intended cases: + +struct Base1: public css::uno::XInterface { virtual ~Base1() {} }; +struct Base2: public Base1 { virtual ~Base2() {} }; +struct Base3: public Base1 { virtual ~Base3() {} }; +struct Derived: public Base2, public Base3 { virtual ~Derived() {} }; + +// The special case using the conversion operator instead: +css::uno::Reference< css::uno::XInterface > testUpcast1( + css::uno::Reference< Derived > const & ref) +{ return ref; } + +// The normal up-cast case: +css::uno::Reference< Base1 > testUpcast2( + css::uno::Reference< Base2 > const & ref) +{ return ref; } + +// Commenting this in should cause a compiler error due to an ambiguous up-cast: +/* +css::uno::Reference< Base1 > testFailingUpcast3( + css::uno::Reference< Derived > const & ref) +{ return ref; } +*/ + +// Commenting this in should cause a compiler error due to a down-cast: +/* +css::uno::Reference< Base2 > testFailingUpcast4( + css::uno::Reference< Base1 > const & ref) +{ return ref; } +*/ + +// Commenting this in should cause a compiler error due to a down-cast: +/* +css::uno::Reference< Base1 > testFailingUpcast5( + css::uno::Reference< css::uno::XInterface > const & ref) +{ return ref; } +*/ + class Test: public ::CppUnit::TestFixture { public: void testUnoSetThrow(); + void testUpcastCompilation(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testUnoSetThrow); + CPPUNIT_TEST(testUpcastCompilation); CPPUNIT_TEST_SUITE_END(); }; @@ -143,53 +184,18 @@ void Test::testUnoSetThrow() CPPUNIT_ASSERT_EQUAL( false, bCaughtException ); } +// Include a dummy test calling those functions, to avoid warnings about those +// functions being unused: +void Test::testUpcastCompilation() +{ + testUpcast1(css::uno::Reference< Derived >()); + testUpcast2(css::uno::Reference< Base2 >()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } // namespace CPPUNIT_PLUGIN_IMPLEMENT(); -// Check that the up-casting Reference conversion constructor catches the -// intended cases: - -namespace { - -struct Base1: public css::uno::XInterface { virtual ~Base1() {} }; -struct Base2: public Base1 { virtual ~Base2() {} }; -struct Base3: public Base1 { virtual ~Base3() {} }; -struct Derived: public Base2, public Base3 { virtual ~Derived() {} }; - -} - -// The special case using the conversion operator instead: -css::uno::Reference< css::uno::XInterface > testUpcast1( - css::uno::Reference< Derived > const & ref) -{ return ref; } - -// The normal up-cast case: -css::uno::Reference< Base1 > testUpcast2( - css::uno::Reference< Base2 > const & ref) -{ return ref; } - -// Commenting this in should cause a compiler error due to an ambiguous up-cast: -/* -css::uno::Reference< Base1 > testFailingUpcast3( - css::uno::Reference< Derived > const & ref) -{ return ref; } -*/ - -// Commenting this in should cause a compiler error due to a down-cast: -/* -css::uno::Reference< Base2 > testFailingUpcast4( - css::uno::Reference< Base1 > const & ref) -{ return ref; } -*/ - -// Commenting this in should cause a compiler error due to a down-cast: -/* -css::uno::Reference< Base1 > testFailingUpcast5( - css::uno::Reference< css::uno::XInterface > const & ref) -{ return ref; } -*/ - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |