2 //=============================================================================
6 * tests bounded wide strings
10 //=============================================================================
14 #include "bd_wstring.h"
15 #include "ace/OS_NS_wchar.h"
17 // ************************************************************************
18 // Test_Bounded_WString
19 // ************************************************************************
21 Test_Bounded_WString::Test_Bounded_WString ()
22 : opname_ (CORBA::string_dup ("test_bounded_wstring")),
30 Test_Bounded_WString::~Test_Bounded_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_Bounded_WString::opname () const
51 Test_Bounded_WString::dii_req_invoke (CORBA::Request
*req
)
53 req
->add_in_arg ("s1") <<= CORBA::Any::from_wstring (this->in_
, 128);
54 req
->add_inout_arg ("s2") <<= CORBA::Any::from_wstring (this->inout_
, 128);
55 req
->add_out_arg ("s3") <<= CORBA::Any::from_wstring (this->out_
, 128);
57 // The Any arg manages its memory but this class member does not.
58 CORBA::wstring_free (this->inout_
);
60 req
->set_return_type (Param_Test::_tc_short_wstring
);
65 req
->return_value () >>= CORBA::Any::to_wstring (tmp
, 128);
66 this->ret_
= CORBA::wstring_dup (tmp
);
68 CORBA::NamedValue_ptr arg2
=
69 req
->arguments ()->item (1);
70 *arg2
->value () >>= CORBA::Any::to_wstring (tmp
, 128);
71 this->inout_
= CORBA::wstring_dup (tmp
);
73 CORBA::NamedValue_ptr arg3
=
74 req
->arguments ()->item (2);
75 *arg3
->value () >>= CORBA::Any::to_wstring (tmp
, 128);
76 this->out_
= CORBA::wstring_dup (tmp
);
80 Test_Bounded_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 (32);
95 this->inout_
= CORBA::wstring_dup (this->in_
);
100 Test_Bounded_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_Bounded_WString::run_sii_test (Param_Test_ptr objref
)
119 CORBA::WString_out
str_out (this->out_
);
121 this->ret_
= objref
->test_bounded_wstring (this->in_
,
127 catch (const CORBA::Exception
& ex
)
129 ex
._tao_print_exception ("Test_Bounded_WString::run_sii_test\n");
135 Test_Bounded_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_Bounded_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_Bounded_WString::print_values ()