2 //=============================================================================
6 * tests fixed size arrays
8 * @author Aniruddha Gokhale
10 //=============================================================================
14 #include "var_array.h"
16 // ************************************************************************
18 // ************************************************************************
20 Test_Var_Array::Test_Var_Array ()
21 : opname_ (CORBA::string_dup ("test_var_array")),
22 out_ (new Param_Test::Var_Array
),
23 ret_ (new Param_Test::Var_Array
)
27 Test_Var_Array::~Test_Var_Array ()
29 CORBA::string_free (this->opname_
);
34 Test_Var_Array::opname () const
40 Test_Var_Array::dii_req_invoke (CORBA::Request
*req
)
42 req
->add_in_arg ("s1") <<= Param_Test::Var_Array_forany (this->in_
);
43 req
->add_inout_arg ("s2") <<= Param_Test::Var_Array_forany (this->inout_
);
44 req
->add_out_arg ("s3") <<= Param_Test::Var_Array_forany (this->out_
.inout ());
46 req
->set_return_type (Param_Test::_tc_Var_Array
);
50 Param_Test::Var_Array_forany forany
;
52 req
->return_value () >>= forany
;
53 this->ret_
= Param_Test::Var_Array_dup (forany
.in ());
55 CORBA::NamedValue_ptr o2
=
56 req
->arguments ()->item (1);
57 *o2
->value () >>= forany
;
58 Param_Test::Var_Array_copy (this->inout_
, forany
.in ());
60 CORBA::NamedValue_ptr o3
=
61 req
->arguments ()->item (2);
62 *o3
->value () >>= forany
;
63 this->out_
= Param_Test::Var_Array_dup (forany
.in ());
67 Test_Var_Array::init_parameters (Param_Test_ptr
)
69 Generator
*gen
= GENERATOR::instance (); // value generator
73 for (CORBA::ULong i
=0; i
< Param_Test::DIM2
; i
++)
75 this->in_
[i
] = gen
->gen_string ();
82 Test_Var_Array::reset_parameters ()
84 // free the out, and return value arrays
85 Param_Test::Var_Array_free (this->out_
._retn ());
86 Param_Test::Var_Array_free (this->ret_
._retn ());
87 this->out_
= new Param_Test::Var_Array
;
88 this->ret_
= new Param_Test::Var_Array
;
93 Test_Var_Array::run_sii_test (Param_Test_ptr objref
)
97 Param_Test::Var_Array_out
out_arr (this->out_
.out ());
98 this->ret_
= objref
->test_var_array (this->in_
,
104 catch (const CORBA::Exception
& ex
)
106 ex
._tao_print_exception ("Test_Var_Array::run_sii_test\n");
112 Test_Var_Array::check_validity ()
114 if (this->compare (this->in_
, this->inout_
) &&
115 this->compare (this->in_
, this->out_
.in ()) &&
116 this->compare (this->in_
, this->ret_
.in ()))
123 Test_Var_Array::check_validity (CORBA::Request_ptr
)
125 return this->check_validity ();
129 Test_Var_Array::compare (const Param_Test::Var_Array_slice
*a1
,
130 const Param_Test::Var_Array_slice
*a2
)
132 for (CORBA::ULong i
=0; i
< Param_Test::DIM2
; i
++)
134 if (ACE_OS::strcmp (a1
[i
].in (), a2
[i
].in ()))
141 Test_Var_Array::print_values ()
143 ACE_DEBUG ((LM_DEBUG
, "IN array\n"));
144 this->print (this->in_
);
145 ACE_DEBUG ((LM_DEBUG
, "INOUT array\n"));
146 this->print (this->inout_
);
147 ACE_DEBUG ((LM_DEBUG
, "OUT array\n"));
148 this->print (this->out_
.in ());
149 ACE_DEBUG ((LM_DEBUG
, "RET array\n"));
150 this->print (this->ret_
.in ());
154 Test_Var_Array::print (const Param_Test::Var_Array_slice
*a
)
156 for (CORBA::ULong i
= 0; i
< Param_Test::DIM2
; i
++)
158 ACE_DEBUG ((LM_DEBUG
, "\t\tElement #%d = %C\n",i
, a
[i
].in ()));