Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Param_Test / bd_long_seq.cpp
blob60354698a608dcaffa60b9fdeada03b57047ca3a
2 //=============================================================================
3 /**
4 * @file bd_long_seq.cpp
6 * tests bounded long sequences
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
13 #include "helper.h"
14 #include "bd_long_seq.h"
16 // ************************************************************************
17 // Test_Bounded_Long_Sequence
18 // ************************************************************************
20 Test_Bounded_Long_Sequence::Test_Bounded_Long_Sequence ()
21 : opname_ (CORBA::string_dup ("test_bounded_long_sequence")),
22 in_ (new Param_Test::Bounded_Long_Seq),
23 inout_ (new Param_Test::Bounded_Long_Seq),
24 out_ (new Param_Test::Bounded_Long_Seq),
25 ret_ (new Param_Test::Bounded_Long_Seq)
29 Test_Bounded_Long_Sequence::~Test_Bounded_Long_Sequence ()
31 CORBA::string_free (this->opname_);
32 this->opname_ = 0;
35 const char *
36 Test_Bounded_Long_Sequence::opname () const
38 return this->opname_;
41 void
42 Test_Bounded_Long_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_Long_Seq);
49 req->invoke ();
51 const Param_Test::Bounded_Long_Seq *tmp;
52 req->return_value () >>= tmp;
53 this->ret_ = new Param_Test::Bounded_Long_Seq (*tmp);
55 CORBA::NamedValue_ptr arg2 =
56 req->arguments ()->item (1);
57 *arg2->value () >>= tmp;
58 this->inout_ = new Param_Test::Bounded_Long_Seq (*tmp);
60 CORBA::NamedValue_ptr arg3 =
61 req->arguments ()->item (2);
62 *arg3->value () >>= tmp;
63 this->out_ = new Param_Test::Bounded_Long_Seq (*tmp);
66 int
67 Test_Bounded_Long_Sequence::init_parameters (Param_Test_ptr)
69 // get some sequence length (32 in this case)
70 CORBA::ULong len = this->in_->maximum ();
72 // set the length of the sequence
73 this->in_->length (len);
74 this->inout_->length (len);
75 // now set each individual element
76 for (CORBA::ULong i=0; i < this->in_->maximum (); i++)
78 this->in_[i] = i;
79 this->inout_[i] = i+1; // different from in_
82 this->inout_->length (0);
83 this->out_->length (0);
84 this->ret_->length (0);
86 return 0;
89 int
90 Test_Bounded_Long_Sequence::reset_parameters ()
92 this->inout_ = new Param_Test::Bounded_Long_Seq; // delete the previous ones
93 this->out_ = new Param_Test::Bounded_Long_Seq;
94 this->ret_ = new Param_Test::Bounded_Long_Seq;
96 this->inout_->length (0);
97 this->out_->length (0);
98 this->ret_->length (0);
100 return 0;
104 Test_Bounded_Long_Sequence::run_sii_test (Param_Test_ptr objref)
108 Param_Test::Bounded_Long_Seq_out out (this->out_.out ());
109 this->ret_ = objref->test_bounded_long_sequence (this->in_.in (),
110 this->inout_.inout (),
111 out);
113 return 0;
115 catch (const CORBA::Exception& ex)
117 ex._tao_print_exception ("Test_Bounded_Long_Sequence::run_sii_test\n");
119 return -1;
122 CORBA::Boolean
123 Test_Bounded_Long_Sequence::check_validity ()
125 CORBA::Boolean flag = 0;
126 if ((this->in_->length () == this->inout_->length ()) &&
127 (this->in_->length () == this->out_->length ()) &&
128 (this->in_->length () == this->ret_->length ()))
130 flag = 1; // assume all are equal
131 // lengths are same. Now compare the contents
132 for (CORBA::ULong i=0; i < this->in_->length () && flag; i++)
134 if (this->in_[i] != this->inout_[i] ||
135 this->in_[i] != this->out_[i] ||
136 this->in_[i] != this->ret_[i])
137 // not equal
138 flag = 0;
141 return flag;
144 CORBA::Boolean
145 Test_Bounded_Long_Sequence::check_validity (CORBA::Request_ptr req)
147 ACE_UNUSED_ARG (req);
148 return this->check_validity ();
151 void
152 Test_Bounded_Long_Sequence::print_values ()
154 CORBA::ULong i;
155 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
156 for (i=0; this->in_.ptr () && (i < this->in_->length ()); i++)
158 ACE_DEBUG ((LM_DEBUG,
159 "Element #%d\n"
160 "in : %d\n",
162 this->in_[i]));
164 if (!this->in_.ptr ())
165 ACE_DEBUG ((LM_DEBUG, "\nin sequence is NUL\n"));
166 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
167 for (i=0; this->inout_.ptr () && (i < this->inout_->length ()); i++)
169 ACE_DEBUG ((LM_DEBUG,
170 "Element #%d\n"
171 "in : %d\n",
173 this->inout_[i]));
175 if (!this->inout_.ptr ())
176 ACE_DEBUG ((LM_DEBUG, "\ninout sequence is NUL\n"));
177 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
178 for (i=0; this->out_.ptr () && (i < this->out_->length ()); i++)
180 ACE_DEBUG ((LM_DEBUG,
181 "Element #%d\n"
182 "in : %d\n",
184 this->out_[i]));
186 if (!this->out_.ptr ())
187 ACE_DEBUG ((LM_DEBUG, "\nout sequence is NUL\n"));
188 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
189 for (i=0; this->ret_.ptr () && (i < this->ret_->length ()); i++)
191 ACE_DEBUG ((LM_DEBUG,
192 "Element #%d\n"
193 "in : %d\n",
195 this->ret_[i]));
197 if (!this->ret_.ptr ())
198 ACE_DEBUG ((LM_DEBUG, "\nin sequence is NUL\n"));
199 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));