2 //=============================================================================
4 * @file bd_struct_seq.cpp
6 * tests bounded struct sequences
8 * @author Aniruddha Gokhale
10 //=============================================================================
14 #include "bd_struct_seq.h"
16 const CORBA::ULong MAX_STRUCTSEQ_LEN
= 1;
18 // ************************************************************************
19 // Test_Bounded_Struct_Sequence
20 // ************************************************************************
22 Test_Bounded_Struct_Sequence::Test_Bounded_Struct_Sequence ()
23 : opname_ (CORBA::string_dup ("test_bounded_struct_sequence")),
24 inout_ (new Param_Test::Bounded_StructSeq
),
25 out_ (new Param_Test::Bounded_StructSeq
),
26 ret_ (new Param_Test::Bounded_StructSeq
)
30 Test_Bounded_Struct_Sequence::~Test_Bounded_Struct_Sequence ()
32 CORBA::string_free (this->opname_
);
34 // the other data members will be freed as they are "_var"s and objects
35 // (rather than pointers to objects)
39 Test_Bounded_Struct_Sequence::opname () const
45 Test_Bounded_Struct_Sequence::dii_req_invoke (CORBA::Request
*req
)
47 req
->add_in_arg ("s1") <<= this->in_
;
48 req
->add_inout_arg ("s2") <<= this->inout_
.in ();
49 req
->add_out_arg ("s3") <<= this->out_
.in ();
50 req
->set_return_type (Param_Test::_tc_Bounded_StructSeq
);
54 const Param_Test::Bounded_StructSeq
*tmp
= 0;
55 req
->return_value () >>= tmp
;
56 this->ret_
= new Param_Test::Bounded_StructSeq (*tmp
);
58 CORBA::NamedValue_ptr arg2
=
59 req
->arguments ()->item (1);
60 *arg2
->value () >>= tmp
;
61 this->inout_
= new Param_Test::Bounded_StructSeq (*tmp
);
63 CORBA::NamedValue_ptr arg3
=
64 req
->arguments ()->item (2);
65 *arg3
->value () >>= tmp
;
66 this->out_
= new Param_Test::Bounded_StructSeq (*tmp
);
70 Test_Bounded_Struct_Sequence::init_parameters (Param_Test_ptr
/* objref */
73 Generator
*gen
= GENERATOR::instance (); // value generator
75 // set the length of the sequence
76 this->in_
.length (MAX_STRUCTSEQ_LEN
);
77 // now set each individual element
78 for (CORBA::ULong i
= 0; i
< this->in_
.length (); i
++)
80 // generate some arbitrary struct to be filled into the ith location in
82 this->in_
[i
] = gen
->gen_fixed_struct ();
85 this->inout_
->length (0);
86 this->out_
->length (0);
87 this->ret_
->length (0);
93 Test_Bounded_Struct_Sequence::reset_parameters ()
95 this->inout_
= new Param_Test::Bounded_StructSeq
; // delete the previous ones
96 this->out_
= new Param_Test::Bounded_StructSeq
;
97 this->ret_
= new Param_Test::Bounded_StructSeq
;
99 this->inout_
->length (0);
100 this->out_
->length (0);
101 this->ret_
->length (0);
107 Test_Bounded_Struct_Sequence::run_sii_test (Param_Test_ptr objref
)
111 Param_Test::Bounded_StructSeq_out
out (this->out_
.out ());
113 this->ret_
= objref
->test_bounded_struct_sequence (this->in_
,
114 this->inout_
.inout (),
119 catch (const CORBA::Exception
& ex
)
121 ex
._tao_print_exception ("Test_Bounded_Struct_Sequence::run_sii_test\n");
127 Test_Bounded_Struct_Sequence::check_validity ()
129 if (this->compare (this->in_
, this->inout_
.in ()) &&
130 this->compare (this->in_
, this->out_
.in ()) &&
131 this->compare (this->in_
, this->ret_
.in ()))
138 Test_Bounded_Struct_Sequence::check_validity (CORBA::Request_ptr
)
140 return this->check_validity ();
144 Test_Bounded_Struct_Sequence::print_values ()
146 ACE_DEBUG ((LM_DEBUG
,
147 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
149 this->print_sequence (this->in_
);
150 ACE_DEBUG ((LM_DEBUG
,
151 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
152 "INOUT sequence\n"));
153 this->print_sequence (this->inout_
.in ());
154 ACE_DEBUG ((LM_DEBUG
,
155 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
157 this->print_sequence (this->out_
.in ());
158 ACE_DEBUG ((LM_DEBUG
,
159 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
161 this->print_sequence (this->ret_
.in ());
165 Test_Bounded_Struct_Sequence::compare (const Param_Test::Bounded_StructSeq
&s1
,
166 const Param_Test::Bounded_StructSeq
&s2
)
168 if (s1
.maximum () != s2
.maximum ())
170 if (s1
.length () != s2
.length ())
173 for (CORBA::ULong i
=0; i
< s1
.length (); i
++)
175 const Param_Test::Fixed_Struct
& vs1
= s1
[i
];
176 const Param_Test::Fixed_Struct
& vs2
= s2
[i
];
182 || !ACE::is_equal (vs1
.f
, vs2
.f
)
184 || !ACE::is_equal (vs1
.d
, vs2
.d
))
192 Test_Bounded_Struct_Sequence::print_sequence (const Param_Test::Bounded_StructSeq
&s
)
194 ACE_DEBUG ((LM_DEBUG
,
199 ACE_DEBUG ((LM_DEBUG
, "Elements -\n"));
200 for (CORBA::ULong i
=0; i
< s
.length (); i
++)
202 const Param_Test::Fixed_Struct
& vs
= s
[i
];
204 ACE_DEBUG ((LM_DEBUG
,
214 vs
.l
, vs
.c
, vs
.s
, vs
.o
, vs
.f
, vs
.b
, vs
.d
));