2 //=============================================================================
4 * @file bd_long_seq.cpp
6 * tests bounded long sequences
8 * @author Aniruddha Gokhale
10 //=============================================================================
14 #include "bd_long_seq.h"
16 // ************************************************************************
17 // Test_Bounded_Long_Sequence
18 // ************************************************************************
20 Test_Bounded_Long_Sequence::Test_Bounded_Long_Sequence ()
21 : opname_ (CORBA::string_dup ("test_bounded_long_sequence")),
22 in_ (new Param_Test::Bounded_Long_Seq
),
23 inout_ (new Param_Test::Bounded_Long_Seq
),
24 out_ (new Param_Test::Bounded_Long_Seq
),
25 ret_ (new Param_Test::Bounded_Long_Seq
)
29 Test_Bounded_Long_Sequence::~Test_Bounded_Long_Sequence ()
31 CORBA::string_free (this->opname_
);
36 Test_Bounded_Long_Sequence::opname () const
42 Test_Bounded_Long_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_Long_Seq
);
51 const Param_Test::Bounded_Long_Seq
*tmp
;
52 req
->return_value () >>= tmp
;
53 this->ret_
= new Param_Test::Bounded_Long_Seq (*tmp
);
55 CORBA::NamedValue_ptr arg2
=
56 req
->arguments ()->item (1);
57 *arg2
->value () >>= tmp
;
58 this->inout_
= new Param_Test::Bounded_Long_Seq (*tmp
);
60 CORBA::NamedValue_ptr arg3
=
61 req
->arguments ()->item (2);
62 *arg3
->value () >>= tmp
;
63 this->out_
= new Param_Test::Bounded_Long_Seq (*tmp
);
67 Test_Bounded_Long_Sequence::init_parameters (Param_Test_ptr
)
69 // get some sequence length (32 in this case)
70 CORBA::ULong len
= this->in_
->maximum ();
72 // set the length of the sequence
73 this->in_
->length (len
);
74 this->inout_
->length (len
);
75 // now set each individual element
76 for (CORBA::ULong i
=0; i
< this->in_
->maximum (); i
++)
79 this->inout_
[i
] = i
+1; // different from in_
82 this->inout_
->length (0);
83 this->out_
->length (0);
84 this->ret_
->length (0);
90 Test_Bounded_Long_Sequence::reset_parameters ()
92 this->inout_
= new Param_Test::Bounded_Long_Seq
; // delete the previous ones
93 this->out_
= new Param_Test::Bounded_Long_Seq
;
94 this->ret_
= new Param_Test::Bounded_Long_Seq
;
96 this->inout_
->length (0);
97 this->out_
->length (0);
98 this->ret_
->length (0);
104 Test_Bounded_Long_Sequence::run_sii_test (Param_Test_ptr objref
)
108 Param_Test::Bounded_Long_Seq_out
out (this->out_
.out ());
109 this->ret_
= objref
->test_bounded_long_sequence (this->in_
.in (),
110 this->inout_
.inout (),
115 catch (const CORBA::Exception
& ex
)
117 ex
._tao_print_exception ("Test_Bounded_Long_Sequence::run_sii_test\n");
123 Test_Bounded_Long_Sequence::check_validity ()
125 CORBA::Boolean flag
= 0;
126 if ((this->in_
->length () == this->inout_
->length ()) &&
127 (this->in_
->length () == this->out_
->length ()) &&
128 (this->in_
->length () == this->ret_
->length ()))
130 flag
= 1; // assume all are equal
131 // lengths are same. Now compare the contents
132 for (CORBA::ULong i
=0; i
< this->in_
->length () && flag
; i
++)
134 if (this->in_
[i
] != this->inout_
[i
] ||
135 this->in_
[i
] != this->out_
[i
] ||
136 this->in_
[i
] != this->ret_
[i
])
145 Test_Bounded_Long_Sequence::check_validity (CORBA::Request_ptr req
)
147 ACE_UNUSED_ARG (req
);
148 return this->check_validity ();
152 Test_Bounded_Long_Sequence::print_values ()
155 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
156 for (i
=0; this->in_
.ptr () && (i
< this->in_
->length ()); i
++)
158 ACE_DEBUG ((LM_DEBUG
,
164 if (!this->in_
.ptr ())
165 ACE_DEBUG ((LM_DEBUG
, "\nin sequence is NUL\n"));
166 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
167 for (i
=0; this->inout_
.ptr () && (i
< this->inout_
->length ()); i
++)
169 ACE_DEBUG ((LM_DEBUG
,
175 if (!this->inout_
.ptr ())
176 ACE_DEBUG ((LM_DEBUG
, "\ninout sequence is NUL\n"));
177 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
178 for (i
=0; this->out_
.ptr () && (i
< this->out_
->length ()); i
++)
180 ACE_DEBUG ((LM_DEBUG
,
186 if (!this->out_
.ptr ())
187 ACE_DEBUG ((LM_DEBUG
, "\nout sequence is NUL\n"));
188 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
189 for (i
=0; this->ret_
.ptr () && (i
< this->ret_
->length ()); i
++)
191 ACE_DEBUG ((LM_DEBUG
,
197 if (!this->ret_
.ptr ())
198 ACE_DEBUG ((LM_DEBUG
, "\nin sequence is NUL\n"));
199 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));