Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Param_Test / bd_short_seq.cpp
blob5b88ceff92ad32036afeeddd45b5c798b9587a03
2 //=============================================================================
3 /**
4 * @file bd_short_seq.cpp
6 * tests bounded short sequences
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
13 #include "helper.h"
14 #include "bd_short_seq.h"
16 // ************************************************************************
17 // Test_Bounded_Short_Sequence
18 // ************************************************************************
20 Test_Bounded_Short_Sequence::Test_Bounded_Short_Sequence ()
21 : opname_ (CORBA::string_dup ("test_bounded_short_sequence")),
22 in_ (new Param_Test::Bounded_Short_Seq),
23 inout_ (new Param_Test::Bounded_Short_Seq),
24 out_ (new Param_Test::Bounded_Short_Seq),
25 ret_ (new Param_Test::Bounded_Short_Seq)
29 Test_Bounded_Short_Sequence::~Test_Bounded_Short_Sequence ()
31 CORBA::string_free (this->opname_);
32 this->opname_ = 0;
35 const char *
36 Test_Bounded_Short_Sequence::opname () const
38 return this->opname_;
41 void
42 Test_Bounded_Short_Sequence::dii_req_invoke (CORBA::Request *req)
44 req->add_in_arg ("s1") <<= this->in_.in ();
45 req->add_inout_arg ("s2") <<= this->inout_.in ();
46 req->add_out_arg ("s3") <<= this->out_.in ();
47 req->set_return_type (Param_Test::_tc_Bounded_Short_Seq);
49 req->invoke ();
51 const Param_Test::Bounded_Short_Seq *tmp = 0;
52 req->return_value () >>= tmp;
53 this->ret_ = new Param_Test::Bounded_Short_Seq (*tmp);
55 CORBA::NamedValue_ptr arg2 =
56 req->arguments ()->item (1);
57 *arg2->value () >>= tmp;
58 this->inout_ = new Param_Test::Bounded_Short_Seq (*tmp);
60 CORBA::NamedValue_ptr arg3 =
61 req->arguments ()->item (2);
62 *arg3->value () >>= tmp;
63 this->out_ = new Param_Test::Bounded_Short_Seq (*tmp);
66 int
67 Test_Bounded_Short_Sequence::init_parameters (Param_Test_ptr /*objref*/
68 /*env*/)
70 // ACE_UNUSED_ARG (objref);
72 // get some sequence length (32 in this case)
73 CORBA::ULong len = this->in_->maximum ();
75 // set the length of the sequence
76 this->in_->length (len);
77 this->inout_->length (len);
78 // now set each individual element
79 for (CORBA::ULong i = 0; i < len; ++i)
81 // generate some arbitrary string to be filled into the ith location in
82 // the sequence
83 this->in_[i] = i;
84 this->inout_[i] = i + 1; // different from in_
87 this->inout_->length (0);
88 this->out_->length (0);
89 this->ret_->length (0);
91 return 0;
94 int
95 Test_Bounded_Short_Sequence::reset_parameters ()
97 this->inout_ = new Param_Test::Bounded_Short_Seq; // delete the previous ones
98 this->out_ = new Param_Test::Bounded_Short_Seq;
99 this->ret_ = new Param_Test::Bounded_Short_Seq;
101 this->inout_->length (0);
102 this->out_->length (0);
103 this->ret_->length (0);
105 return 0;
109 Test_Bounded_Short_Sequence::run_sii_test (Param_Test_ptr objref)
113 Param_Test::Bounded_Short_Seq_out out (this->out_.out ());
115 this->ret_ = objref->test_bounded_short_sequence (this->in_.in (),
116 this->inout_.inout (),
117 out);
119 return 0;
121 catch (const CORBA::Exception& ex)
123 ex._tao_print_exception ("Test_Bounded_Short_Sequence::run_sii_test\n");
125 return -1;
128 CORBA::Boolean
129 Test_Bounded_Short_Sequence::check_validity ()
131 CORBA::Boolean flag = 0;
132 if ((this->in_->length () == this->inout_->length ()) &&
133 (this->in_->length () == this->out_->length ()) &&
134 (this->in_->length () == this->ret_->length ()))
136 flag = 1; // assume all are equal
137 // lengths are same. Now compare the contents
138 for (CORBA::ULong i=0; i < this->in_->length () && flag; i++)
140 if (this->in_[i] != this->inout_[i] ||
141 this->in_[i] != this->out_[i] ||
142 this->in_[i] != this->ret_[i])
143 // not equal
144 flag = 0;
147 return flag;
150 CORBA::Boolean
151 Test_Bounded_Short_Sequence::check_validity (CORBA::Request_ptr /*req*/)
153 return this->check_validity ();
156 void
157 Test_Bounded_Short_Sequence::print_values ()
159 CORBA::ULong i;
160 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
162 for (i = 0; this->in_.ptr () && (i < this->in_->length ()); ++i)
164 ACE_DEBUG ((LM_DEBUG,
165 "Element #%d\n"
166 "in : %d\n",
168 this->in_[i]));
171 if (!this->in_.ptr ())
173 ACE_DEBUG ((LM_DEBUG, "\nin sequence is NUL\n"));
176 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
178 for (i = 0; this->inout_.ptr () && (i < this->inout_->length ()); ++i)
180 ACE_DEBUG ((LM_DEBUG,
181 "Element #%d\n"
182 "inout : %d\n",
184 this->inout_[i]));
187 if (!this->inout_.ptr ())
189 ACE_DEBUG ((LM_DEBUG, "\ninout sequence is NUL\n"));
192 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
194 for (i = 0; this->out_.ptr () && (i < this->out_->length ()); ++i)
196 ACE_DEBUG ((LM_DEBUG,
197 "Element #%d\n"
198 "out : %d\n",
200 this->out_[i]));
203 if (!this->out_.ptr ())
205 ACE_DEBUG ((LM_DEBUG, "\nout sequence is NUL\n"));
208 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
210 for (i = 0; this->ret_.ptr () && (i < this->ret_->length ()); ++i)
212 ACE_DEBUG ((LM_DEBUG,
213 "Element #%d\n"
214 "in : %d\n",
216 this->ret_[i]));
219 if (!this->ret_.ptr ())
221 ACE_DEBUG ((LM_DEBUG, "\nin sequence is NUL\n"));
224 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));