2 //=============================================================================
4 * @file bd_short_seq.cpp
6 * tests bounded short sequences
8 * @author Aniruddha Gokhale
10 //=============================================================================
14 #include "bd_short_seq.h"
16 // ************************************************************************
17 // Test_Bounded_Short_Sequence
18 // ************************************************************************
20 Test_Bounded_Short_Sequence::Test_Bounded_Short_Sequence ()
21 : opname_ (CORBA::string_dup ("test_bounded_short_sequence")),
22 in_ (new Param_Test::Bounded_Short_Seq
),
23 inout_ (new Param_Test::Bounded_Short_Seq
),
24 out_ (new Param_Test::Bounded_Short_Seq
),
25 ret_ (new Param_Test::Bounded_Short_Seq
)
29 Test_Bounded_Short_Sequence::~Test_Bounded_Short_Sequence ()
31 CORBA::string_free (this->opname_
);
36 Test_Bounded_Short_Sequence::opname () const
42 Test_Bounded_Short_Sequence::dii_req_invoke (CORBA::Request
*req
)
44 req
->add_in_arg ("s1") <<= this->in_
.in ();
45 req
->add_inout_arg ("s2") <<= this->inout_
.in ();
46 req
->add_out_arg ("s3") <<= this->out_
.in ();
47 req
->set_return_type (Param_Test::_tc_Bounded_Short_Seq
);
51 const Param_Test::Bounded_Short_Seq
*tmp
= 0;
52 req
->return_value () >>= tmp
;
53 this->ret_
= new Param_Test::Bounded_Short_Seq (*tmp
);
55 CORBA::NamedValue_ptr arg2
=
56 req
->arguments ()->item (1);
57 *arg2
->value () >>= tmp
;
58 this->inout_
= new Param_Test::Bounded_Short_Seq (*tmp
);
60 CORBA::NamedValue_ptr arg3
=
61 req
->arguments ()->item (2);
62 *arg3
->value () >>= tmp
;
63 this->out_
= new Param_Test::Bounded_Short_Seq (*tmp
);
67 Test_Bounded_Short_Sequence::init_parameters (Param_Test_ptr
/*objref*/
70 // ACE_UNUSED_ARG (objref);
72 // get some sequence length (32 in this case)
73 CORBA::ULong len
= this->in_
->maximum ();
75 // set the length of the sequence
76 this->in_
->length (len
);
77 this->inout_
->length (len
);
78 // now set each individual element
79 for (CORBA::ULong i
= 0; i
< len
; ++i
)
81 // generate some arbitrary string to be filled into the ith location in
84 this->inout_
[i
] = i
+ 1; // different from in_
87 this->inout_
->length (0);
88 this->out_
->length (0);
89 this->ret_
->length (0);
95 Test_Bounded_Short_Sequence::reset_parameters ()
97 this->inout_
= new Param_Test::Bounded_Short_Seq
; // delete the previous ones
98 this->out_
= new Param_Test::Bounded_Short_Seq
;
99 this->ret_
= new Param_Test::Bounded_Short_Seq
;
101 this->inout_
->length (0);
102 this->out_
->length (0);
103 this->ret_
->length (0);
109 Test_Bounded_Short_Sequence::run_sii_test (Param_Test_ptr objref
)
113 Param_Test::Bounded_Short_Seq_out
out (this->out_
.out ());
115 this->ret_
= objref
->test_bounded_short_sequence (this->in_
.in (),
116 this->inout_
.inout (),
121 catch (const CORBA::Exception
& ex
)
123 ex
._tao_print_exception ("Test_Bounded_Short_Sequence::run_sii_test\n");
129 Test_Bounded_Short_Sequence::check_validity ()
131 CORBA::Boolean flag
= 0;
132 if ((this->in_
->length () == this->inout_
->length ()) &&
133 (this->in_
->length () == this->out_
->length ()) &&
134 (this->in_
->length () == this->ret_
->length ()))
136 flag
= 1; // assume all are equal
137 // lengths are same. Now compare the contents
138 for (CORBA::ULong i
=0; i
< this->in_
->length () && flag
; i
++)
140 if (this->in_
[i
] != this->inout_
[i
] ||
141 this->in_
[i
] != this->out_
[i
] ||
142 this->in_
[i
] != this->ret_
[i
])
151 Test_Bounded_Short_Sequence::check_validity (CORBA::Request_ptr
/*req*/)
153 return this->check_validity ();
157 Test_Bounded_Short_Sequence::print_values ()
160 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
162 for (i
= 0; this->in_
.ptr () && (i
< this->in_
->length ()); ++i
)
164 ACE_DEBUG ((LM_DEBUG
,
171 if (!this->in_
.ptr ())
173 ACE_DEBUG ((LM_DEBUG
, "\nin sequence is NUL\n"));
176 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
178 for (i
= 0; this->inout_
.ptr () && (i
< this->inout_
->length ()); ++i
)
180 ACE_DEBUG ((LM_DEBUG
,
187 if (!this->inout_
.ptr ())
189 ACE_DEBUG ((LM_DEBUG
, "\ninout sequence is NUL\n"));
192 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
194 for (i
= 0; this->out_
.ptr () && (i
< this->out_
->length ()); ++i
)
196 ACE_DEBUG ((LM_DEBUG
,
203 if (!this->out_
.ptr ())
205 ACE_DEBUG ((LM_DEBUG
, "\nout sequence is NUL\n"));
208 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
210 for (i
= 0; this->ret_
.ptr () && (i
< this->ret_
->length ()); ++i
)
212 ACE_DEBUG ((LM_DEBUG
,
219 if (!this->ret_
.ptr ())
221 ACE_DEBUG ((LM_DEBUG
, "\nin sequence is NUL\n"));
224 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));