summaryrefslogtreecommitdiff
path: root/TAO/tests/Alt_Mapping/ub_string.cpp
blob: a1cb328c8a534c052b9c08ee5e26295675c524ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

//=============================================================================
/**
 *  @file    ub_string.cpp
 *
 *  tests unbounded strings
 *
 *  @author   Aniruddha Gokhale
 */
//=============================================================================


#include "helper.h"
#include "ub_string.h"

// ************************************************************************
//               Test_Unbounded_String
// ************************************************************************

Test_Unbounded_String::Test_Unbounded_String (void)
  : opname_ (CORBA::string_dup ("test_unbounded_string"))
{
}

Test_Unbounded_String::~Test_Unbounded_String (void)
{
  CORBA::string_free (this->opname_);
  this->opname_ = 0;
}

const char *
Test_Unbounded_String::opname () const
{
  return this->opname_;
}

int
Test_Unbounded_String::init_parameters (Alt_Mapping_ptr)
{
  Generator *gen = GENERATOR::instance (); // value generator

  this->in_ = gen->gen_string ();
  this->inout_ = this->in_.c_str ();

  return 0;
}

int
Test_Unbounded_String::reset_parameters (void)
{
  this->inout_ = this->in_.c_str ();
  this->out_.clear ();
  this->ret_.clear ();

  return 0;
}

int
Test_Unbounded_String::run_sii_test (Alt_Mapping_ptr objref)
{
  try
    {
      this->ret_ = objref->test_unbounded_string (this->in_,
                                                  this->inout_,
                                                  this->out_);//str_out);

      return 0;
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Test_Unbounded_String::run_sii_test\n");
    }

  return -1;
}

CORBA::Boolean
Test_Unbounded_String::check_validity (void)
{
  CORBA::ULong len = this->in_.length ();

  std::string first_half = this->inout_.substr (0, len);
  std::string second_half = this->inout_.substr (len, len);

  return (this->in_ == this->out_
          && this->in_ == this->ret_
          && this->inout_.length () == 2 * len
          && this->in_ == first_half
          && this->in_ == second_half);
}

CORBA::Boolean
Test_Unbounded_String::check_validity (CORBA::Request_ptr )
{
  // No need to retrieve anything because, for all the args and
  // the return, we provided the memory and we own it.
  return this->check_validity ();
}

void
Test_Unbounded_String::print_values (void)
{
  ACE_DEBUG ((LM_DEBUG,
              "\n=*=*=*=*=*=*\n"
              "in with len (%d) = %s\n"
              "inout with len (%d) = %s\n"
              "out with len (%d) = %s\n"
              "ret with len (%d) = %s\n"
              "\n=*=*=*=*=*=*\n",
              this->in_.length (),
              this->in_.c_str (),
              this->inout_.length (),
              this->inout_.c_str (),
              this->out_.length (),
              this->out_.c_str (),
              this->ret_.length (),
              this->ret_.c_str ()));
}