2 //=============================================================================
6 * tests bounded string sequences
8 * @author Aniruddha Gokhale
10 //=============================================================================
14 #include "bd_str_seq.h"
16 // ************************************************************************
17 // Test_Bounded_String_Sequence
18 // ************************************************************************
20 Test_Bounded_String_Sequence::Test_Bounded_String_Sequence (void)
21 : opname_ (CORBA::string_dup ("test_bounded_strseq")),
22 in_ (new Param_Test::Bounded_StrSeq
),
23 inout_ (new Param_Test::Bounded_StrSeq
),
24 out_ (new Param_Test::Bounded_StrSeq
),
25 ret_ (new Param_Test::Bounded_StrSeq
)
29 Test_Bounded_String_Sequence::~Test_Bounded_String_Sequence (void)
31 CORBA::string_free (this->opname_
);
36 Test_Bounded_String_Sequence::opname (void) const
42 Test_Bounded_String_Sequence::dii_req_invoke (CORBA::Request
*req
)
44 req
->add_in_arg ("s1") <<= this->in_
.in ();
45 req
->add_inout_arg ("s2") <<= this->inout_
.in ();
46 req
->add_out_arg ("s3") <<= this->out_
.in ();
48 req
->set_return_type (Param_Test::_tc_Bounded_StrSeq
);
52 const Param_Test::Bounded_StrSeq
*tmp
;
53 req
->return_value () >>= tmp
;
54 this->ret_
= new Param_Test::Bounded_StrSeq (*tmp
);
56 CORBA::NamedValue_ptr arg2
=
57 req
->arguments ()->item (1);
58 *arg2
->value () >>= tmp
;
59 this->inout_
= new Param_Test::Bounded_StrSeq (*tmp
);
61 CORBA::NamedValue_ptr arg3
=
62 req
->arguments ()->item (2);
63 *arg3
->value () >>= tmp
;
64 this->out_
= new Param_Test::Bounded_StrSeq (*tmp
);
68 Test_Bounded_String_Sequence::init_parameters (Param_Test_ptr
)
70 const char *choiceList
[] =
77 CORBA::ULong len
= this->in_
->maximum ();
79 // set the length of the sequence
80 this->in_
->length (len
);
81 this->inout_
->length (len
);
82 // now set each individual element
83 for (CORBA::ULong i
=0; i
< this->in_
->length (); i
++)
85 this->in_
[i
] = choiceList
[i
%3];
86 this->inout_
[i
] = choiceList
[(i
+1)%3]; // different from in_
92 Test_Bounded_String_Sequence::reset_parameters (void)
94 this->inout_
= new Param_Test::Bounded_StrSeq
; // delete the previous ones
95 this->out_
= new Param_Test::Bounded_StrSeq
;
96 this->ret_
= new Param_Test::Bounded_StrSeq
;
101 Test_Bounded_String_Sequence::run_sii_test (Param_Test_ptr objref
)
105 Param_Test::Bounded_StrSeq_out
out (this->out_
.out ());
107 this->ret_
= objref
->test_bounded_strseq (this->in_
.in (),
108 this->inout_
.inout (),
113 catch (const CORBA::Exception
& ex
)
115 ex
._tao_print_exception ("Test_Bounded_String_Sequence::run_sii_test\n");
122 Test_Bounded_String_Sequence::check_validity (void)
124 CORBA::Boolean flag
= 0;
125 if ((this->in_
->length () == this->inout_
->length ()) &&
126 (this->in_
->length () == this->out_
->length ()) &&
127 (this->in_
->length () == this->ret_
->length ()))
129 flag
= 1; // assume all are equal
130 // lengths are same. Now compare the contents
131 for (CORBA::ULong i
=0; i
< this->in_
->length () && flag
; i
++)
133 if (ACE_OS::strcmp(this->in_
[i
], this->inout_
[i
]) ||
134 ACE_OS::strcmp(this->in_
[i
], this->out_
[i
]) ||
135 ACE_OS::strcmp(this->in_
[i
], this->ret_
[i
]))
144 Test_Bounded_String_Sequence::check_validity (CORBA::Request_ptr
/*req*/)
146 //ACE_UNUSED_ARG (req);
147 return this->check_validity ();
151 Test_Bounded_String_Sequence::print_values (void)
154 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
155 for (i
=0; this->in_
.ptr () && (i
< this->in_
->length ()); i
++)
157 ACE_DEBUG ((LM_DEBUG
,
161 this->in_
[i
]? (const char *)this->in_
[i
]:"<nul>"));
163 if (!this->in_
.ptr ())
164 ACE_DEBUG ((LM_DEBUG
, "\nin sequence is NUL\n"));
165 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
166 for (i
=0; this->inout_
.ptr () && (i
< this->inout_
->length ()); i
++)
168 ACE_DEBUG ((LM_DEBUG
,
172 (this->inout_
[i
]? (const char *)this->inout_
[i
]:"<nul>")));
174 if (!this->inout_
.ptr ())
175 ACE_DEBUG ((LM_DEBUG
, "\ninout sequence is NUL\n"));
176 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
177 for (i
=0; this->out_
.ptr () && (i
< this->out_
->length ()); i
++)
179 ACE_DEBUG ((LM_DEBUG
,
183 (this->out_
[i
]? (const char *)this->out_
[i
]:"<nul>")));
185 if (!this->out_
.ptr ())
186 ACE_DEBUG ((LM_DEBUG
, "\nout sequence is NUL\n"));
187 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));
188 for (i
=0; this->ret_
.ptr () && (i
< this->ret_
->length ()); i
++)
190 ACE_DEBUG ((LM_DEBUG
,
194 (this->ret_
[i
]? (const char *)this->ret_
[i
]:"<nul>")));
196 if (!this->ret_
.ptr ())
197 ACE_DEBUG ((LM_DEBUG
, "\nin sequence is NUL\n"));
198 ACE_DEBUG ((LM_DEBUG
, "\n*=*=*=*=*=*=*=*=*=*=\n"));