Skip to content

Commit

Permalink
Merge pull request #397 from jwillemsen/jwi-defaultliteraltest
Browse files Browse the repository at this point in the history
Add default_literal test
  • Loading branch information
jwillemsen committed Sep 4, 2024
2 parents 1e98f67 + 6f76375 commit c0945bd
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/taox11_tests.lst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ tests/idl4/bitset/run_illegal_idl3_test.pl:
tests/idl4/bitmask/run_test.pl:
tests/idl4/bitmask/run_illegal_idl3_test.pl:
tests/idl4/default/run_test.pl:
tests/idl4/default_literal/run_test.pl:
tests/idl4/enum/run_test.pl:
tests/idl4/explicit_ints/run_test.pl:
tests/idl4/explicit_ints/run_illegal_idl3_test.pl:
Expand Down
45 changes: 45 additions & 0 deletions tests/idl4/default_literal/client.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @file client.cpp
* @author Johnny Willemsen
*
* @brief CORBA C++11 client application
*
* @copyright Copyright (c) Remedy IT Expertise BV
*/

#include "testC.h"
#include "testlib/taox11_testlog.h"

int main (int /*argc*/, char* /*argv*/[])
{
int retval {};
Shape shape;
shape.color_seq().resize(5);

TAOX11_TEST_INFO << "shape: " << shape << std::endl;

if (shape.color_red() != Color::RED)
{
TAOX11_TEST_ERROR << "shape.color_red() not RED but: " << shape.color_red() << std::endl;
++retval;
}
for (const auto& arrayi : shape.color_red_array())
{
if (arrayi != Color::RED)
{
TAOX11_TEST_ERROR << "shape.color_red_array() not RED but: " << arrayi << std::endl;
++retval;
}
}
for (size_t i = 0; i < shape.color_seq().size(); ++i)
{
if (shape.color_seq()[i] != Color::RED)
{
// Not supported, see D4982
// TAOX11_TEST_ERROR << "shape.color_seq()[" << i << "] not RED but: " << shape.color_seq()[i] << std::endl;
// ++retval;
}
}

return retval;
}
31 changes: 31 additions & 0 deletions tests/idl4/default_literal/run_test.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#---------------------------------------------------------------------
# @file run_test.pl
# @author Marcel Smit
#
# @copyright Copyright (c) Remedy IT Expertise BV
#---------------------------------------------------------------------
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;

# -*- perl -*-

use lib "$ENV{ACE_ROOT}/bin";
use PerlACE::TestTarget;

my $target = PerlACE::TestTarget::create_target(2) || die "Create target 2 failed\n";

$status = 0;

$SV = $target->CreateProcess ("client");

$server = $SV->SpawnWaitKill ($target->ProcessStartWaitInterval());

if ($server != 0) {
print STDERR "ERROR: client returned $server\n";
$status = 1;
}

$target->GetStderrLog();

exit $status;
21 changes: 21 additions & 0 deletions tests/idl4/default_literal/test.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @file test.idl
* @author Johnny Willemsen
*
* @copyright Copyright (c) Remedy IT Expertise BV
*/

enum Color {
GREEN,
@default_literal RED,
BLUE
};

typedef Color ColorArray[5];
typedef sequence<Color> ColorSeq;

struct Shape {
Color color_red;
ColorArray color_red_array;
ColorSeq color_seq;
};
20 changes: 20 additions & 0 deletions tests/idl4/default_literal/test.mpc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// -*- MPC -*-

project(*defaultliteral_gen_idl): ridl_ostream_defaults {
IDL_Files {
test.idl
idlflags += --idl-version=4
}
custom_only = 1
}

project(*defaultliteral_client): taox11_client {
after += *defaultliteral_gen_idl
Source_Files {
client.cpp
}
Source_Files {
testC.cpp
}
}

0 comments on commit c0945bd

Please sign in to comment.