From 14f5e1959c45b41a307a3a21aa7ef69b9e1bec3e Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Tue, 17 May 2022 14:57:51 +0200 Subject: [PATCH 1/2] Extend test code for TestUnion_U1 * tests/union/server.cpp: --- tests/union/server.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/union/server.cpp b/tests/union/server.cpp index ab95e605..b0ebafb3 100644 --- a/tests/union/server.cpp +++ b/tests/union/server.cpp @@ -97,6 +97,31 @@ main(int argc, ACE_TCHAR *argv[]) TAOX11_TEST_DEBUG << "event loop finished" << std::endl; + // Testing the TestUnion_U1 type + Test::TestUnion_U1 u1_1; + Test::TestUnion_U1 u1_2 (u1_1); // make a copy + // Validate that u1_1 and u1_2 are the same + if (u1_1._d() != u1_2._d()) + { + TAOX11_TEST_ERROR << "u1_1._d() != u1_2._d()" << std::endl; + return 1; + } + Test::TestUnion_U1 u1_3 (std::move(u1_1)); // do a move, u1_1 is now nil + // Validate that u1_2 and u1_3 are the same + if (u1_2._d() != u1_3._d()) + { + TAOX11_TEST_ERROR << "u1_2._d() != u1_3._d()" << std::endl; + return 1; + } + // Swap the content of u1_2 and u1_3, currently triggers a warning + u1_2.swap (u1_3); + // Validate that u1_2 and u1_3 are the same + if (u1_2._d() != u1_3._d()) + { + TAOX11_TEST_ERROR << "u1_2._d() != u1_3._d()" << std::endl; + return 1; + } + root_poa->destroy (true, true); _orb->destroy (); From 2950bf382835448ac283296ba49937cf98707462 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 18 May 2022 13:38:04 +0200 Subject: [PATCH 2/2] Extend union test with Any usage * tests/union/foo.cpp: * tests/union/foo.h: * tests/union/server.cpp: --- tests/union/foo.cpp | 4 ++-- tests/union/foo.h | 2 +- tests/union/server.cpp | 21 ++++++++++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/tests/union/foo.cpp b/tests/union/foo.cpp index c78f0ead..4a7fd6de 100644 --- a/tests/union/foo.cpp +++ b/tests/union/foo.cpp @@ -15,13 +15,13 @@ Foo::Foo (IDL::traits::ref_type orb) } uint16_t -Foo::get_error_count() +Foo::get_error_count() const { return errors_; } bool -Foo::pass_union (const Test::Data & s) +Foo::pass_union (const Test::Data& s) { this->s_ = s; diff --git a/tests/union/foo.h b/tests/union/foo.h index 58670d05..9c3bf8bd 100644 --- a/tests/union/foo.h +++ b/tests/union/foo.h @@ -36,7 +36,7 @@ class Foo final void shutdown () override; - uint16_t get_error_count (); + uint16_t get_error_count () const; private: IDL::traits::ref_type orb_; diff --git a/tests/union/server.cpp b/tests/union/server.cpp index b0ebafb3..7a54c809 100644 --- a/tests/union/server.cpp +++ b/tests/union/server.cpp @@ -17,7 +17,7 @@ main(int argc, ACE_TCHAR *argv[]) { IDL::traits::ref_type _orb = CORBA::ORB_init (argc, argv); - if (_orb == nullptr) + if (!_orb) { TAOX11_TEST_ERROR << "ERROR: CORBA::ORB_init (argc, argv) returned null ORB." << std::endl; return 1; @@ -75,7 +75,7 @@ main(int argc, ACE_TCHAR *argv[]) return 1; } - std::string ior = _orb->object_to_string (hello); + std::string const ior = _orb->object_to_string (hello); // Output the IOR to the std::ofstream fos("test.ior"); @@ -113,7 +113,8 @@ main(int argc, ACE_TCHAR *argv[]) TAOX11_TEST_ERROR << "u1_2._d() != u1_3._d()" << std::endl; return 1; } - // Swap the content of u1_2 and u1_3, currently triggers a warning + // Swap the content of u1_2 and u1_3, some gcc compilers give an invalid warning + // here u1_2.swap (u1_3); // Validate that u1_2 and u1_3 are the same if (u1_2._d() != u1_3._d()) @@ -122,6 +123,20 @@ main(int argc, ACE_TCHAR *argv[]) return 1; } + // Testing the TestUnion_U2 type + Test::TestUnion_U2 u2_1; + Test::TestUnion_U2 u2_2 (u2_1); // make a copy + // Swap the content of u1_1 and u2_2, commenting this swap operation + // will trigger the warnings given by some gcc versions above. Also + // commenting out the call `CORBA::ORB_init (argc, argv)` will remove + // the warning given by some gcc compilers on the swap above + u2_1.swap (u2_2); + // Validate that u1_2 and u2_2 are the same + if (u2_1._d() != u2_2._d()) + { + TAOX11_TEST_ERROR << "u2_1._d() != u2_2._d()" << std::endl; + return 1; + } root_poa->destroy (true, true); _orb->destroy ();