2 //=============================================================================
6 * tests unbounded wide strings
8 * @author Jeff Parsons <parsons@cs.wustl.edu>
10 //=============================================================================
14 #include "ub_wstring.h"
15 #include "ace/OS_NS_wchar.h"
17 // ************************************************************************
18 // Test_Unbounded_WString
19 // ************************************************************************
21 Test_Unbounded_WString::Test_Unbounded_WString ()
22 : opname_ (CORBA::string_dup ("test_unbounded_wstring")),
30 Test_Unbounded_WString::~Test_Unbounded_WString ()
32 CORBA::string_free (this->opname_
);
33 CORBA::wstring_free (this->in_
);
34 CORBA::wstring_free (this->inout_
);
35 CORBA::wstring_free (this->out_
);
36 CORBA::wstring_free (this->ret_
);
45 Test_Unbounded_WString::opname () const
51 Test_Unbounded_WString::dii_req_invoke (CORBA::Request
*req
)
53 req
->add_in_arg ("s1") <<= this->in_
;
54 req
->add_inout_arg ("s2") <<= this->inout_
;
55 req
->add_out_arg ("s3") <<= this->out_
;
57 // The Any arg manages its memory but this class member does not.
58 CORBA::wstring_free (this->inout_
);
60 req
->set_return_type (CORBA::_tc_wstring
);
64 const CORBA::WChar
*tmp
;
65 req
->return_value () >>= tmp
;
66 this->ret_
= CORBA::wstring_dup (tmp
);
68 CORBA::NamedValue_ptr o2
=
69 req
->arguments ()->item (1);
70 *o2
->value () >>= tmp
;
71 this->inout_
= CORBA::wstring_dup (tmp
);
73 CORBA::NamedValue_ptr o3
=
74 req
->arguments ()->item (2);
75 *o3
->value () >>= tmp
;
76 this->out_
= CORBA::wstring_dup (tmp
);
80 Test_Unbounded_WString::init_parameters (Param_Test_ptr
)
82 Generator
*gen
= GENERATOR::instance (); // value generator
84 // release any previously occupied values
85 CORBA::wstring_free (this->in_
);
86 CORBA::wstring_free (this->inout_
);
87 CORBA::wstring_free (this->out_
);
88 CORBA::wstring_free (this->ret_
);
94 this->in_
= gen
->gen_wstring ();
95 this->inout_
= CORBA::wstring_dup (this->in_
);
100 Test_Unbounded_WString::reset_parameters ()
102 // release any previously occupied values
103 CORBA::wstring_free (this->inout_
);
104 CORBA::wstring_free (this->out_
);
105 CORBA::wstring_free (this->ret_
);
110 this->inout_
= CORBA::wstring_dup (this->in_
);
115 Test_Unbounded_WString::run_sii_test (Param_Test_ptr objref
)
119 CORBA::WString_out
str_out (this->out_
);
121 this->ret_
= objref
->test_unbounded_wstring (this->in_
,
127 catch (const CORBA::Exception
& ex
)
129 ex
._tao_print_exception ("Test_Unbounded_WString::run_sii_test\n");
135 Test_Unbounded_WString::check_validity ()
137 CORBA::ULong len
= ACE_OS::wslen (this->in_
);
139 if (!ACE_OS::wscmp (this->in_
, this->out_
) &&
140 !ACE_OS::wscmp (this->in_
, this->ret_
) &&
141 ACE_OS::wslen (this->inout_
) == 2*len
&&
142 !ACE_OS::wsncmp (this->in_
, this->inout_
, len
) &&
143 !ACE_OS::wsncmp (this->in_
, &this->inout_
[len
], len
))
146 return 0; // otherwise
150 Test_Unbounded_WString::check_validity (CORBA::Request_ptr
)
152 // No need to retrieve anything because, for all the args and
153 // the return, we provided the memory and we own it.
154 return this->check_validity ();
158 Test_Unbounded_WString::print_values ()