2 //=============================================================================
4 * @file bd_array_seq.cpp
6 * tests bounded array sequences
8 * @author Jeff Parsons <parsons@cs.wustl.edu>
10 //=============================================================================
14 #include "bd_array_seq.h"
16 const CORBA::ULong MAX_ARRAYSEQ_LEN
= 1;
18 // ************************************************************************
19 // Test_Bounded_Array_Sequence
20 // ************************************************************************
22 Test_Bounded_Array_Sequence::Test_Bounded_Array_Sequence ()
23 : opname_ (CORBA::string_dup ("test_bounded_array_sequence")),
24 inout_ (new Param_Test::Bounded_ArraySeq
),
25 out_ (new Param_Test::Bounded_ArraySeq
),
26 ret_ (new Param_Test::Bounded_ArraySeq
)
30 Test_Bounded_Array_Sequence::~Test_Bounded_Array_Sequence ()
32 CORBA::string_free (this->opname_
);
34 // the other data members will be freed as they are "_var"s and objects
35 // (rather than pointers to objects)
39 Test_Bounded_Array_Sequence::opname () const
45 Test_Bounded_Array_Sequence::dii_req_invoke (CORBA::Request
*req
)
47 req
->add_in_arg ("s1") <<= this->in_
;
48 req
->add_inout_arg ("s2") <<= this->inout_
.in ();
49 req
->add_out_arg ("s3") <<= this->out_
.in ();
50 req
->set_return_type (Param_Test::_tc_Bounded_ArraySeq
);
54 const Param_Test::Bounded_ArraySeq
*tmp
= 0;
55 req
->return_value () >>= tmp
;
56 this->ret_
= new Param_Test::Bounded_ArraySeq (*tmp
);
58 CORBA::NamedValue_ptr arg2
=
59 req
->arguments ()->item (1);
60 *arg2
->value () >>= tmp
;
61 this->inout_
= new Param_Test::Bounded_ArraySeq (*tmp
);
63 CORBA::NamedValue_ptr arg3
=
64 req
->arguments ()->item (2);
65 *arg3
->value () >>= tmp
;
66 this->out_
= new Param_Test::Bounded_ArraySeq (*tmp
);
70 Test_Bounded_Array_Sequence::init_parameters (Param_Test_ptr
)
72 Generator
*gen
= GENERATOR::instance (); // value generator
74 // set the length of the sequence
75 this->in_
.length (MAX_ARRAYSEQ_LEN
);
76 // different from in_.
77 this->inout_
->length (1);
79 // now set each individual element
80 Param_Test::Fixed_Array tmp
;
82 for (CORBA::ULong j
= 0; j
< Param_Test::DIM1
; j
++)
84 tmp
[j
] = gen
->gen_long ();
87 Param_Test::Fixed_Array_copy (this->inout_
[0], tmp
);
89 for (CORBA::ULong i
= 0; i
< this->in_
.length (); i
++)
91 // Generate some arbitrary array to be filled into the ith
92 // location in the sequence.
93 for (CORBA::ULong j
= 0; j
< Param_Test::DIM1
; j
++)
95 tmp
[j
] = gen
->gen_long ();
98 Param_Test::Fixed_Array_copy (this->in_
[i
], tmp
);
105 Test_Bounded_Array_Sequence::reset_parameters ()
107 // Delete the previous ones.
108 this->inout_
= new Param_Test::Bounded_ArraySeq
;
109 this->out_
= new Param_Test::Bounded_ArraySeq
;
110 this->ret_
= new Param_Test::Bounded_ArraySeq
;
115 Test_Bounded_Array_Sequence::run_sii_test (Param_Test_ptr objref
)
119 Param_Test::Bounded_ArraySeq_out
out (this->out_
.out ());
122 objref
->test_bounded_array_sequence (this->in_
,
123 this->inout_
.inout (),
128 catch (const CORBA::Exception
& ex
)
130 ex
._tao_print_exception ("Test_Bounded_Array_Sequence::run_sii_test\n");
136 Test_Bounded_Array_Sequence::check_validity ()
138 if (this->compare (this->in_
, this->inout_
.in ()) &&
139 this->compare (this->in_
, this->out_
.in ()) &&
140 this->compare (this->in_
, this->ret_
.in ()))
147 Test_Bounded_Array_Sequence::check_validity (CORBA::Request_ptr
)
149 return this->check_validity ();
153 Test_Bounded_Array_Sequence::print_values ()
155 ACE_DEBUG ((LM_DEBUG
,
156 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
158 this->print_sequence (this->in_
);
159 ACE_DEBUG ((LM_DEBUG
,
160 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
161 "INOUT sequence\n"));
162 this->print_sequence (this->inout_
.in ());
163 ACE_DEBUG ((LM_DEBUG
,
164 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
166 this->print_sequence (this->out_
.in ());
167 ACE_DEBUG ((LM_DEBUG
,
168 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
170 this->print_sequence (this->ret_
.in ());
174 Test_Bounded_Array_Sequence::compare (const Param_Test::Bounded_ArraySeq
&s1
,
175 const Param_Test::Bounded_ArraySeq
&s2
)
177 if (s1
.maximum () != s2
.maximum ())
182 if (s1
.length () != s2
.length ())
187 for (CORBA::ULong i
= 0; i
< s1
.length (); i
++)
189 const Param_Test::Fixed_Array
& vs1
= s1
[i
];
190 const Param_Test::Fixed_Array
& vs2
= s2
[i
];
192 for (CORBA::ULong j
= 0; j
< Param_Test::DIM1
; j
++)
194 if (vs1
[j
] != vs2
[j
])
205 Test_Bounded_Array_Sequence::print_sequence (const Param_Test::Bounded_ArraySeq
&s
)
207 ACE_DEBUG ((LM_DEBUG
,
212 ACE_DEBUG ((LM_DEBUG
, "Elements -\n"));
214 for (CORBA::ULong i
=0; i
< s
.length (); i
++)
216 ACE_DEBUG ((LM_DEBUG
,
220 const Param_Test::Fixed_Array
& vs
= s
[i
];
222 for (CORBA::ULong j
= 0; j
< Param_Test::DIM1
; j
++)
224 ACE_DEBUG ((LM_DEBUG
,
225 "Element%d[%d] = %d\n",