2 //=============================================================================
6 * @author Carlos O'Ryan
8 //=============================================================================
11 #include "param_testC.h"
13 #include "tao/debug.h"
14 #include "ace/OS_NS_string.h"
16 // Not normally needed, but we create an object reference in this test,
17 // and we have to narrow it.
18 #include "tao/Object_T.h"
20 #include "ace/Get_Opt.h"
23 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
29 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
31 ACE_Get_Opt
get_opt (argc
, argv
, ACE_TEXT("dn:"));
34 while ((opt
= get_opt ()) != EOF
)
42 n
= ACE_OS::atoi (get_opt
.opt_arg ());
56 for (int i
= 0; i
!= n
; ++i
)
61 Param_Test::Var_Array var_array
;
62 any
<<= Param_Test::Var_Array_forany (var_array
);
64 Param_Test::Var_Array_forany forany
;
66 if (!(any
>>= forany
))
69 "Failure for Param_Test::Var_Array\n"));
71 Param_Test::Var_Array_var var
=
72 Param_Test::Var_Array_dup (forany
.in ());
73 any
<<= Param_Test::Var_Array_forany (var
.inout ());
75 if (!(any
>>= forany
))
78 "Failure for Param_Test::Var_Array[2]\n"));
83 CORBA::Object_var obj
=
84 orb
->string_to_object ("corbaloc:iiop:localhost:1234/Foo/Bar");
86 Param_Test_var param_test
=
87 TAO::Narrow_Utils
<Param_Test
>::unchecked_narrow (obj
.in ());
88 TAO_Stub
*stub
= param_test
->_stubobj ();
89 stub
->type_id
= CORBA::string_dup ("IDL:Param_Test:1.0");
91 any
<<= param_test
.in ();
98 "Cannot extract Param_Test (oh the horror)\n"));
100 CORBA::Boolean equiv
=
101 param_test
->_is_equivalent (o
);
105 ACE_DEBUG ((LM_DEBUG
,
106 "Mismatched Param_Test extraction\n"));
109 CORBA::Object_var other
;
111 if (!(any
>>= CORBA::Any::to_object (other
.inout ())))
113 ACE_DEBUG ((LM_DEBUG
,
114 "Cannot extract Param_Test as Object\n"));
119 CORBA::Short i
= 123;
127 ACE_DEBUG ((LM_DEBUG
,
128 "Failure for CORBA::Short (%d,%d)\n",
142 ACE_DEBUG ((LM_DEBUG
,
143 "Failure for CORBA::Long (%d,%d)\n",
149 CORBA::ULongLong i
= 123;
157 ACE_DEBUG ((LM_DEBUG
,
158 "Failure for CORBA::ULongLong (%Q,%Q)\n",
164 CORBA::Double i
= 123;
169 if (!(any
>>= o
) || !ACE::is_equal (i
, o
))
171 ACE_DEBUG ((LM_DEBUG
,
172 "Failure for CORBA::Double (%f,%f)\n",
183 *i
<<= CORBA::Short (123);
193 ACE_DEBUG ((LM_DEBUG
,
194 "Failure for CORBA::Any "
195 "(copying insertion, %d)\n",
205 ACE_DEBUG ((LM_DEBUG
,
206 "Failure for CORBA::Any "
207 "(non-copying insertion, %d)\n",
213 const char i
[] = "123";
219 || ACE_OS::strcmp (i
, o
) != 0)
221 ACE_DEBUG ((LM_DEBUG
,
222 "Failure for char* (%C,%C)\n",
230 Param_Test::Fixed_Struct
*i
= 0;
232 Param_Test::Fixed_Struct
,
243 const Param_Test::Fixed_Struct
*o
= 0;
250 || !ACE::is_equal (o
->f
, i
->f
)
252 || !ACE::is_equal (o
->d
, i
->d
))
254 ACE_DEBUG ((LM_DEBUG
,
255 "Failure for Fixed_Struct "
256 "(copying insertion)\n"));
266 || !ACE::is_equal (o
->f
, i
->f
)
268 || !ACE::is_equal (o
->d
, i
->d
))
270 ACE_DEBUG ((LM_DEBUG
,
271 "Failure for Fixed_Struct "
272 "(non-copying insertion)\n"));
277 CORBA::ULong len
= 3;
279 CORBA::LongSeq
*i
= 0;
281 CORBA::LongSeq (len
),
285 for (CORBA::ULong k
= 0; k
< len
; ++k
)
291 const CORBA::LongSeq
*o
= 0;
294 || (*i
)[0] != (*o
)[0]
295 || (*i
)[1] != (*o
)[1]
296 || (*i
)[2] != (*o
)[2])
298 ACE_DEBUG ((LM_DEBUG
,
299 "Failure for Long_Seq "
300 "(copying insertion)\n"));
306 || (*i
)[0] != (*o
)[0]
307 || (*i
)[1] != (*o
)[1]
308 || (*i
)[2] != (*o
)[2])
310 ACE_DEBUG ((LM_DEBUG
,
311 "Failure for Long_Seq "
312 "(non-copying insertion)\n"));
317 catch (const CORBA::Exception
& ex
)
319 ex
._tao_print_exception ("IDL Types");