2 //=============================================================================
4 * @file multdim_array.cpp
6 * tests multidimensional fixed size arrays
10 //=============================================================================
14 #include "multdim_array.h"
17 // ************************************************************************
19 // ************************************************************************
21 Test_Multdim_Array::Test_Multdim_Array (void)
22 : opname_ (CORBA::string_dup ("test_multdim_array")),
23 in_ (new Param_Test::Multdim_Array
),
24 inout_ (new Param_Test::Multdim_Array
),
25 out_ (new Param_Test::Multdim_Array
),
26 ret_ (new Param_Test::Multdim_Array
)
30 Test_Multdim_Array::~Test_Multdim_Array (void)
32 CORBA::string_free (this->opname_
);
37 Test_Multdim_Array::opname (void) const
43 Test_Multdim_Array::dii_req_invoke (CORBA::Request
*req
)
45 req
->add_in_arg ("s1") <<= Param_Test::Multdim_Array_forany (this->in_
.inout ());
46 req
->add_inout_arg ("s2") <<= Param_Test::Multdim_Array_forany (this->inout_
.inout ());
47 req
->add_out_arg ("s3") <<= Param_Test::Multdim_Array_forany (this->out_
.inout ());
49 req
->set_return_type (Param_Test::_tc_Multdim_Array
);
54 Param_Test::Multdim_Array_forany forany
;
55 req
->return_value () >>= forany
;
56 Param_Test::Multdim_Array_copy (this->ret_
, forany
.in ());
58 CORBA::NamedValue_ptr o2
=
59 req
->arguments ()->item (1);
60 *o2
->value () >>= forany
;
61 Param_Test::Multdim_Array_copy (this->inout_
, forany
.in ());
63 CORBA::NamedValue_ptr o3
=
64 req
->arguments ()->item (2);
65 *o3
->value () >>= forany
;
66 Param_Test::Multdim_Array_copy (this->out_
, forany
.in ());
70 Test_Multdim_Array::init_parameters (Param_Test_ptr
/*objref*/
73 Generator
*gen
= GENERATOR::instance (); // value generator
75 for (CORBA::ULong i
=0; i
< Param_Test::DIM2
; i
++)
77 for (CORBA::ULong j
=0; j
< Param_Test::DIM3
; j
++)
79 for (CORBA::ULong k
=0; k
< Param_Test::DIM1
; k
++)
81 this->in_
[i
][j
][k
] = gen
->gen_long ();
82 this->inout_
[i
][j
][k
] = 0;
90 Test_Multdim_Array::reset_parameters (void)
92 Generator
*gen
= GENERATOR::instance (); // value generator
94 // free the in value array
95 Param_Test::Multdim_Array_free (this->in_
._retn ());
96 // needed for repeated DII calls
97 this->in_
= new Param_Test::Multdim_Array
;
98 // free the inout value array
99 Param_Test::Multdim_Array_free (this->inout_
._retn ());
100 // needed for repeated DII calls
101 this->inout_
= new Param_Test::Multdim_Array
;
103 for (CORBA::ULong i
=0; i
< Param_Test::DIM2
; i
++)
105 for (CORBA::ULong j
=0; j
< Param_Test::DIM3
; j
++)
107 for (CORBA::ULong k
=0; k
< Param_Test::DIM1
; k
++)
109 this->inout_
[i
][j
][k
] = 0;
110 this->in_
[i
][j
][k
] = gen
->gen_long ();
114 // free the out value array
115 Param_Test::Multdim_Array_free (this->out_
._retn ());
116 // needed for repeated DII calls
117 this->out_
= new Param_Test::Multdim_Array
;
118 // free the return value array
119 Param_Test::Multdim_Array_free (this->ret_
._retn ());
120 // needed for repeated DII calls
121 this->ret_
= new Param_Test::Multdim_Array
;
126 Test_Multdim_Array::run_sii_test (Param_Test_ptr objref
)
130 this->ret_
= objref
->test_multdim_array (this->in_
.in (),
131 this->inout_
.inout (),
132 this->out_
.inout ());
135 catch (const CORBA::Exception
& ex
)
137 ex
._tao_print_exception ("Test_Multdim_Array::run_sii_test\n");
143 Test_Multdim_Array::check_validity (void)
145 if (this->compare (this->in_
.in (),
146 this->inout_
.in ()) &&
147 this->compare (this->in_
.in (),
149 this->compare (this->in_
.in (),
157 Test_Multdim_Array::check_validity (CORBA::Request_ptr
/*req*/)
159 //ACE_UNUSED_ARG (req);
160 return this->check_validity ();
164 Test_Multdim_Array::compare (const Param_Test::Multdim_Array_slice
*a1
,
165 const Param_Test::Multdim_Array_slice
*a2
)
167 for (CORBA::ULong i
=0; i
< Param_Test::DIM2
; i
++)
169 for (CORBA::ULong j
=0; j
< Param_Test::DIM3
; j
++)
171 for (CORBA::ULong k
=0; k
< Param_Test::DIM1
; k
++)
173 if (a1
[i
][j
][k
] != a2
[i
][j
][k
])
182 Test_Multdim_Array::print_values (void)
184 ACE_DEBUG ((LM_DEBUG
, "IN array\n"));
185 this->print (this->in_
.in ());
186 ACE_DEBUG ((LM_DEBUG
, "INOUT array\n"));
187 this->print (this->inout_
.in ());
188 ACE_DEBUG ((LM_DEBUG
, "OUT array\n"));
189 this->print (this->out_
.in ());
190 ACE_DEBUG ((LM_DEBUG
, "RET array\n"));
191 this->print (this->ret_
.in ());
195 Test_Multdim_Array::print (const Param_Test::Multdim_Array_slice
*a
)
197 for (CORBA::ULong i
= 0; i
< Param_Test::DIM2
; i
++)
199 for (CORBA::ULong j
=0; j
< Param_Test::DIM3
; j
++)
201 for (CORBA::ULong k
=0; k
< Param_Test::DIM1
; k
++)
203 ACE_DEBUG ((LM_DEBUG
, "\t\tElement #%d #%d #%d = %d\n",i
,j
,k
, a
[i
][j
][k
]));