Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / Alt_Mapping / ub_string.cpp
blobb71967dca0f5f91b612eb97235e559bd73526812
2 //=============================================================================
3 /**
4 * @file ub_string.cpp
6 * tests unbounded strings
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
13 #include "helper.h"
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"))
25 Test_Unbounded_String::~Test_Unbounded_String ()
27 CORBA::string_free (this->opname_);
28 this->opname_ = 0;
31 const char *
32 Test_Unbounded_String::opname () const
34 return this->opname_;
37 int
38 Test_Unbounded_String::init_parameters (Alt_Mapping_ptr)
40 Generator *gen = GENERATOR::instance (); // value generator
42 this->in_ = gen->gen_string ();
43 this->inout_ = this->in_.c_str ();
45 return 0;
48 int
49 Test_Unbounded_String::reset_parameters ()
51 this->inout_ = this->in_.c_str ();
52 this->out_.clear ();
53 this->ret_.clear ();
55 return 0;
58 int
59 Test_Unbounded_String::run_sii_test (Alt_Mapping_ptr objref)
61 try
63 this->ret_ = objref->test_unbounded_string (this->in_,
64 this->inout_,
65 this->out_);//str_out);
67 return 0;
69 catch (const CORBA::Exception& ex)
71 ex._tao_print_exception ("Test_Unbounded_String::run_sii_test\n");
74 return -1;
77 CORBA::Boolean
78 Test_Unbounded_String::check_validity ()
80 CORBA::ULong len = this->in_.length ();
82 std::string first_half = this->inout_.substr (0, len);
83 std::string second_half = this->inout_.substr (len, len);
85 return (this->in_ == this->out_
86 && this->in_ == this->ret_
87 && this->inout_.length () == 2 * len
88 && this->in_ == first_half
89 && this->in_ == second_half);
92 CORBA::Boolean
93 Test_Unbounded_String::check_validity (CORBA::Request_ptr )
95 // No need to retrieve anything because, for all the args and
96 // the return, we provided the memory and we own it.
97 return this->check_validity ();
100 void
101 Test_Unbounded_String::print_values ()
103 ACE_DEBUG ((LM_DEBUG,
104 "\n=*=*=*=*=*=*\n"
105 "in with len (%d) = %s\n"
106 "inout with len (%d) = %s\n"
107 "out with len (%d) = %s\n"
108 "ret with len (%d) = %s\n"
109 "\n=*=*=*=*=*=*\n",
110 this->in_.length (),
111 this->in_.c_str (),
112 this->inout_.length (),
113 this->inout_.c_str (),
114 this->out_.length (),
115 this->out_.c_str (),
116 this->ret_.length (),
117 this->ret_.c_str ()));