2 //=============================================================================
6 * tests unbounded strings
8 * @author Aniruddha Gokhale
10 //=============================================================================
14 #include "ub_string.h"
16 // ************************************************************************
17 // Test_Unbounded_String
18 // ************************************************************************
20 Test_Unbounded_String::Test_Unbounded_String ()
21 : opname_ (CORBA::string_dup ("test_unbounded_string")),
29 Test_Unbounded_String::~Test_Unbounded_String ()
31 CORBA::string_free (this->opname_
);
32 CORBA::string_free (this->in_
);
33 CORBA::string_free (this->inout_
);
34 CORBA::string_free (this->out_
);
35 CORBA::string_free (this->ret_
);
44 Test_Unbounded_String::opname () const
50 Test_Unbounded_String::dii_req_invoke (CORBA::Request
*req
)
52 req
->add_in_arg ("s1") <<= this->in_
;
53 req
->add_inout_arg ("s2") <<= this->inout_
;
54 req
->add_out_arg ("s3") <<= this->out_
;
56 // The Any arg manages its memory but this class member does not.
57 CORBA::string_free (this->inout_
);
59 req
->set_return_type (CORBA::_tc_string
);
64 req
->return_value () >>= tmp
;
65 this->ret_
= CORBA::string_dup (tmp
);
67 CORBA::NamedValue_ptr o2
=
68 req
->arguments ()->item (1);
69 *o2
->value () >>= tmp
;
70 this->inout_
= CORBA::string_dup (tmp
);
72 CORBA::NamedValue_ptr o3
=
73 req
->arguments ()->item (2);
74 *o3
->value () >>= tmp
;
75 this->out_
= CORBA::string_dup (tmp
);
79 Test_Unbounded_String::init_parameters (Param_Test_ptr
)
81 Generator
*gen
= GENERATOR::instance (); // value generator
84 // release any previously occupied values
85 CORBA::string_free (this->in_
);
86 CORBA::string_free (this->inout_
);
87 CORBA::string_free (this->out_
);
88 CORBA::string_free (this->ret_
);
94 this->in_
= gen
->gen_string ();
95 this->inout_
= CORBA::string_dup (this->in_
);
100 Test_Unbounded_String::reset_parameters ()
102 // release any previously occupied values
103 CORBA::string_free (this->inout_
);
104 CORBA::string_free (this->out_
);
105 CORBA::string_free (this->ret_
);
110 this->inout_
= CORBA::string_dup (this->in_
);
115 Test_Unbounded_String::run_sii_test (Param_Test_ptr objref
)
119 CORBA::String_out
str_out (this->out_
);
121 this->ret_
= objref
->test_unbounded_string (this->in_
,
127 catch (const CORBA::Exception
& ex
)
129 ex
._tao_print_exception ("Test_Unbounded_String::run_sii_test\n");
135 Test_Unbounded_String::check_validity ()
137 CORBA::ULong len
= ACE_OS::strlen (this->in_
);
139 if (!ACE_OS::strcmp (this->in_
, this->out_
) &&
140 !ACE_OS::strcmp (this->in_
, this->ret_
) &&
141 ACE_OS::strlen (this->inout_
) == 2*len
&&
142 !ACE_OS::strncmp (this->in_
, this->inout_
, len
) &&
143 !ACE_OS::strncmp (this->in_
, &this->inout_
[len
], len
))
146 return 0; // otherwise
150 Test_Unbounded_String::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_String::print_values ()
160 ACE_DEBUG ((LM_DEBUG
,
162 "in with len (%d) = %C\n"
163 "inout with len (%d) = %C\n"
164 "out with len (%d) = %C\n"
165 "ret with len (%d) = %C\n"
167 (this->in_
? ACE_OS::strlen (this->in_
):0),
168 (this->in_
? this->in_
:"<nul string>"),
169 (this->inout_
? ACE_OS::strlen (this->inout_
):0),
170 (this->inout_
? this->inout_
:"<nul string>"),
171 (this->out_
? ACE_OS::strlen (this->out_
):0),
172 (this->out_
? this->out_
:"<nul string>"),
173 (this->ret_
? ACE_OS::strlen (this->ret_
):0),
174 (this->ret_
? this->ret_
:"<nul string>")));