Skip to content

Commit

Permalink
Merge pull request #219 from jwillemsen/jwi-extenduniontest2
Browse files Browse the repository at this point in the history
Extend TAOX11 union test
  • Loading branch information
jwillemsen authored May 18, 2022
2 parents 8cc129e + 2950bf3 commit bab359f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tests/union/foo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Foo::Foo (IDL::traits<CORBA::ORB>::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;

Expand Down
2 changes: 1 addition & 1 deletion tests/union/foo.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Foo final

void shutdown () override;

uint16_t get_error_count ();
uint16_t get_error_count () const;

private:
IDL::traits<CORBA::ORB>::ref_type orb_;
Expand Down
44 changes: 42 additions & 2 deletions tests/union/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ main(int argc, ACE_TCHAR *argv[])
{
IDL::traits<CORBA::ORB>::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;
Expand Down Expand Up @@ -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 <ior_output_file>
std::ofstream fos("test.ior");
Expand All @@ -97,6 +97,46 @@ 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, 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())
{
TAOX11_TEST_ERROR << "u1_2._d() != u1_3._d()" << std::endl;
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 ();
Expand Down

0 comments on commit bab359f

Please sign in to comment.