Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Param_Test / bd_wstr_seq.cpp
blob75f9cb78dc88e9b8bc73569c2ab508dc03cc4bb5
2 //=============================================================================
3 /**
4 * @file bd_wstr_seq.cpp
6 * tests bounded wide string sequences
8 * @author Jeff Parsons
9 */
10 //=============================================================================
13 #include "helper.h"
14 #include "bd_wstr_seq.h"
15 #include "ace/OS_NS_wchar.h"
17 // ************************************************************************
18 // Test_Bounded_WString_Sequence
19 // ************************************************************************
21 Test_Bounded_WString_Sequence::Test_Bounded_WString_Sequence ()
22 : opname_ (CORBA::string_dup ("test_bounded_wstrseq")),
23 in_ (new Param_Test::Bounded_WStrSeq),
24 inout_ (new Param_Test::Bounded_WStrSeq),
25 out_ (new Param_Test::Bounded_WStrSeq),
26 ret_ (new Param_Test::Bounded_WStrSeq)
30 Test_Bounded_WString_Sequence::~Test_Bounded_WString_Sequence ()
32 CORBA::string_free (this->opname_);
33 this->opname_ = 0;
36 const char *
37 Test_Bounded_WString_Sequence::opname () const
39 return this->opname_;
42 void
43 Test_Bounded_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 (Param_Test::_tc_Bounded_WStrSeq);
51 req->invoke ();
53 const Param_Test::Bounded_WStrSeq *tmp;
54 req->return_value () >>= tmp;
55 this->ret_ = new Param_Test::Bounded_WStrSeq (*tmp);
57 CORBA::NamedValue_ptr arg2 =
58 req->arguments ()->item (1);
59 *arg2->value () >>= tmp;
60 this->inout_ = new Param_Test::Bounded_WStrSeq (*tmp);
62 CORBA::NamedValue_ptr arg3 =
63 req->arguments ()->item (2);
64 *arg3->value () >>= tmp;
65 this->out_ = new Param_Test::Bounded_WStrSeq (*tmp);
68 int
69 Test_Bounded_WString_Sequence::init_parameters (Param_Test_ptr)
71 Generator *gen = GENERATOR::instance (); // value generator
73 CORBA::ULong len = this->in_->maximum ();
75 // set the length of the sequence
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 ();
84 // different from in_
85 this->inout_[i] = gen->gen_wstring ();
88 return 0;
91 int
92 Test_Bounded_WString_Sequence::reset_parameters ()
94 this->inout_ = new Param_Test::Bounded_WStrSeq; // delete the previous ones
95 this->out_ = new Param_Test::Bounded_WStrSeq;
96 this->ret_ = new Param_Test::Bounded_WStrSeq;
97 return 0;
101 Test_Bounded_WString_Sequence::run_sii_test (Param_Test_ptr objref)
105 Param_Test::Bounded_WStrSeq_out out (this->out_.out ());
107 this->ret_ = objref->test_bounded_wstrseq (this->in_.in (),
108 this->inout_.inout (),
109 out);
111 return 0;
113 catch (const CORBA::Exception& ex)
115 ex._tao_print_exception ("Test_Bounded_WString_Sequence::run_sii_test\n");
117 return -1;
120 CORBA::Boolean
121 Test_Bounded_WString_Sequence::check_validity ()
123 CORBA::Boolean flag = 0;
124 if ((this->in_->length () == this->inout_->length ()) &&
125 (this->in_->length () == this->out_->length ()) &&
126 (this->in_->length () == this->ret_->length ()))
128 flag = 1; // assume all are equal
129 // lengths are same. Now compare the contents
130 for (CORBA::ULong i=0; i < this->in_->length () && flag; i++)
132 if (ACE_OS::wscmp (this->in_[i], this->inout_[i]) ||
133 ACE_OS::wscmp (this->in_[i], this->out_[i]) ||
134 ACE_OS::wscmp (this->in_[i], this->ret_[i]))
135 // not equal
136 flag = 0;
139 return flag;
142 CORBA::Boolean
143 Test_Bounded_WString_Sequence::check_validity (CORBA::Request_ptr)
145 return this->check_validity ();
148 void
149 Test_Bounded_WString_Sequence::print_values ()