Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Param_Test / ub_str_seq.cpp
blob979ee4d1ff24533d3a245302ee12e999a869a77c
2 //=============================================================================
3 /**
4 * @file ub_str_seq.cpp
6 * tests unbounded string sequences
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
13 #include "helper.h"
14 #include "ub_str_seq.h"
16 // ************************************************************************
17 // Test_String_Sequence
18 // ************************************************************************
20 Test_String_Sequence::Test_String_Sequence ()
21 : opname_ (CORBA::string_dup ("test_strseq")),
22 in_ (new CORBA::StringSeq),
23 inout_ (new CORBA::StringSeq),
24 out_ (new CORBA::StringSeq),
25 ret_ (new CORBA::StringSeq)
29 Test_String_Sequence::~Test_String_Sequence ()
31 CORBA::string_free (this->opname_);
32 this->opname_ = 0;
35 const char *
36 Test_String_Sequence::opname () const
38 return this->opname_;
41 void
42 Test_String_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 ();
48 req->set_return_type (CORBA::_tc_StringSeq);
50 req->invoke ();
52 const CORBA::StringSeq *tmp = 0;
53 req->return_value () >>= tmp;
54 this->ret_ = new CORBA::StringSeq (*tmp);
56 CORBA::NamedValue_ptr o2 =
57 req->arguments ()->item (1);
58 *o2->value () >>= tmp;
59 this->inout_ = new CORBA::StringSeq (*tmp);
61 CORBA::NamedValue_ptr o3 =
62 req->arguments ()->item (2);
63 *o3->value () >>= tmp;
64 this->out_ = new CORBA::StringSeq (*tmp);
67 int
68 Test_String_Sequence::init_parameters (Param_Test_ptr)
70 const char *choiceList[] =
72 "one",
73 "two",
74 "three",
75 "four"
78 CORBA::ULong len = sizeof(choiceList)/sizeof(char *) - 1;
80 // set the length of the sequences
81 this->in_->length (len);
82 this->inout_->length (len);
84 // now set each individual element
85 for (CORBA::ULong i=0; i < this->in_->length (); i++)
87 this->in_[i] = choiceList[i];
88 this->inout_[i] = choiceList[i+1];
90 return 0;
93 int
94 Test_String_Sequence::reset_parameters ()
96 this->inout_ = new CORBA::StringSeq; // delete the previous ones
97 this->out_ = new CORBA::StringSeq;
98 this->ret_ = new CORBA::StringSeq;
99 return 0;
103 Test_String_Sequence::run_sii_test (Param_Test_ptr objref)
107 CORBA::StringSeq_out out (this->out_.out ());
109 this->ret_ = objref->test_strseq (this->in_.in (),
110 this->inout_.inout (),
111 out);
113 return 0;
115 catch (const CORBA::Exception& ex)
117 ex._tao_print_exception ("Test_String_Sequence::run_sii_test\n");
119 return -1;
122 CORBA::Boolean
123 Test_String_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 (ACE_OS::strcmp(this->in_[i], this->inout_[i]) ||
135 ACE_OS::strcmp(this->in_[i], this->out_[i]) ||
136 ACE_OS::strcmp(this->in_[i], this->ret_[i]))
137 // not equal
138 flag = 0;
141 return flag;
144 CORBA::Boolean
145 Test_String_Sequence::check_validity (CORBA::Request_ptr )
147 return this->check_validity ();
150 void
151 Test_String_Sequence::print_values ()
153 CORBA::ULong i;
154 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
155 for (i=0; this->in_.ptr () && (i < this->in_->length ()); i++)
157 ACE_DEBUG ((LM_DEBUG,
158 "Element #%d\n"
159 "in : %C\n",
161 this->in_[i]? (const char *)this->in_[i]:"<nul>"));
163 if (!this->in_.ptr ())
164 ACE_DEBUG ((LM_DEBUG, "\nin sequence is NUL\n"));
165 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
166 for (i=0; this->inout_.ptr () && (i < this->inout_->length ()); i++)
168 ACE_DEBUG ((LM_DEBUG,
169 "Element #%d\n"
170 "in : %C\n",
172 (this->inout_[i]? (const char *)this->inout_[i]:"<nul>")));
174 if (!this->inout_.ptr ())
175 ACE_DEBUG ((LM_DEBUG, "\ninout sequence is NUL\n"));
176 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
177 for (i=0; this->out_.ptr () && (i < this->out_->length ()); i++)
179 ACE_DEBUG ((LM_DEBUG,
180 "Element #%d\n"
181 "in : %C\n",
183 (this->out_[i]? (const char *)this->out_[i]:"<nul>")));
185 if (!this->out_.ptr ())
186 ACE_DEBUG ((LM_DEBUG, "\nout sequence is NUL\n"));
187 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));
188 for (i=0; this->ret_.ptr () && (i < this->ret_->length ()); i++)
190 ACE_DEBUG ((LM_DEBUG,
191 "Element #%d\n"
192 "in : %C\n",
194 (this->ret_[i]? (const char *)this->ret_[i]:"<nul>")));
196 if (!this->ret_.ptr ())
197 ACE_DEBUG ((LM_DEBUG, "\nin sequence is NUL\n"));
198 ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n"));