2 //=============================================================================
6 * tests bounded strings
8 * @author Carlos O'Ryan
10 //=============================================================================
14 #include "bd_string.h"
16 // ************************************************************************
17 // Test_Bounded_String
18 // ************************************************************************
20 Test_Bounded_String::Test_Bounded_String ()
21 : opname_ (CORBA::string_dup ("test_bounded_string")),
29 Test_Bounded_String::~Test_Bounded_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_Bounded_String::opname () const
50 Test_Bounded_String::dii_req_invoke (CORBA::Request
*req
)
52 req
->add_in_arg ("s1") <<= CORBA::Any::from_string (this->in_
, 128);
53 req
->add_inout_arg ("s2") <<= CORBA::Any::from_string (this->inout_
, 128);
54 req
->add_out_arg ("s3") <<= CORBA::Any::from_string (this->out_
, 128);
56 // The Any arg manages its memory but this class member does not.
57 CORBA::string_free (this->inout_
);
59 req
->set_return_type (Param_Test::_tc_short_string
);
64 req
->return_value () >>= CORBA::Any::to_string (tmp
, 128);
65 this->ret_
= CORBA::string_dup (tmp
);
67 CORBA::NamedValue_ptr arg2
=
68 req
->arguments ()->item (1);
69 *arg2
->value () >>= CORBA::Any::to_string (tmp
, 128);
70 this->inout_
= CORBA::string_dup (tmp
);
72 CORBA::NamedValue_ptr arg3
=
73 req
->arguments ()->item (2);
74 *arg3
->value () >>= CORBA::Any::to_string (tmp
, 128);
75 this->out_
= CORBA::string_dup (tmp
);
79 Test_Bounded_String::init_parameters (Param_Test_ptr
)
81 Generator
*gen
= GENERATOR::instance (); // value generator
83 // release any previously occupied values
84 CORBA::string_free (this->in_
);
85 CORBA::string_free (this->inout_
);
86 CORBA::string_free (this->out_
);
87 CORBA::string_free (this->ret_
);
93 this->in_
= gen
->gen_string (32);
94 this->inout_
= CORBA::string_dup (this->in_
);
99 Test_Bounded_String::reset_parameters ()
101 // release any previously occupied values
102 CORBA::string_free (this->inout_
);
103 CORBA::string_free (this->out_
);
104 CORBA::string_free (this->ret_
);
109 this->inout_
= CORBA::string_dup (this->in_
);
114 Test_Bounded_String::run_sii_test (Param_Test_ptr objref
)
118 CORBA::String_out
str_out (this->out_
);
120 this->ret_
= objref
->test_bounded_string (this->in_
,
126 catch (const CORBA::Exception
& ex
)
128 ex
._tao_print_exception ("Test_Bounded_String::run_sii_test\n");
134 Test_Bounded_String::check_validity ()
136 CORBA::ULong len
= ACE_OS::strlen (this->in_
);
138 if (!ACE_OS::strcmp (this->in_
, this->out_
) &&
139 !ACE_OS::strcmp (this->in_
, this->ret_
) &&
140 ACE_OS::strlen (this->inout_
) == 2*len
&&
141 !ACE_OS::strncmp (this->in_
, this->inout_
, len
) &&
142 !ACE_OS::strncmp (this->in_
, &this->inout_
[len
], len
))
145 return 0; // otherwise
149 Test_Bounded_String::check_validity (CORBA::Request_ptr
)
151 // No need to retrieve anything because, for all the args and
152 // the return, we provided the memory and we own it.
153 return this->check_validity ();
157 Test_Bounded_String::print_values ()
159 ACE_DEBUG ((LM_DEBUG
,
161 "in with len (%d) = %C\n"
162 "inout with len (%d) = %C\n"
163 "out with len (%d) = %C\n"
164 "ret with len (%d) = %C\n"
166 (this->in_
? ACE_OS::strlen (this->in_
):0),
167 (this->in_
? this->in_
:"<nul string>"),
168 (this->inout_
? ACE_OS::strlen (this->inout_
):0),
169 (this->inout_
? this->inout_
:"<nul string>"),
170 (this->out_
? ACE_OS::strlen (this->out_
):0),
171 (this->out_
? this->out_
:"<nul string>"),
172 (this->ret_
? ACE_OS::strlen (this->ret_
):0),
173 (this->ret_
? this->ret_
:"<nul string>")));