Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Param_Test / bd_array_seq.cpp
blob6cbb566417706b265de8572549152bee1fc15d9b
2 //=============================================================================
3 /**
4 * @file bd_array_seq.cpp
6 * tests bounded array sequences
8 * @author Jeff Parsons <parsons@cs.wustl.edu>
9 */
10 //=============================================================================
13 #include "helper.h"
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_);
33 this->opname_ = 0;
34 // the other data members will be freed as they are "_var"s and objects
35 // (rather than pointers to objects)
38 const char *
39 Test_Bounded_Array_Sequence::opname () const
41 return this->opname_;
44 void
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);
52 req->invoke ();
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);
69 int
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);
101 return 0;
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;
111 return 0;
115 Test_Bounded_Array_Sequence::run_sii_test (Param_Test_ptr objref)
119 Param_Test::Bounded_ArraySeq_out out (this->out_.out ());
121 this->ret_ =
122 objref->test_bounded_array_sequence (this->in_,
123 this->inout_.inout (),
124 out);
126 return 0;
128 catch (const CORBA::Exception& ex)
130 ex._tao_print_exception ("Test_Bounded_Array_Sequence::run_sii_test\n");
132 return -1;
135 CORBA::Boolean
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 ()))
141 return 1;
142 else
143 return 0;
146 CORBA::Boolean
147 Test_Bounded_Array_Sequence::check_validity (CORBA::Request_ptr)
149 return this->check_validity ();
152 void
153 Test_Bounded_Array_Sequence::print_values ()
155 ACE_DEBUG ((LM_DEBUG,
156 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
157 "IN sequence\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"
165 "OUT sequence\n"));
166 this->print_sequence (this->out_.in ());
167 ACE_DEBUG ((LM_DEBUG,
168 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
169 "RET sequence\n"));
170 this->print_sequence (this->ret_.in ());
173 CORBA::Boolean
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 ())
179 return 0;
182 if (s1.length () != s2.length ())
184 return 0;
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])
196 return 0;
201 return 1; // success
204 void
205 Test_Bounded_Array_Sequence::print_sequence (const Param_Test::Bounded_ArraySeq &s)
207 ACE_DEBUG ((LM_DEBUG,
208 "maximum = %d\n"
209 "length = %d\n",
210 s.maximum (),
211 s.length ()));
212 ACE_DEBUG ((LM_DEBUG, "Elements -\n"));
214 for (CORBA::ULong i=0; i < s.length (); i++)
216 ACE_DEBUG ((LM_DEBUG,
217 "Element #%d --\n",
218 i));
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",
228 vs[j]));