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 (void)
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 (void)
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 (void) 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 (void)
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");
128 Test_Bounded_Struct_Sequence::check_validity (void)
130 if (this->compare (this->in_
, this->inout_
.in ()) &&
131 this->compare (this->in_
, this->out_
.in ()) &&
132 this->compare (this->in_
, this->ret_
.in ()))
139 Test_Bounded_Struct_Sequence::check_validity (CORBA::Request_ptr
)
141 return this->check_validity ();
145 Test_Bounded_Struct_Sequence::print_values (void)
147 ACE_DEBUG ((LM_DEBUG
,
148 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
150 this->print_sequence (this->in_
);
151 ACE_DEBUG ((LM_DEBUG
,
152 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
153 "INOUT sequence\n"));
154 this->print_sequence (this->inout_
.in ());
155 ACE_DEBUG ((LM_DEBUG
,
156 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
158 this->print_sequence (this->out_
.in ());
159 ACE_DEBUG ((LM_DEBUG
,
160 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
162 this->print_sequence (this->ret_
.in ());
166 Test_Bounded_Struct_Sequence::compare (const Param_Test::Bounded_StructSeq
&s1
,
167 const Param_Test::Bounded_StructSeq
&s2
)
169 if (s1
.maximum () != s2
.maximum ())
171 if (s1
.length () != s2
.length ())
174 for (CORBA::ULong i
=0; i
< s1
.length (); i
++)
176 const Param_Test::Fixed_Struct
& vs1
= s1
[i
];
177 const Param_Test::Fixed_Struct
& vs2
= s2
[i
];
183 || !ACE::is_equal (vs1
.f
, vs2
.f
)
185 || !ACE::is_equal (vs1
.d
, vs2
.d
))
193 Test_Bounded_Struct_Sequence::print_sequence (const Param_Test::Bounded_StructSeq
&s
)
195 ACE_DEBUG ((LM_DEBUG
,
200 ACE_DEBUG ((LM_DEBUG
, "Elements -\n"));
201 for (CORBA::ULong i
=0; i
< s
.length (); i
++)
203 const Param_Test::Fixed_Struct
& vs
= s
[i
];
205 ACE_DEBUG ((LM_DEBUG
,
215 vs
.l
, vs
.c
, vs
.s
, vs
.o
, vs
.f
, vs
.b
, vs
.d
));