2 //=============================================================================
6 * tests unbounded string sequences
8 * @author Aniruddha Gokhale
10 //=============================================================================
14 #include "ub_str_seq.h"
16 // ************************************************************************
17 // Test_String_Sequence
18 // ************************************************************************
20 Test_String_Sequence::Test_String_Sequence ()
21 : opname_ (CORBA::string_dup ("test_strseq")),
22 in_ (new CORBA::StringSeq
),
23 inout_ (new CORBA::StringSeq
),
24 out_ (new CORBA::StringSeq
),
25 ret_ (new CORBA::StringSeq
)
29 Test_String_Sequence::~Test_String_Sequence ()
31 CORBA::string_free (this->opname_
);
36 Test_String_Sequence::opname () const
42 Test_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 (CORBA::_tc_StringSeq
);
52 const CORBA::StringSeq
*tmp
= 0;
53 req
->return_value () >>= tmp
;
54 this->ret_
= new CORBA::StringSeq (*tmp
);
56 CORBA::NamedValue_ptr o2
=
57 req
->arguments ()->item (1);
58 *o2
->value () >>= tmp
;
59 this->inout_
= new CORBA::StringSeq (*tmp
);
61 CORBA::NamedValue_ptr o3
=
62 req
->arguments ()->item (2);
63 *o3
->value () >>= tmp
;
64 this->out_
= new CORBA::StringSeq (*tmp
);
68 Test_String_Sequence::init_parameters (Param_Test_ptr
)
70 const char *choiceList
[] =
78 CORBA::ULong len
= sizeof(choiceList
)/sizeof(char *) - 1;
80 // set the length of the sequences
81 this->in_
->length (len
);
82 this->inout_
->length (len
);
84 // now set each individual element
85 for (CORBA::ULong i
=0; i
< this->in_
->length (); i
++)
87 this->in_
[i
] = choiceList
[i
];
88 this->inout_
[i
] = choiceList
[i
+1];
94 Test_String_Sequence::reset_parameters ()
96 this->inout_
= new CORBA::StringSeq
; // delete the previous ones
97 this->out_
= new CORBA::StringSeq
;
98 this->ret_
= new CORBA::StringSeq
;
103 Test_String_Sequence::run_sii_test (Param_Test_ptr objref
)
107 CORBA::StringSeq_out
out (this->out_
.out ());
109 this->ret_
= objref
->test_strseq (this->in_
.in (),
110 this->inout_
.inout (),
115 catch (const CORBA::Exception
& ex
)
117 ex
._tao_print_exception ("Test_String_Sequence::run_sii_test\n");
123 Test_String_Sequence::check_validity ()
125 CORBA::Boolean flag
= 0;
126 if ((this->in_
->length () == this->inout_
->length ()) &&
127 (this->in_
->length () == this->out_
->length ()) &&
128 (this->in_
->length () == this->ret_
->length ()))
130 flag
= 1; // assume all are equal
131 // lengths are same. Now compare the contents
132 for (CORBA::ULong i
=0; i
< this->in_
->length () && flag
; i
++)
134 if (ACE_OS::strcmp(this->in_
[i
], this->inout_
[i
]) ||
135 ACE_OS::strcmp(this->in_
[i
], this->out_
[i
]) ||
136 ACE_OS::strcmp(this->in_
[i
], this->ret_
[i
]))
145 Test_String_Sequence::check_validity (CORBA::Request_ptr
)
147 return this->check_validity ();
151 Test_String_Sequence::print_values ()
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"));