Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / OBV / ValueBox / client.cpp
blob3536051e46401992b50e23b47c80f85108d20c4d
1 #include "valueboxC.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
6 int
7 parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'k':
16 ior = get_opts.optarg;
17 break;
19 case '?':
20 default:
21 ACE_ERROR_RETURN ((LM_ERROR,
22 "usage: %s "
23 "-k <ior> "
24 "\n",
25 argv [0]),
26 -1);
28 // Indicates successful parsing of the command line
29 return 0;
33 #define OBV_VERITY(Condition) \
34 { \
35 if ((Condition)==0) \
36 { \
37 fail++; \
38 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Failure at line %l\n")); \
39 } \
43 // Templated function for testing various aspects of valuetypes.
44 // valuebox is a type created by the user, with UT as the underlying type.
45 // It is assumed that, on entry, valuebox->_value() != val1, and that
46 // val1 and val2 are distinct.
48 template <class BoxT, class UT>
49 int box_test1 (BoxT *valuebox, UT val1, UT val2)
51 int fail = 0;
52 BoxT *valuebox_clone = 0;
53 ACE_NEW_RETURN (valuebox_clone,
54 BoxT (val1),
55 1);
57 // should be a deep copy of val1...
58 OBV_VERITY (&valuebox_clone->_boxed_inout () != &valuebox->_boxed_inout ());
60 // but values should be equal
61 OBV_VERITY (ACE::is_equal (valuebox_clone->_value (), valuebox->_value ()));
63 // Check that modifier is working.
64 valuebox_clone->_value (val2);
65 OBV_VERITY (!ACE::is_equal (valuebox_clone->_value (), valuebox->_value ()));
67 // use operator=
68 *valuebox = val2;
69 OBV_VERITY (ACE::is_equal (valuebox_clone->_value (), valuebox->_value ()));
71 // Check that _value and _boxed_in are the same.
72 OBV_VERITY (ACE::is_equal (valuebox_clone->_value (), valuebox_clone->_boxed_in ()));
73 OBV_VERITY (ACE::is_equal (valuebox->_value (), valuebox->_boxed_in ()));
75 // Used _boxed_inout to change the value
76 OBV_VERITY (!ACE::is_equal (valuebox->_value (), val1));
77 valuebox->_boxed_inout () = val1;
78 OBV_VERITY (ACE::is_equal (valuebox->_value (), val1));
80 // Use _boxed_out to access the value
81 OBV_VERITY (!ACE::is_equal (valuebox_clone->_value (), val1));
82 valuebox_clone->_boxed_out () = val1;
83 OBV_VERITY (ACE::is_equal (valuebox_clone->_value (), val1));
85 // Test _copy_value
86 CORBA::ValueBase *copy = valuebox->_copy_value ();
87 OBV_VERITY (copy != 0);
88 // check add_ref, remove_ref
89 copy->_add_ref ();
90 copy->_remove_ref ();
92 // try downcast...then we can check that copy was correct.
93 BoxT *down = BoxT::_downcast (copy);
94 if (down == 0)
96 fail++;
97 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Failure at line %l\n"));
99 else
101 OBV_VERITY (ACE::is_equal (down->_value (), val1));
102 down->_value (val2);
103 OBV_VERITY (!ACE::is_equal (down->_value (), valuebox->_value ()));
104 OBV_VERITY (ACE::is_equal (down->_value (), val2));
107 CORBA::remove_ref (copy);
109 // cleanup. Use purify on the PC to check for leaks.
110 CORBA::remove_ref (valuebox_clone);
112 return fail;
115 template <class BoxT, class UT>
116 int simple_box_test ()
118 int fail = 0;
119 BoxT *p = 0;
120 ACE_NEW_RETURN (p,
121 BoxT (101),
123 fail += box_test1<BoxT, UT> (p, 101, 202);
125 CORBA::remove_ref (p);
127 return fail;
131 // Test boxed values that use an underlying UT&
133 template <class BoxT, class UT>
134 int box_test_ref (BoxT *valuebox, UT &val1, UT &val2)
136 int fail = 0;
137 BoxT *p = 0;
138 ACE_NEW_RETURN (p,
139 BoxT (val1),
142 // should be a deep copy of val1...
143 OBV_VERITY (&p->_boxed_inout () != &valuebox->_boxed_inout ());
145 p->_value (val2); // deep copy
146 OBV_VERITY (&p->_boxed_inout () != &valuebox->_boxed_inout () );
148 *valuebox = val2; // deep copy, too.
149 OBV_VERITY (&p->_boxed_inout () != &valuebox->_boxed_inout () );
151 CORBA::remove_ref (p);
153 return fail;
156 int test_basic ()
158 int fail = 0;
160 // Basic types
161 fail += simple_box_test<VBshort, CORBA::Short> ();
162 fail += simple_box_test<VBlong, CORBA::Long> ();
163 fail += simple_box_test<VBlonglong, CORBA::LongLong> ();
164 fail += simple_box_test<VBushort, CORBA::UShort> ();
165 fail += simple_box_test<VBulong, CORBA::ULong> ();
166 fail += simple_box_test<VBulonglong, CORBA::ULongLong> ();
167 fail += simple_box_test<VBwchar, CORBA::WChar> ();
168 fail += simple_box_test<VBoctet, CORBA::Octet> ();
169 fail += simple_box_test<VBfloat, CORBA::Float> ();
170 fail += simple_box_test<VBdouble, CORBA::Double> ();
172 VBchar *pchar = 0;
173 ACE_NEW_RETURN (pchar,
174 VBchar ('A'),
176 fail += box_test1<VBchar, CORBA::Char> (pchar, 'A', 'Z');
177 CORBA::remove_ref (pchar);
179 VBboolean *pbool = 0;
180 ACE_NEW_RETURN (pbool,
181 VBboolean (true),
183 fail += box_test1<VBboolean, CORBA::Boolean> (pbool, true, false);
184 CORBA::remove_ref (pbool);
186 // Typedef of basic types
187 fail += simple_box_test<VBTDshort, CORBA::Short> ();
188 fail += simple_box_test<VBTDlong, CORBA::Long> ();
189 fail += simple_box_test<VBTDlonglong, CORBA::LongLong> ();
190 fail += simple_box_test<VBTDushort, CORBA::UShort> ();
191 fail += simple_box_test<VBTDulong, CORBA::ULong> ();
192 fail += simple_box_test<VBTDulonglong, CORBA::ULongLong> ();
193 fail += simple_box_test<VBTDwchar, CORBA::WChar> ();
194 fail += simple_box_test<VBTDoctet, CORBA::Octet> ();
195 fail += simple_box_test<VBTDfloat, CORBA::Float> ();
196 fail += simple_box_test<VBTDdouble, CORBA::Double> ();
198 VBTDchar *pchar2 = 0;
199 ACE_NEW_RETURN (pchar2,
200 VBTDchar ('A'),
202 fail += box_test1<VBTDchar, CORBA::Char> (pchar2, 'A', 'Z');
203 CORBA::remove_ref (pchar2);
205 VBTDboolean *pbool2 = 0;
206 ACE_NEW_RETURN (pbool2,
207 VBTDboolean (true),
209 fail += box_test1<VBTDboolean, CORBA::Boolean> (pbool2, true, false);
210 CORBA::remove_ref (pbool2);
212 // Enumerated type
213 VBenum *penum = 0;
214 ACE_NEW_RETURN (penum,
215 VBenum (yellow),
217 fail += box_test1<VBenum, Color> (penum, yellow, red);
218 CORBA::remove_ref (penum);
220 // Typedef of enumerated type
221 VBTDenum *penum2 = 0;
222 ACE_NEW_RETURN (penum2,
223 VBTDenum (yellow),
225 fail += box_test1<VBTDenum, Color> (penum2, yellow, red);
226 CORBA::remove_ref (penum2);
228 // Any
229 CORBA::Any *a1 = 0;
230 ACE_NEW_RETURN (a1,
231 CORBA::Any (),
233 CORBA::Any_var any1 (a1);
235 CORBA::Any *a2 = 0;
236 ACE_NEW_RETURN (a2,
237 CORBA::Any (),
239 CORBA::Any_var any2 (a2);
241 VBany *pany = 0;
242 ACE_NEW_RETURN (pany,
243 VBany (any1.in ()),
245 fail += box_test_ref<VBany, CORBA::Any> (pany, any1.inout (),
246 any2.inout ());
247 CORBA::remove_ref (pany);
249 // Typedef of Any
250 VBTDany *pany2 = 0;
251 ACE_NEW_RETURN (pany2,
252 VBTDany (any1.in ()),
254 fail += box_test_ref<VBTDany, CORBA::Any> (pany2, any1.inout (),
255 any2.inout ());
256 CORBA::remove_ref (pany2);
258 return fail;
261 int test_basic_invocations (Test * test_object)
263 int fail = 0;
265 VBlong *p1 = 0;
266 VBlong *p2 = 0;
267 VBlong *p3;
269 vb_basic::M_VBlong *mp1 = 0;
270 vb_basic::M_VBlong *mp2 = 0;
271 vb_basic::M_VBlong *mp3;
275 //============================================================
276 // Test method invocation with boxed value
277 //============================================================
279 ACE_NEW_RETURN (p1,
280 VBlong(25),
282 ACE_NEW_RETURN (p2,
283 VBlong(53),
286 OBV_VERITY (p1->_value () == 25);
287 OBV_VERITY (p2->_value () == 53);
289 VBlong_var result =
290 test_object->basic_op1(p1, p2, p3);
292 OBV_VERITY (p2->_value () == (53*3));
293 OBV_VERITY (p3->_value () == (53*5));
294 OBV_VERITY (result->_value () == (p1->_value () *3));
296 //============================================================
297 // Test method invocation with boxed value from nested module
298 //============================================================
300 ACE_NEW_RETURN (mp1,
301 vb_basic::M_VBlong(25),
304 ACE_NEW_RETURN (mp2,
305 vb_basic::M_VBlong(53),
308 OBV_VERITY (mp1->_value () == 25);
309 OBV_VERITY (mp2->_value () == 53);
311 vb_basic::M_VBlong_var mresult =
312 test_object->basic_op2(mp1, mp2, mp3);
314 OBV_VERITY (mp2->_value () == (53*3));
315 OBV_VERITY (mp3->_value () == (53*5));
316 OBV_VERITY (mresult->_value () == (mp1->_value () *3));
318 //============================================================
319 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
320 //============================================================
322 p1->_value(67);
323 p2->_value(93);
325 long lresult =
326 test_object->basic_op3(p1->_boxed_in(), p2->_boxed_inout(),
327 p3->_boxed_out());
329 OBV_VERITY (p2->_value () == (93*3));
330 OBV_VERITY (p3->_value () == (93*5));
331 OBV_VERITY (lresult == (p1->_value()*3));
333 catch (const CORBA::Exception& ex)
335 ex._tao_print_exception ("test_basic_invocations");
336 fail = 1;
338 catch (...)
340 ACE_DEBUG ((LM_DEBUG,
341 "(%P|%t) test_basic_invocations: caught a C++ exception\n"));
342 fail = 1;
344 if (p1) p1->_remove_ref ();
345 if (p2) p2->_remove_ref ();
346 if (p3) p3->_remove_ref ();
348 if (mp1) mp1->_remove_ref ();
349 if (mp2) mp2->_remove_ref ();
350 if (mp3) mp3->_remove_ref ();
352 return fail;
356 int test_boxed_string()
358 int fail = 0;
359 const char *string1 = "First-string";
360 const char *string2 = "Second-string";
362 // Establish that we have data setup correctly...
363 OBV_VERITY (ACE_OS::strcmp (string1, string2) < 0);
364 OBV_VERITY (ACE_OS::strcmp (string2, string1) > 0);
365 OBV_VERITY (ACE_OS::strcmp (string1, string1) == 0);
367 // Make some objects, using our data
368 VBstring *temp = 0;
369 ACE_NEW_RETURN (temp,
370 VBstring(string1),
372 VBstring_var vbstring1 (temp);
374 VBstring *vbstring2 = 0;
375 ACE_NEW_RETURN (vbstring2,
376 VBstring(string1), // tests const char * ctor.
379 OBV_VERITY (ACE_OS::strcmp (vbstring1->_value(), string1) == 0);
380 OBV_VERITY (ACE_OS::strcmp (vbstring2->_value(), string1) == 0);
382 // Test assignment operators
383 char *carray1 = 0;
384 ACE_NEW_RETURN (carray1,
385 char[15],
387 ACE_OS::memcpy(carray1, string2, ACE_OS::strlen(string2));
388 *vbstring2 = carray1; // char * (adopted by box)
389 OBV_VERITY ((*vbstring2)[0] == 'S');
390 *vbstring2 = string1;
391 OBV_VERITY ((*vbstring2)[0] == 'F');
392 CORBA::String_var svar(string2);
393 *vbstring2 = svar;
394 OBV_VERITY ((*vbstring2)[0] == 'S');
396 // Test _value modifiers--like assignment drill above.
397 char *carray2 = 0;
398 ACE_NEW_RETURN (carray2,
399 char[15],
401 ACE_OS::memcpy(carray2, string1, ACE_OS::strlen(string1));
402 vbstring2->_value(carray2); // char * (adopted by box)
403 OBV_VERITY ((*vbstring2)[0] == 'F');
404 vbstring2->_value(string2); // const char *
405 OBV_VERITY ((*vbstring2)[0] == 'S');
406 (*vbstring2)[0] = 'Y';
407 OBV_VERITY ((*vbstring2)[0] != 'S');
408 vbstring2->_value(svar);
409 OBV_VERITY ((*vbstring2)[0] == 'S');
410 // test value accessor
411 OBV_VERITY ((vbstring2->_value())[0] == 'S');
414 // Test ctors.
415 // const boxed string
416 VBstring *vbstring3 = 0;
417 ACE_NEW_RETURN (vbstring3,
418 VBstring(*vbstring2),
420 OBV_VERITY ((*vbstring3)[0] == 'S');
421 (*vbstring3)[0] = 'W';
422 OBV_VERITY ((*vbstring3)[0] == 'W' && (*vbstring2)[0] == 'S');
423 vbstring3->_remove_ref ();
426 // char *
427 char *carray3 = 0;
428 ACE_NEW_RETURN (carray3,
429 char[15],
431 ACE_OS::memcpy(carray3, string1, ACE_OS::strlen(string1));
432 VBstring *vbstring4 = 0;
433 ACE_NEW_RETURN (vbstring4,
434 VBstring(carray3),
436 OBV_VERITY ((*vbstring4)[0] == 'F');
437 vbstring4->_remove_ref ();
440 // test CORBA::String_var ctor
441 VBstring *vbstring5 = 0;
442 ACE_NEW_RETURN (vbstring5,
443 VBstring(svar),
445 OBV_VERITY ((*vbstring5)[0] == 'S');
446 (*vbstring5)[0] = 'W';
447 OBV_VERITY ((*vbstring5)[0] == 'W' && (svar.in())[0] == 'S');
448 vbstring5->_remove_ref ();
450 // release, as usual
451 vbstring2->_remove_ref ();
452 return fail;
456 int test_boxed_string_invocations (Test * test_object)
458 int fail = 0;
460 VBstring *p1 = 0;
461 VBstring *p2 = 0;
462 VBstring *p3 = 0;
466 //============================================================
467 // Test method invocation with boxed value
468 //============================================================
470 ACE_NEW_RETURN (p1,
471 VBstring(CORBA::string_dup ("string1")),
473 ACE_NEW_RETURN (p2,
474 VBstring(CORBA::string_dup ("string2")),
477 OBV_VERITY (ACE_OS::strcmp(p1->_value (), "string1") == 0);
478 OBV_VERITY (ACE_OS::strcmp(p2->_value (), "string2") == 0);
480 VBstring_var result = test_object->string_op1(p1, p2, p3);
482 OBV_VERITY (ACE_OS::strcmp(p2->_value (), "2string") == 0);
483 OBV_VERITY (ACE_OS::strcmp(p3->_value (), "2string") == 0);
484 OBV_VERITY (ACE_OS::strcmp(result->_value (), "1string") == 0);
486 //============================================================
487 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
488 //============================================================
490 p2->_value(CORBA::string_dup ("second string2"));
492 CORBA::String_var sresult =
493 test_object->string_op2(p1->_boxed_in(), p2->_boxed_inout(),
494 p3->_boxed_out());
496 OBV_VERITY (ACE_OS::strcmp(p2->_value (), "2second string") == 0);
497 OBV_VERITY (ACE_OS::strcmp(p3->_value (), "2second string") == 0);
498 OBV_VERITY (ACE_OS::strcmp(sresult.in (), "1string") == 0);
500 catch (const CORBA::Exception& ex)
502 ex._tao_print_exception ("test_boxed_string_invocations");
503 fail = 1;
505 catch (...)
507 ACE_DEBUG ((LM_DEBUG,
508 "(%P|%t) test_boxed_string_invocations: "
509 "caught a C++ exception\n"));
510 fail = 1;
512 if (p1) p1->_remove_ref ();
513 if (p2) p2->_remove_ref ();
514 if (p3) p3->_remove_ref ();
516 return fail;
520 // Test boxed sequence types.
522 int test_boxed_sequence ()
524 int fail = 0;
527 VBseqlong *vbseqlong1 = 0;
528 ACE_NEW_RETURN (vbseqlong1,
529 VBseqlong (),
532 VBseqlong *temp = 0;
533 ACE_NEW_RETURN (temp,
534 VBseqlong (),
537 VBseqlong_var vbseqlong2 (temp);
538 OBV_VERITY (vbseqlong1->length() == 0);
539 OBV_VERITY (vbseqlong2->length() == 0);
540 CORBA::Long *longarray = 0;
541 ACE_NEW_RETURN (longarray,
542 CORBA::Long[3],
544 longarray[0] = 101;
545 longarray[1] = 202;
546 longarray[2] = 303;
548 // Create a sequence
549 TDseqlong *temp2 = 0;
550 ACE_NEW_RETURN (temp2,
551 TDseqlong(10, 3, longarray, 1),
553 TDseqlong_var seqlong1 (temp2);
554 OBV_VERITY (seqlong1[0] == 101 && seqlong1[2] == 303);
556 VBseqlong *vbseqlong3 = 0;
557 ACE_NEW_RETURN (vbseqlong3,
558 VBseqlong(seqlong1.in()),
561 // Test sequence ctor.
562 VBseqlong *vbseqlong4 = 0;
563 ACE_NEW_RETURN (vbseqlong4,
564 VBseqlong(10, 3, longarray, 0),
567 // Test assignment and subscript operators
568 vbseqlong2 = vbseqlong3;
569 OBV_VERITY (vbseqlong2->length() == 3);
570 VBseqlong &vbseqlong5 = *vbseqlong2.inout();
571 OBV_VERITY (vbseqlong5[2] == 303);
572 vbseqlong5[2] = 444;
573 OBV_VERITY (vbseqlong5[2] == 444);
574 OBV_VERITY (seqlong1[0] == 101 && seqlong1[2] == 303);
575 OBV_VERITY ((*vbseqlong4)[0] == 101 && (*vbseqlong4)[2] == 303);
576 seqlong1[0] = 111;
577 OBV_VERITY ((*vbseqlong4)[0] == 111);
578 OBV_VERITY (vbseqlong4->maximum() == 10);
579 *vbseqlong4 = vbseqlong1->_value();
580 OBV_VERITY (vbseqlong4->length() == 0);
582 // Test copy_value
583 VBseqlong *vbseqlong6 = VBseqlong::_downcast( vbseqlong4->_copy_value());
584 if (vbseqlong6 == 0)
586 fail++;
587 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Failure at line %l\n"));
589 else
591 OBV_VERITY (vbseqlong6->length() == 0);
592 vbseqlong6->_remove_ref ();
595 // release
596 vbseqlong1->_remove_ref ();
597 vbseqlong4->_remove_ref ();
599 catch (const ::CORBA::Exception &ex)
601 ex._tao_print_exception ("test_boxed_sequence");
602 fail = 1;
604 catch (...)
606 ACE_ERROR ((LM_ERROR, "test_boxed_sequence : unexpected exception caught\n"));
608 return fail;
612 int test_boxed_sequence_invocations (Test * test_object)
614 int fail = 0;
615 VBseqlong *p1 = 0;
616 VBseqlong *p2 = 0;
617 VBseqlong *p3;
621 //============================================================
622 // Test method invocation with boxed value
623 //============================================================
625 ACE_NEW_RETURN (p1,
626 VBseqlong(4),
628 ACE_NEW_RETURN (p2,
629 VBseqlong(3),
631 p1->length(4);
632 p2->length(3);
634 (*p1)[0] = 10;
635 (*p1)[1] = 9;
636 (*p1)[2] = 8;
637 (*p1)[3] = 7;
639 (*p2)[0] = 100;
640 (*p2)[1] = 99;
641 (*p2)[2] = 98;
643 OBV_VERITY ((*p1)[0] == 10);
644 OBV_VERITY ((*p1)[1] == 9);
645 OBV_VERITY ((*p1)[2] == 8);
646 OBV_VERITY ((*p1)[3] == 7);
648 VBseqlong_var result = test_object->seq_op1(p1, p2, p3);
650 OBV_VERITY ((*p2)[0] == 100*3);
651 OBV_VERITY ((*p2)[1] == 99*3);
652 OBV_VERITY ((*p2)[2] == 98*3);
653 OBV_VERITY ((*p3)[0] == 100*5);
654 OBV_VERITY ((*p3)[1] == 99*5);
655 OBV_VERITY ((*p3)[2] == 98*5);
656 OBV_VERITY ((*result.in ())[0] == 10);
657 OBV_VERITY ((*result.in ())[1] == 9);
658 OBV_VERITY ((*result.in ())[2] == 8);
659 OBV_VERITY ((*result.in ())[3] == 7);
661 //============================================================
662 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
663 //============================================================
665 test_object->seq_op2(p1->_boxed_in(), p2->_boxed_inout(),
666 p3->_boxed_out());
668 OBV_VERITY ((*p2)[0] == 100*3*3);
669 OBV_VERITY ((*p2)[1] == 99*3*3);
670 OBV_VERITY ((*p2)[2] == 98*3*3);
671 OBV_VERITY ((*p3)[0] == (*p1)[0]*5);
672 OBV_VERITY ((*p3)[1] == (*p1)[1]*5);
673 OBV_VERITY ((*p3)[2] == (*p1)[2]*5);
674 OBV_VERITY ((*p3)[3] == (*p1)[3]*5);
676 catch (const CORBA::Exception& ex)
678 ex._tao_print_exception ("test_boxed_sequence_invocations");
679 fail = 1;
681 catch (...)
683 ACE_DEBUG ((LM_DEBUG,
684 "(%P|%t) test_boxed_sequence_invocations: "
685 "caught a C++ exception\n"));
686 fail = 1;
689 if (p1) p1->_remove_ref ();
690 if (p2) p2->_remove_ref ();
691 if (p3) p3->_remove_ref ();
693 return fail;
698 // Test a boxed struct type. This is not templated since the struct
699 // members are accessed by name, so this is specific to a certain IDL.
701 int test_boxed_struct ()
703 int fail = 0;
705 Fixed_Struct1 *fixed_struct_a = 0;
706 ACE_NEW_RETURN (fixed_struct_a,
707 Fixed_Struct1,
709 fixed_struct_a->l = 3233;
710 fixed_struct_a->abstruct.s1 = 73;
711 fixed_struct_a->abstruct.s2 = 37;
713 // Test the VBfixed_struct1 constructor
714 VBfixed_struct1 *valuebox1 = 0;
715 ACE_NEW_RETURN (valuebox1,
716 VBfixed_struct1 (*fixed_struct_a),
719 // Test boxed copy ctor.
720 VBfixed_struct1* valuebox2_ptr = 0;
721 ACE_NEW_RETURN (valuebox2_ptr,
722 VBfixed_struct1 (*valuebox1),
724 VBfixed_struct1_var valuebox2 = valuebox2_ptr;
726 OBV_VERITY (valuebox1->l () == valuebox2->l ());
727 OBV_VERITY ((valuebox1->abstruct ()).s1 == (valuebox2->abstruct ()).s1);
728 OBV_VERITY ((valuebox1->abstruct ()).s2 == (valuebox2->abstruct ()).s2);
730 // Change an element
731 valuebox1->l (505);
732 OBV_VERITY (valuebox1->l () != valuebox2->l ());
734 // Change some more, to test other types.
735 (valuebox2->abstruct ()).s1 = 667;
736 OBV_VERITY ((valuebox1->abstruct ()).s1 != (valuebox2->abstruct ()).s1);
737 (valuebox2->abstruct ()).s2 = 1667;
738 OBV_VERITY ((valuebox1->abstruct ()).s2 != (valuebox2->abstruct ()).s2);
740 Fixed_Struct1 *fixed_struct_b = 0;
741 ACE_NEW_RETURN (fixed_struct_b,
742 Fixed_Struct1,
744 fixed_struct_b->l = 7372;
745 fixed_struct_b->abstruct.s1 = 11;
746 fixed_struct_b->abstruct.s2 = 51;
748 // Make another VBfixed_struct1
749 VBfixed_struct1 *valuebox3 = 0;
750 ACE_NEW_RETURN (valuebox3,
751 VBfixed_struct1 (),
754 // Test assignment operator
755 *valuebox3 = *fixed_struct_b;
757 OBV_VERITY (valuebox3->l () == fixed_struct_b->l);
758 OBV_VERITY ((valuebox3->abstruct ()).s1 == fixed_struct_b->abstruct.s1);
759 OBV_VERITY ((valuebox3->abstruct ()).s2 == fixed_struct_b->abstruct.s2);
761 // Test _value modifier method
762 valuebox2->_value (*fixed_struct_b);
763 OBV_VERITY (valuebox2->l () == fixed_struct_b->l);
764 OBV_VERITY ((valuebox2->abstruct ()).s1 == fixed_struct_b->abstruct.s1);
765 OBV_VERITY ((valuebox2->abstruct ()).s2 == fixed_struct_b->abstruct.s2);
767 // Test _copy_value and _downcast
768 VBfixed_struct1_var valuebox4 =
769 VBfixed_struct1::_downcast (valuebox3->_copy_value ());
770 if (valuebox4.in () == 0)
772 fail++;
773 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Failure at line %l\n"));
775 else
777 OBV_VERITY (valuebox4->l () == fixed_struct_b->l);
778 OBV_VERITY ((valuebox4->abstruct ()).s1 == fixed_struct_b->abstruct.s1);
779 OBV_VERITY ((valuebox4->abstruct ()).s2 == fixed_struct_b->abstruct.s2);
783 // valuebox1 and valuebox3 must be explicitly removed.
784 CORBA::remove_ref (valuebox1);
785 CORBA::remove_ref (valuebox3);
788 // as well as the structs we new'ed.
789 delete fixed_struct_a;
790 delete fixed_struct_b;
793 // Other types are _var so their dtors will clean up remaining
794 // allocations.
796 return fail;
800 int test_boxed_struct_invocations (Test * test_object)
802 int fail = 0;
806 //============================================================
807 // Fixed struct
808 // Test method invocation with boxed value
809 //============================================================
810 Fixed_Struct1 fs1;
811 fs1.l = 29;
812 fs1.abstruct.s1 = 117;
813 fs1.abstruct.s2 = 21;
815 VBfixed_struct1 *p1 = 0;
816 ACE_NEW_RETURN (p1,
817 VBfixed_struct1(fs1),
820 Fixed_Struct1 fs2;
821 fs2.l = 92;
822 fs2.abstruct.s1 = 171;
823 fs2.abstruct.s2 = 12;
825 VBfixed_struct1 *p2 = 0;
826 ACE_NEW_RETURN (p2,
827 VBfixed_struct1(fs2),
830 VBfixed_struct1 *p3;
832 OBV_VERITY (p1->l() == 29);
833 OBV_VERITY ((p1->abstruct()).s1 == 117);
834 OBV_VERITY ((p1->abstruct()).s2 == 21);
836 VBfixed_struct1_var result = test_object->struct_op1(p1, p2, p3);
838 OBV_VERITY (p2->l() == 92*3);
839 OBV_VERITY ((p2->abstruct()).s1 == 171*3);
840 OBV_VERITY ((p2->abstruct()).s2 == 12*3);
842 OBV_VERITY (p3->l() == 92*5);
843 OBV_VERITY ((p3->abstruct()).s1 == 171*5);
844 OBV_VERITY ((p3->abstruct()).s2 == 12*5);
846 OBV_VERITY (result->l() == fs1.l);
847 OBV_VERITY ((result->abstruct()).s1 == fs1.abstruct.s1);
848 OBV_VERITY ((result->abstruct()).s2 == fs1.abstruct.s2);
850 //============================================================
851 // Fixed struct
852 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
853 //============================================================
855 test_object->struct_op2(p1->_boxed_in(), p2->_boxed_inout(),
856 p3->_boxed_out());
858 OBV_VERITY (p2->l() == 92*3*3);
859 OBV_VERITY ((p2->abstruct()).s1 == 171*3*3);
860 OBV_VERITY ((p2->abstruct()).s2 == 12*3*3);
862 OBV_VERITY (p3->l() == fs1.l);
863 OBV_VERITY ((p3->abstruct()).s1 == fs1.abstruct.s1);
864 OBV_VERITY ((p3->abstruct()).s2 == fs1.abstruct.s2);
867 p1->_remove_ref ();
868 p2->_remove_ref ();
869 p3->_remove_ref ();
872 //============================================================
873 // Variable struct
874 // Test method invocation with boxed value
875 //============================================================
877 Variable_Struct1 vs1;
878 vs1.l = 29;
879 vs1.str = CORBA::string_dup ("variable1");
881 VBvariable_struct1 *p4 = 0;
882 ACE_NEW_RETURN (p4,
883 VBvariable_struct1 (vs1),
886 Variable_Struct1 vs2;
887 vs2.l = 37;
888 vs2.str = "variable2";
890 VBvariable_struct1 *p5 = 0;
891 ACE_NEW_RETURN (p5,
892 VBvariable_struct1 (vs2),
895 VBvariable_struct1 *p6;
898 OBV_VERITY (p4->l() == 29);
899 OBV_VERITY (ACE_OS::strcmp(p4->str(), "variable1") == 0);
901 VBvariable_struct1_var result2 = test_object->struct_op3(p4, p5, p6);
903 OBV_VERITY (p5->l() == vs2.l*3);
904 OBV_VERITY (ACE_OS::strcmp(p5->str(), "2variable") == 0);
906 OBV_VERITY (p6->l() == vs2.l*3);
907 OBV_VERITY (ACE_OS::strcmp(p6->str(), "2variable") == 0);
909 OBV_VERITY (result2->l() == vs1.l);
910 OBV_VERITY (ACE_OS::strcmp(result2->str(), vs1.str) == 0);
913 //============================================================
914 // Variable struct
915 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
916 //============================================================
918 test_object->struct_op4(p4->_boxed_in(), p5->_boxed_inout(),
919 p6->_boxed_out());
921 OBV_VERITY (p5->l() == vs2.l*3*3);
922 OBV_VERITY (ACE_OS::strcmp(p5->str(), "e2variabl") == 0);
924 OBV_VERITY (p6->l() == vs1.l);
925 OBV_VERITY (ACE_OS::strcmp(p6->str(), vs1.str) == 0);
928 p4->_remove_ref ();
929 p5->_remove_ref ();
930 p6->_remove_ref ();
932 catch (const CORBA::Exception& ex)
934 ex._tao_print_exception ("test_boxed_struct_invocations");
935 fail = 1;
937 catch (...)
939 ACE_DEBUG ((LM_DEBUG,
940 "(%P|%t) test_boxed_struct_invocations: "
941 "caught a C++ exception\n"));
942 fail = 1;
945 return fail;
949 // Test boxed array types.
951 int test_boxed_array()
953 int fail = 0;
954 LongArray la;
955 la[0] = 101;
956 la[1] = 202;
957 la[2] = 303;
959 // three ctors
960 VBlongarray *valuebox1 = 0;
961 ACE_NEW_RETURN (valuebox1,
962 VBlongarray,
964 VBlongarray *valuebox2 = 0;
965 ACE_NEW_RETURN (valuebox2,
966 VBlongarray(la),
968 VBlongarray *valuebox3 = 0;
969 ACE_NEW_RETURN (valuebox3,
970 VBlongarray(*valuebox2),
973 OBV_VERITY ((*valuebox2)[0] == 101
974 && valuebox2->_value()[1] == 202
975 && valuebox2->_value()[2] == 303);
977 OBV_VERITY ((*valuebox3)[0] == 101
978 && (*valuebox3)[1] == 202
979 && (*valuebox3)[2] == 303);
981 (*valuebox3)[0] = 111;
982 valuebox3->_value()[1] = 222;
984 OBV_VERITY ((*valuebox2)[0] == 101
985 && (*valuebox2)[1] == 202
986 && (*valuebox2)[2] == 303);
988 OBV_VERITY ((*valuebox3)[0] == 111
989 && (*valuebox3)[1] == 222
990 && (*valuebox3)[2] == 303);
992 *valuebox1 = la;
994 OBV_VERITY ((*valuebox1)[0] == 101
995 && valuebox1->_value()[1] == 202
996 && valuebox1->_value()[2] == 303);
998 valuebox2->_value(la);
1000 OBV_VERITY ((*valuebox2)[0] == 101
1001 && valuebox2->_value()[1] == 202
1002 && valuebox2->_value()[2] == 303);
1004 LongArray_var lv_la(LongArray_dup(la));
1005 *valuebox2 = lv_la.in();
1007 *valuebox2 = valuebox3->_value();
1008 valuebox3->_value()[1] = 777;
1009 OBV_VERITY ((*valuebox2)[0] == 111
1010 && valuebox2->_value()[1] == 222
1011 && valuebox2->_value()[2] == 303);
1013 // release
1014 valuebox1->_remove_ref ();
1015 valuebox2->_remove_ref ();
1016 valuebox3->_remove_ref ();
1018 return fail;
1022 int test_boxed_array_invocations (Test * test_object)
1024 int fail = 0;
1028 //============================================================
1029 // Array (fixed)
1030 // Test method invocation with boxed value
1031 //============================================================
1033 LongArray la;
1034 la[0] = 101;
1035 la[1] = 202;
1036 la[2] = 303;
1038 VBlongarray *p1 = 0;
1039 ACE_NEW_RETURN (p1,
1040 VBlongarray (la),
1043 LongArray la2;
1044 la2[0] = 3101;
1045 la2[1] = 3202;
1046 la2[2] = 3303;
1048 VBlongarray *p2 = 0;
1049 ACE_NEW_RETURN (p2,
1050 VBlongarray (la2),
1053 OBV_VERITY ((*p1)[0] == 101
1054 && (*p1)[1] == 202
1055 && (*p1)[2] == 303);
1057 VBlongarray *p3;
1059 VBlongarray_var result = test_object->array_op1 (p1, p2, p3);
1061 OBV_VERITY ((*p2)[0] == (3101*3)
1062 && (*p2)[1] == (3202*3)
1063 && (*p3)[2] == (3303*3));
1065 OBV_VERITY ((*p3)[0] == (3101*3)
1066 && (*p3)[1] == (3202*3)
1067 && (*p3)[2] == (3303*3));
1069 OBV_VERITY ((*result.in ())[0] == 101
1070 && (*result.in ())[1] == 202
1071 && (*result.in ())[2] == 303);
1073 //============================================================
1074 // Array (fixed)
1075 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
1076 //============================================================
1078 // Exclude the following test for now until issues with _boxed_out()
1079 // for arrays are resolved.
1080 #if 0
1081 test_object->array_op2(p1->_boxed_in(), p2->_boxed_inout(),
1082 p3->_boxed_out());
1084 OBV_VERITY ((*p2)[0] == (3101*3*3)
1085 && (*p2)[1] == (3202*3*3)
1086 && (*p2)[2] == (3303*3*3));
1088 OBV_VERITY ((*p3)[0] == (*p1)[0]
1089 && (*p3)[1] == (*p1)[1]
1090 && (*p3)[2] == (*p1)[2]);
1091 #endif
1093 p1->_remove_ref ();
1094 p2->_remove_ref ();
1095 p3->_remove_ref ();
1097 //============================================================
1098 // Array (variable)
1099 // Test method invocation with boxed value
1100 //============================================================
1102 StringArray sa;
1103 sa[0] = CORBA::string_dup ("in string1");
1104 sa[1] = CORBA::string_dup ("in string2");
1106 VBstringarray *p4 = 0;
1107 ACE_NEW_RETURN (p4,
1108 VBstringarray (sa),
1111 StringArray sa2;
1112 sa2[0] = CORBA::string_dup ("inout string1");
1113 sa2[1] = CORBA::string_dup ("inout string2");
1115 VBstringarray *p5 = 0;
1116 ACE_NEW_RETURN (p5,
1117 VBstringarray (sa2),
1120 OBV_VERITY (ACE_OS::strcmp((*p4)[0], sa[0]) == 0);
1121 OBV_VERITY (ACE_OS::strcmp((*p4)[1], sa[1]) == 0);
1123 VBstringarray *p6;
1125 VBstringarray_var result2 = test_object->array_op3 (p4, p5, p6);
1127 OBV_VERITY (ACE_OS::strcmp((*p5)[0], "1inout string") == 0);
1128 OBV_VERITY (ACE_OS::strcmp((*p5)[1], "2inout string") == 0);
1129 OBV_VERITY (ACE_OS::strcmp((*p6)[0], "1inout string") == 0);
1130 OBV_VERITY (ACE_OS::strcmp((*p6)[1], "2inout string") == 0);
1131 OBV_VERITY (ACE_OS::strcmp((*result2.in ())[0], sa[0]) == 0);
1132 OBV_VERITY (ACE_OS::strcmp((*result2.in ())[1], sa[1]) == 0);
1134 //============================================================
1135 // Array (variable)
1136 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
1137 //============================================================
1139 // Disable the following for now. Need to troubleshoot it.
1140 #if 0
1141 // Following gets compilation error on parameter 3
1142 // test_object->array_op4(p4->_boxed_in(), p5->_boxed_inout(),
1143 // p6->_boxed_out());
1145 // Trying the following variation to troubleshoot. No compilation error
1146 // but p6 is unchanged after return from method.
1147 StringArray sa_experimental;
1148 StringArray_slice *slice = p6->_boxed_out();
1149 StringArray_out an_out (slice);
1151 test_object->array_op4(p4->_boxed_in(), p5->_boxed_inout(),
1152 an_out);
1154 ACE_DEBUG ((LM_DEBUG, "(%P|%t) after array_op4\n"));
1155 ACE_DEBUG ((LM_DEBUG, "(%P|%t) p5[0]=%s\n", (const char *)((*p5)[0])));
1156 ACE_DEBUG ((LM_DEBUG, "(%P|%t) p5[1]=%s\n", (const char *)((*p5)[1])));
1157 ACE_DEBUG ((LM_DEBUG, "(%P|%t) p6[0]=%s\n", (const char *)((*p6)[0])));
1158 ACE_DEBUG ((LM_DEBUG, "(%P|%t) p6[1]=%s\n", (const char *)((*p6)[1])));
1159 OBV_VERITY (ACE_OS::strcmp((*p5)[0], "g1inout strin") == 0);
1160 OBV_VERITY (ACE_OS::strcmp((*p5)[1], "g2inout strin") == 0);
1161 OBV_VERITY (ACE_OS::strcmp((*p6)[0], sa[0]) == 0);
1162 OBV_VERITY (ACE_OS::strcmp((*p6)[1], sa[1]) == 0);
1163 #endif
1165 p4->_remove_ref ();
1166 p5->_remove_ref ();
1167 p6->_remove_ref ();
1169 catch (const CORBA::Exception& ex)
1171 ex._tao_print_exception ("test_boxed_array_invocations");
1172 fail = 1;
1174 catch (...)
1176 ACE_DEBUG ((LM_DEBUG,
1177 "(%P|%t) test_boxed_array_invocations: "
1178 "caught a C++ exception\n"));
1179 fail = 1;
1182 return fail;
1187 // Test a boxed union type.
1189 int test_boxed_union()
1191 int fail = 0;
1193 VBfixed_union1 *ptemp;
1194 ACE_NEW_RETURN (ptemp,
1195 VBfixed_union1 (),
1197 VBfixed_union1_var valuebox1(ptemp);
1200 Fixed_Union1 *ptemp2;
1201 ACE_NEW_RETURN (ptemp2,
1202 Fixed_Union1 (),
1204 Fixed_Union1_var fixed_union1(ptemp2);
1206 // Test modifiers, accessors, discriminant access
1207 valuebox1->m1 (37);
1208 OBV_VERITY (valuebox1->m1 () == 37);
1209 OBV_VERITY (valuebox1->_d () == 1 || valuebox1->_d () == 2);
1211 // Explicitly set discriminant, make sure thats the only thing
1212 // that changes.
1213 valuebox1->_d (2);
1214 OBV_VERITY (valuebox1->_d () == 2);
1215 OBV_VERITY (valuebox1->m1 () == 37);
1216 valuebox1->_d (1);
1217 OBV_VERITY (valuebox1->_d () == 1);
1218 OBV_VERITY (valuebox1->m1 () == 37);
1220 // Use _value() to access
1221 valuebox1->_value ()._d (2);
1222 OBV_VERITY (valuebox1->_d () == 2);
1224 // Use _value as modifier.
1225 valuebox1->_value (fixed_union1.in());
1226 OBV_VERITY (valuebox1->_d () != 1 && valuebox1->_d () != 2);
1229 VBfixed_union1* valuebox2_ptr = 0;
1230 ACE_NEW_RETURN (valuebox2_ptr,
1231 VBfixed_union1 (),
1233 VBfixed_union1_var valuebox2 (valuebox2_ptr);
1234 valuebox2->m2(333);
1235 OBV_VERITY (valuebox2->_d () == 2);
1237 // Test copy ctor
1238 VBfixed_union1* valuebox3_ptr = 0;
1239 ACE_NEW_RETURN (valuebox3_ptr,
1240 VBfixed_union1 (*valuebox2.in ()),
1242 VBfixed_union1_var valuebox3 (valuebox3_ptr);
1243 OBV_VERITY (valuebox3->_d () == 2);
1244 OBV_VERITY (valuebox3->m2 () == 333);
1246 // Test assignment op
1247 valuebox3->m2 (456);
1248 *valuebox3.in () = valuebox2->_value ();
1249 OBV_VERITY (valuebox3->_d () == 2);
1250 OBV_VERITY (valuebox3->m2 () == 333);
1252 // Test constructor taking union argument
1253 fixed_union1->m2 (137);
1254 VBfixed_union1 *valuebox4_ptr = 0;
1255 ACE_NEW_RETURN (valuebox4_ptr,
1256 VBfixed_union1 (fixed_union1.in ()),
1258 VBfixed_union1_var valuebox4 (valuebox4_ptr);
1259 OBV_VERITY (valuebox4->m2 () == 137);
1260 OBV_VERITY (valuebox4->_d () == 1 || valuebox4->_d () == 2);
1262 return fail;
1267 int test_boxed_union_invocations (Test * test_object)
1269 int fail = 0;
1273 //============================================================
1274 // Union (fixed)
1275 // Test method invocation with boxed value
1276 //============================================================
1278 Fixed_Union1 *ptemp = 0;
1279 ACE_NEW_RETURN (ptemp,
1280 Fixed_Union1 (),
1282 Fixed_Union1_var fixed_union1(ptemp);
1284 fixed_union1->m1 (321);
1285 VBfixed_union1 *p1 = 0;
1286 ACE_NEW_RETURN (p1,
1287 VBfixed_union1 (fixed_union1.in ()),
1290 Fixed_Union1 *ptemp2 = 0;
1291 ACE_NEW_RETURN (ptemp2,
1292 Fixed_Union1 (),
1294 Fixed_Union1_var fixed_union2(ptemp2);
1295 fixed_union2->m2 (789);
1296 VBfixed_union1 *p2 = 0;
1297 ACE_NEW_RETURN (p2,
1298 VBfixed_union1 (fixed_union2.in ()),
1301 OBV_VERITY (p1->_d () == 1);
1302 OBV_VERITY (p1->m1 () == 321);
1303 OBV_VERITY (p2->_d () == 2);
1304 OBV_VERITY (p2->m2 () == 789);
1306 VBfixed_union1 * p3;
1308 VBfixed_union1_var result = test_object->union_op1 (p1, p2, p3);
1310 OBV_VERITY (p2->_d () == 2);
1311 OBV_VERITY (p2->m2 () == 789*3);
1312 OBV_VERITY (p3->_d () == 1);
1313 OBV_VERITY (p3->m1 () == 321*3);
1314 OBV_VERITY (result->_d () == 1);
1315 OBV_VERITY (result->m1 () == 321*3);
1318 //============================================================
1319 // Union (fixed)
1320 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
1321 //============================================================
1323 test_object->union_op2(p1->_boxed_in(), p2->_boxed_inout(),
1324 p3->_boxed_out());
1326 OBV_VERITY (p2->_d () == 2);
1327 OBV_VERITY (p2->m2 () == 789*3*3);
1329 OBV_VERITY (p3->_d () == 1);
1330 OBV_VERITY (p3->m1 () == 321);
1332 p1->_remove_ref ();
1333 p2->_remove_ref ();
1334 p3->_remove_ref ();
1336 //============================================================
1337 // Union (variable)
1338 // Test method invocation with boxed value
1339 //============================================================
1341 Variable_Union1_var variable_union1;
1342 ACE_NEW_RETURN (variable_union1,
1343 Variable_Union1 (),
1345 variable_union1->m1 (321);
1346 // TODO : resource leak
1347 VBvariable_union1 *p4 = 0;
1348 ACE_NEW_RETURN (p4,
1349 VBvariable_union1 (variable_union1.in ()),
1352 Variable_Union1_var variable_union2;
1353 ACE_NEW_RETURN (variable_union2,
1354 Variable_Union1 (),
1356 variable_union2->m2 (CORBA::string_dup ("abracadabra"));
1357 VBvariable_union1 *p5 = 0;
1358 ACE_NEW_RETURN (p5,
1359 VBvariable_union1 (variable_union2.in ()),
1362 OBV_VERITY (p4->_d () == 1);
1363 OBV_VERITY (p4->m1 () == 321);
1364 OBV_VERITY (p5->_d () == 2);
1365 OBV_VERITY (ACE_OS::strcmp(p5->m2 (), "abracadabra") == 0);
1367 VBvariable_union1 * p6;
1369 VBvariable_union1_var result2 = test_object->union_op3 (p4, p5, p6);
1371 OBV_VERITY (p5->_d () == 2);
1372 OBV_VERITY (ACE_OS::strcmp(p5->m2 (), "aabracadabr") == 0);
1373 OBV_VERITY (p6->_d () == 1);
1374 OBV_VERITY (p6->m1 () == 321);
1375 OBV_VERITY (result2->_d () == 1);
1376 OBV_VERITY (result2->m1 () == 321);
1378 //============================================================
1379 // Union (variable)
1380 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
1381 //============================================================
1383 p4->m1 (1722);
1385 test_object->union_op4(p4->_boxed_in(), p5->_boxed_inout(),
1386 p6->_boxed_out());
1388 OBV_VERITY (p5->_d () == 2);
1389 OBV_VERITY (ACE_OS::strcmp(p5->m2 (), "raabracadab") == 0);
1391 OBV_VERITY (p6->_d () == 1);
1392 OBV_VERITY (p6->m1 () == 1722);
1394 p4->_remove_ref ();
1395 p5->_remove_ref ();
1396 p6->_remove_ref ();
1398 catch (const CORBA::Exception& ex)
1400 ex._tao_print_exception ("test_boxed_union_invocations");
1401 fail = 1;
1403 catch (...)
1405 ACE_DEBUG ((LM_DEBUG,
1406 "(%P|%t) test_boxed_union_invocations: "
1407 "caught a C++ exception\n"));
1408 fail = 1;
1411 return fail;
1415 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
1417 Test_var test_object;
1418 CORBA::ORB_var orb;
1423 orb = CORBA::ORB_init (argc, argv);
1425 if (parse_args (argc, argv) != 0)
1426 return 1;
1428 // Obtain reference to the object.
1429 CORBA::Object_var tmp =
1430 orb->string_to_object(ior);
1432 test_object = Test::_narrow(tmp.in ());
1434 if (CORBA::is_nil (test_object.in ()))
1436 ACE_ERROR_RETURN ((LM_DEBUG,
1437 "Nil Test reference <%s>\n",
1438 ior),
1442 catch (const CORBA::Exception& ex)
1444 ex._tao_print_exception ("Initialization failure");
1445 return 1;
1447 catch (...)
1449 ACE_DEBUG ((LM_DEBUG,
1450 "(%P|%t) Initialization failure: caught a C++ exception\n"));
1451 return 1;
1454 int fail = 0;
1456 fail = test_basic ();
1458 fail += test_basic_invocations (test_object.in ());
1460 fail += test_boxed_string ();
1462 fail += test_boxed_string_invocations (test_object.in ());
1464 fail += test_boxed_sequence ();
1466 fail += test_boxed_sequence_invocations (test_object.in ());
1468 fail += test_boxed_struct ();
1470 fail += test_boxed_struct_invocations (test_object.in ());
1472 fail += test_boxed_array ();
1474 fail += test_boxed_array_invocations (test_object.in ());
1476 fail += test_boxed_union();
1478 fail += test_boxed_union_invocations (test_object.in ());
1483 test_object->shutdown ();
1485 ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - test finished\n"));
1487 orb->destroy ();
1489 catch (const CORBA::Exception& ex)
1491 ex._tao_print_exception ("Exception caught:");
1492 return 1;
1495 return (fail) ? 1 : 0;