2 //=============================================================================
4 * @file ub_array_seq.cpp
6 * tests unbounded array sequences
8 * @author Jeff Parsons <parsons@cs.wustl.edu>
10 //=============================================================================
14 #include "ub_array_seq.h"
16 // ************************************************************************
17 // Test_Array_Sequence
18 // ************************************************************************
20 Test_Array_Sequence::Test_Array_Sequence ()
21 : opname_ (CORBA::string_dup ("test_array_sequence")),
22 inout_ (new Param_Test::ArraySeq
),
23 out_ (new Param_Test::ArraySeq
),
24 ret_ (new Param_Test::ArraySeq
)
28 Test_Array_Sequence::~Test_Array_Sequence ()
30 CORBA::string_free (this->opname_
);
32 // the other data members will be freed as they are "_var"s and objects
33 // (rather than pointers to objects)
37 Test_Array_Sequence::opname () const
43 Test_Array_Sequence::dii_req_invoke (CORBA::Request
*req
)
45 req
->add_in_arg ("s1") <<= this->in_
;
46 req
->add_inout_arg ("s2") <<= this->inout_
.in ();
47 req
->add_out_arg ("s3") <<= this->out_
.in ();
49 req
->set_return_type (Param_Test::_tc_ArraySeq
);
53 const Param_Test::ArraySeq
*tmp
= 0;
54 req
->return_value () >>= tmp
;
55 this->ret_
= new Param_Test::ArraySeq (*tmp
);
57 CORBA::NamedValue_ptr o2
=
58 req
->arguments ()->item (1);
59 *o2
->value () >>= tmp
;
60 this->inout_
= new Param_Test::ArraySeq (*tmp
);
62 CORBA::NamedValue_ptr o3
=
63 req
->arguments ()->item (2);
64 *o3
->value () >>= tmp
;
65 this->out_
= new Param_Test::ArraySeq (*tmp
);
69 Test_Array_Sequence::init_parameters (Param_Test_ptr
)
71 Generator
*gen
= GENERATOR::instance (); // value generator
73 // get some sequence length (not more than 10)
74 CORBA::ULong len
= (CORBA::ULong
) (gen
->gen_long () % 10) + 1;
76 // set the length of the in sequence
77 this->in_
.length (len
);
78 // different from in_.
79 this->inout_
->length (1);
81 // now set each individual element
82 Param_Test::Fixed_Array tmp
;
84 for (CORBA::ULong j
= 0; j
< Param_Test::DIM1
; j
++)
86 tmp
[j
] = gen
->gen_long ();
89 Param_Test::Fixed_Array_copy (this->inout_
[0], tmp
);
91 for (CORBA::ULong i
= 0; i
< this->in_
.length (); i
++)
93 // Generate some arbitrary array to be filled into the ith
94 // location in the sequence.
95 for (CORBA::ULong j
= 0; j
< Param_Test::DIM1
; j
++)
97 tmp
[j
] = gen
->gen_long ();
100 Param_Test::Fixed_Array_copy (this->in_
[i
], tmp
);
107 Test_Array_Sequence::reset_parameters ()
109 // Delete the previous ones.
110 this->inout_
= new Param_Test::ArraySeq
;
111 this->out_
= new Param_Test::ArraySeq
;
112 this->ret_
= new Param_Test::ArraySeq
;
117 Test_Array_Sequence::run_sii_test (Param_Test_ptr objref
)
121 Param_Test::ArraySeq_out
out (this->out_
.out ());
123 this->ret_
= objref
->test_array_sequence (this->in_
,
124 this->inout_
.inout (),
129 catch (const CORBA::Exception
& ex
)
131 ex
._tao_print_exception ("Test_Array_Sequence::run_sii_test\n");
137 Test_Array_Sequence::check_validity ()
139 if (this->compare (this->in_
, this->inout_
.in ()) &&
140 this->compare (this->in_
, this->out_
.in ()) &&
141 this->compare (this->in_
, this->ret_
.in ()))
148 Test_Array_Sequence::check_validity (CORBA::Request_ptr
)
150 return this->check_validity ();
154 Test_Array_Sequence::print_values ()
156 ACE_DEBUG ((LM_DEBUG
,
157 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
159 this->print_sequence (this->in_
);
160 ACE_DEBUG ((LM_DEBUG
,
161 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
163 this->print_sequence (this->inout_
.in ());
164 ACE_DEBUG ((LM_DEBUG
,
165 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
167 this->print_sequence (this->out_
.in ());
168 ACE_DEBUG ((LM_DEBUG
,
169 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
171 this->print_sequence (this->ret_
.in ());
175 Test_Array_Sequence::compare (const Param_Test::ArraySeq
&s1
,
176 const Param_Test::ArraySeq
&s2
)
178 if (s1
.maximum () != s2
.maximum ())
183 if (s1
.length () != s2
.length ())
188 for (CORBA::ULong i
= 0; i
< s1
.length (); i
++)
190 const Param_Test::Fixed_Array
& vs1
= s1
[i
];
191 const Param_Test::Fixed_Array
& vs2
= s2
[i
];
193 for (CORBA::ULong j
= 0; j
< Param_Test::DIM1
; j
++)
195 if (vs1
[j
] != vs2
[j
])
206 Test_Array_Sequence::print_sequence (const Param_Test::ArraySeq
&s
)
208 ACE_DEBUG ((LM_DEBUG
,
213 ACE_DEBUG ((LM_DEBUG
, "Elements -\n"));
215 for (CORBA::ULong i
=0; i
< s
.length (); i
++)
217 ACE_DEBUG ((LM_DEBUG
,
221 const Param_Test::Fixed_Array
& vs
= s
[i
];
223 for (CORBA::ULong j
= 0; j
< Param_Test::DIM1
; j
++)
225 ACE_DEBUG ((LM_DEBUG
,
226 "Element%d[%d] = %d\n",