Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Param_Test / ub_wstr_seq.cpp
blob732dfa60d43e895785c4df0a2f266f14e10db153
2 //=============================================================================
3 /**
4 * @file ub_wstr_seq.cpp
6 * tests unbounded wide string sequences
8 * @author Jeff Parsons
9 */
10 //=============================================================================
13 #include "helper.h"
14 #include "ub_wstr_seq.h"
15 #include "ace/OS_NS_wchar.h"
17 // ************************************************************************
18 // Test_WString_Sequence
19 // ************************************************************************
21 Test_WString_Sequence::Test_WString_Sequence ()
22 : opname_ (CORBA::string_dup ("test_wstrseq")),
23 in_ (new CORBA::WStringSeq),
24 inout_ (new CORBA::WStringSeq),
25 out_ (new CORBA::WStringSeq),
26 ret_ (new CORBA::WStringSeq)
30 Test_WString_Sequence::~Test_WString_Sequence ()
32 CORBA::string_free (this->opname_);
33 this->opname_ = 0;
36 const char *
37 Test_WString_Sequence::opname () const
39 return this->opname_;
42 void
43 Test_WString_Sequence::dii_req_invoke (CORBA::Request *req)
45 req->add_in_arg ("s1") <<= this->in_.in ();
46 req->add_inout_arg ("s2") <<= this->inout_.in ();
47 req->add_out_arg ("s3") <<= this->out_.in ();
49 req->set_return_type (CORBA::_tc_WStringSeq);
51 req->invoke ();
53 const CORBA::WStringSeq *tmp = 0;
54 req->return_value () >>= tmp;
55 this->ret_ = new CORBA::WStringSeq (*tmp);
57 CORBA::NamedValue_ptr o2 =
58 req->arguments ()->item (1);
59 *o2->value () >>= tmp;
60 this->inout_ = new CORBA::WStringSeq (*tmp);
62 CORBA::NamedValue_ptr o3 =
63 req->arguments ()->item (2);
64 *o3->value () >>= tmp;
65 this->out_ = new CORBA::WStringSeq (*tmp);
68 int
69 Test_WString_Sequence::init_parameters (Param_Test_ptr)
71 Generator *gen = GENERATOR::instance (); // value generator
73 CORBA::ULong len = 2;
75 // set the length of the sequences
76 this->in_->length (len);
77 this->inout_->length (len);
79 // now set each individual element
80 for (CORBA::ULong i = 0; i < this->in_->length (); i++)
82 this->in_[i] = gen->gen_wstring ();
83 this->inout_[i] = gen->gen_wstring ();
86 return 0;
89 int
90 Test_WString_Sequence::reset_parameters ()
92 this->inout_ = new CORBA::WStringSeq; // delete the previous ones
93 this->out_ = new CORBA::WStringSeq;
94 this->ret_ = new CORBA::WStringSeq;
95 return 0;
98 int
99 Test_WString_Sequence::run_sii_test (Param_Test_ptr objref)
103 CORBA::WStringSeq_out out (this->out_.out ());
105 this->ret_ = objref->test_wstrseq (this->in_.in (),
106 this->inout_.inout (),
107 out);
109 return 0;
111 catch (const CORBA::Exception& ex)
113 ex._tao_print_exception ("Test_WString_Sequence::run_sii_test\n");
115 return -1;
118 CORBA::Boolean
119 Test_WString_Sequence::check_validity ()
121 CORBA::Boolean flag = 0;
122 if ((this->in_->length () == this->inout_->length ()) &&
123 (this->in_->length () == this->out_->length ()) &&
124 (this->in_->length () == this->ret_->length ()))
126 flag = 1; // assume all are equal
127 // lengths are same. Now compare the contents
128 for (CORBA::ULong i=0; i < this->in_->length () && flag; i++)
130 if (ACE_OS::wscmp (this->in_[i], this->inout_[i]) ||
131 ACE_OS::wscmp (this->in_[i], this->out_[i]) ||
132 ACE_OS::wscmp (this->in_[i], this->ret_[i]))
133 // not equal
134 flag = 0;
137 return flag;
140 CORBA::Boolean
141 Test_WString_Sequence::check_validity (CORBA::Request_ptr )
143 return this->check_validity ();
146 void
147 Test_WString_Sequence::print_values ()