Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / OBV / ValueBox / client.cpp
blob506cd15686c93f79247def860620b4d23b645a53
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;
132 // Test boxed values that use an underlying UT&
134 template <class BoxT, class UT>
135 int box_test_ref (BoxT *valuebox, UT &val1, UT &val2)
137 int fail = 0;
138 BoxT *p = 0;
139 ACE_NEW_RETURN (p,
140 BoxT (val1),
143 // should be a deep copy of val1...
144 OBV_VERITY ( &p->_boxed_inout () != &valuebox->_boxed_inout () );
146 p->_value ( val2 ); // deep copy
147 OBV_VERITY ( &p->_boxed_inout () != &valuebox->_boxed_inout () );
149 *valuebox = val2; // deep copy, too.
150 OBV_VERITY ( &p->_boxed_inout () != &valuebox->_boxed_inout () );
152 CORBA::remove_ref (p);
154 return fail;
157 int test_basic (void)
159 int fail = 0;
161 // Basic types
162 fail += simple_box_test<VBshort, CORBA::Short> ();
163 fail += simple_box_test<VBlong, CORBA::Long> ();
164 fail += simple_box_test<VBlonglong, CORBA::LongLong> ();
165 fail += simple_box_test<VBushort, CORBA::UShort> ();
166 fail += simple_box_test<VBulong, CORBA::ULong> ();
167 fail += simple_box_test<VBulonglong, CORBA::ULongLong> ();
168 fail += simple_box_test<VBwchar, CORBA::WChar> ();
169 fail += simple_box_test<VBoctet, CORBA::Octet> ();
170 fail += simple_box_test<VBfloat, CORBA::Float> ();
171 fail += simple_box_test<VBdouble, CORBA::Double> ();
173 VBchar *pchar = 0;
174 ACE_NEW_RETURN (pchar,
175 VBchar ('A'),
177 fail += box_test1<VBchar, CORBA::Char> (pchar, 'A', 'Z');
178 CORBA::remove_ref (pchar);
180 VBboolean *pbool = 0;
181 ACE_NEW_RETURN (pbool,
182 VBboolean (true),
184 fail += box_test1<VBboolean, CORBA::Boolean> (pbool, true, false);
185 CORBA::remove_ref (pbool);
187 // Typedef of basic types
188 fail += simple_box_test<VBTDshort, CORBA::Short> ();
189 fail += simple_box_test<VBTDlong, CORBA::Long> ();
190 fail += simple_box_test<VBTDlonglong, CORBA::LongLong> ();
191 fail += simple_box_test<VBTDushort, CORBA::UShort> ();
192 fail += simple_box_test<VBTDulong, CORBA::ULong> ();
193 fail += simple_box_test<VBTDulonglong, CORBA::ULongLong> ();
194 fail += simple_box_test<VBTDwchar, CORBA::WChar> ();
195 fail += simple_box_test<VBTDoctet, CORBA::Octet> ();
196 fail += simple_box_test<VBTDfloat, CORBA::Float> ();
197 fail += simple_box_test<VBTDdouble, CORBA::Double> ();
199 VBTDchar *pchar2 = 0;
200 ACE_NEW_RETURN (pchar2,
201 VBTDchar ('A'),
203 fail += box_test1<VBTDchar, CORBA::Char> (pchar2, 'A', 'Z');
204 CORBA::remove_ref (pchar2);
206 VBTDboolean *pbool2 = 0;
207 ACE_NEW_RETURN (pbool2,
208 VBTDboolean (true),
210 fail += box_test1<VBTDboolean, CORBA::Boolean> (pbool2, true, false);
211 CORBA::remove_ref (pbool2);
213 // Enumerated type
214 VBenum *penum = 0;
215 ACE_NEW_RETURN (penum,
216 VBenum (yellow),
218 fail += box_test1<VBenum, Color> (penum, yellow, red);
219 CORBA::remove_ref (penum);
221 // Typedef of enumerated type
222 VBTDenum *penum2 = 0;
223 ACE_NEW_RETURN (penum2,
224 VBTDenum (yellow),
226 fail += box_test1<VBTDenum, Color> (penum2, yellow, red);
227 CORBA::remove_ref (penum2);
229 // Any
230 CORBA::Any *a1 = 0;
231 ACE_NEW_RETURN (a1,
232 CORBA::Any (),
234 CORBA::Any_var any1 (a1);
236 CORBA::Any *a2 = 0;
237 ACE_NEW_RETURN (a2,
238 CORBA::Any (),
240 CORBA::Any_var any2 (a2);
242 VBany *pany = 0;
243 ACE_NEW_RETURN (pany,
244 VBany (any1.in ()),
246 fail += box_test_ref<VBany, CORBA::Any> (pany, any1.inout (),
247 any2.inout ());
248 CORBA::remove_ref (pany);
250 // Typedef of Any
251 VBTDany *pany2 = 0;
252 ACE_NEW_RETURN (pany2,
253 VBTDany (any1.in ()),
255 fail += box_test_ref<VBTDany, CORBA::Any> (pany2, any1.inout (),
256 any2.inout ());
257 CORBA::remove_ref (pany2);
259 return fail;
262 int test_basic_invocations (Test * test_object)
264 int fail = 0;
266 VBlong *p1 = 0;
267 VBlong *p2 = 0;
268 VBlong *p3;
270 vb_basic::M_VBlong *mp1 = 0;
271 vb_basic::M_VBlong *mp2 = 0;
272 vb_basic::M_VBlong *mp3;
277 //============================================================
278 // Test method invocation with boxed value
279 //============================================================
281 ACE_NEW_RETURN (p1,
282 VBlong(25),
284 ACE_NEW_RETURN (p2,
285 VBlong(53),
288 OBV_VERITY (p1->_value () == 25);
289 OBV_VERITY (p2->_value () == 53);
291 VBlong_var result =
292 test_object->basic_op1(p1, p2, p3);
294 OBV_VERITY (p2->_value () == (53*3));
295 OBV_VERITY (p3->_value () == (53*5));
296 OBV_VERITY (result->_value () == (p1->_value () *3));
298 //============================================================
299 // Test method invocation with boxed value from nested module
300 //============================================================
302 ACE_NEW_RETURN (mp1,
303 vb_basic::M_VBlong(25),
306 ACE_NEW_RETURN (mp2,
307 vb_basic::M_VBlong(53),
310 OBV_VERITY (mp1->_value () == 25);
311 OBV_VERITY (mp2->_value () == 53);
313 vb_basic::M_VBlong_var mresult =
314 test_object->basic_op2(mp1, mp2, mp3);
316 OBV_VERITY (mp2->_value () == (53*3));
317 OBV_VERITY (mp3->_value () == (53*5));
318 OBV_VERITY (mresult->_value () == (mp1->_value () *3));
320 //============================================================
321 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
322 //============================================================
324 p1->_value(67);
325 p2->_value(93);
327 long lresult =
328 test_object->basic_op3(p1->_boxed_in(), p2->_boxed_inout(),
329 p3->_boxed_out());
331 OBV_VERITY (p2->_value () == (93*3));
332 OBV_VERITY (p3->_value () == (93*5));
333 OBV_VERITY (lresult == (p1->_value()*3));
335 catch (const CORBA::Exception& ex)
337 ex._tao_print_exception ("test_basic_invocations");
338 fail = 1;
340 catch (...)
342 ACE_DEBUG ((LM_DEBUG,
343 "(%P|%t) test_basic_invocations: caught a C++ exception\n"));
344 fail = 1;
346 if (p1) p1->_remove_ref ();
347 if (p2) p2->_remove_ref ();
348 if (p3) p3->_remove_ref ();
350 if (mp1) mp1->_remove_ref ();
351 if (mp2) mp2->_remove_ref ();
352 if (mp3) mp3->_remove_ref ();
354 return fail;
358 int test_boxed_string()
360 int fail = 0;
361 const char *string1 = "First-string";
362 const char *string2 = "Second-string";
364 // Establish that we have data setup correctly...
365 OBV_VERITY (ACE_OS::strcmp (string1, string2) < 0);
366 OBV_VERITY (ACE_OS::strcmp (string2, string1) > 0);
367 OBV_VERITY (ACE_OS::strcmp (string1, string1) == 0);
369 // Make some objects, using our data
370 VBstring *temp = 0;
371 ACE_NEW_RETURN (temp,
372 VBstring(string1),
374 VBstring_var vbstring1 (temp);
376 VBstring *vbstring2 = 0;
377 ACE_NEW_RETURN (vbstring2,
378 VBstring(string1), // tests const char * ctor.
381 OBV_VERITY (ACE_OS::strcmp (vbstring1->_value(), string1) == 0);
382 OBV_VERITY (ACE_OS::strcmp (vbstring2->_value(), string1) == 0);
384 // Test assignment operators
385 char *carray1 = 0;
386 ACE_NEW_RETURN (carray1,
387 char[15],
389 ACE_OS::memcpy(carray1, string2, ACE_OS::strlen(string2));
390 *vbstring2 = carray1; // char * (adopted by box)
391 OBV_VERITY ((*vbstring2)[0] == 'S');
392 *vbstring2 = string1;
393 OBV_VERITY ((*vbstring2)[0] == 'F');
394 CORBA::String_var svar(string2);
395 *vbstring2 = svar;
396 OBV_VERITY ((*vbstring2)[0] == 'S');
398 // Test _value modifiers--like assignment drill above.
399 char *carray2 = 0;
400 ACE_NEW_RETURN (carray2,
401 char[15],
403 ACE_OS::memcpy(carray2, string1, ACE_OS::strlen(string1));
404 vbstring2->_value(carray2); // char * (adopted by box)
405 OBV_VERITY ((*vbstring2)[0] == 'F');
406 vbstring2->_value(string2); // const char *
407 OBV_VERITY ((*vbstring2)[0] == 'S');
408 (*vbstring2)[0] = 'Y';
409 OBV_VERITY ((*vbstring2)[0] != 'S');
410 vbstring2->_value(svar);
411 OBV_VERITY ((*vbstring2)[0] == 'S');
412 // test value accessor
413 OBV_VERITY ( (vbstring2->_value())[0] == 'S' );
416 // Test ctors.
417 // const boxed string
418 VBstring *vbstring3 = 0;
419 ACE_NEW_RETURN (vbstring3,
420 VBstring(*vbstring2),
422 OBV_VERITY ((*vbstring3)[0] == 'S');
423 (*vbstring3)[0] = 'W';
424 OBV_VERITY ((*vbstring3)[0] == 'W' && (*vbstring2)[0] == 'S');
425 vbstring3->_remove_ref ();
428 // char *
429 char *carray3 = 0;
430 ACE_NEW_RETURN (carray3,
431 char[15],
433 ACE_OS::memcpy(carray3, string1, ACE_OS::strlen(string1));
434 VBstring *vbstring4 = 0;
435 ACE_NEW_RETURN (vbstring4,
436 VBstring(carray3),
438 OBV_VERITY ((*vbstring4)[0] == 'F');
439 vbstring4->_remove_ref ();
442 // test CORBA::String_var ctor
443 VBstring *vbstring5 = 0;
444 ACE_NEW_RETURN (vbstring5,
445 VBstring(svar),
447 OBV_VERITY ((*vbstring5)[0] == 'S');
448 (*vbstring5)[0] = 'W';
449 OBV_VERITY ((*vbstring5)[0] == 'W' && (svar.in())[0] == 'S');
450 vbstring5->_remove_ref ();
452 // release, as usual
453 vbstring2->_remove_ref ();
454 return fail;
458 int test_boxed_string_invocations (Test * test_object)
460 int fail = 0;
462 VBstring *p1 = 0;
463 VBstring *p2 = 0;
464 VBstring *p3 = 0;
469 //============================================================
470 // Test method invocation with boxed value
471 //============================================================
473 ACE_NEW_RETURN (p1,
474 VBstring(CORBA::string_dup ("string1")),
476 ACE_NEW_RETURN (p2,
477 VBstring(CORBA::string_dup ("string2")),
480 OBV_VERITY (ACE_OS::strcmp(p1->_value (), "string1") == 0);
481 OBV_VERITY (ACE_OS::strcmp(p2->_value (), "string2") == 0);
483 VBstring_var result = test_object->string_op1(p1, p2, p3);
485 OBV_VERITY (ACE_OS::strcmp(p2->_value (), "2string") == 0);
486 OBV_VERITY (ACE_OS::strcmp(p3->_value (), "2string") == 0);
487 OBV_VERITY (ACE_OS::strcmp(result->_value (), "1string") == 0);
489 //============================================================
490 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
491 //============================================================
493 p2->_value(CORBA::string_dup ("second string2"));
495 CORBA::String_var sresult =
496 test_object->string_op2(p1->_boxed_in(), p2->_boxed_inout(),
497 p3->_boxed_out());
499 OBV_VERITY (ACE_OS::strcmp(p2->_value (), "2second string") == 0);
500 OBV_VERITY (ACE_OS::strcmp(p3->_value (), "2second string") == 0);
501 OBV_VERITY (ACE_OS::strcmp(sresult.in (), "1string") == 0);
503 catch (const CORBA::Exception& ex)
505 ex._tao_print_exception ("test_boxed_string_invocations");
506 fail = 1;
508 catch (...)
510 ACE_DEBUG ((LM_DEBUG,
511 "(%P|%t) test_boxed_string_invocations: "
512 "caught a C++ exception\n"));
513 fail = 1;
515 if (p1) p1->_remove_ref ();
516 if (p2) p2->_remove_ref ();
517 if (p3) p3->_remove_ref ();
519 return fail;
523 // Test boxed sequence types.
525 int test_boxed_sequence (void)
527 int fail = 0;
530 VBseqlong *vbseqlong1 = 0;
531 ACE_NEW_RETURN (vbseqlong1,
532 VBseqlong (),
535 VBseqlong *temp = 0;
536 ACE_NEW_RETURN (temp,
537 VBseqlong (),
540 VBseqlong_var vbseqlong2 (temp);
541 OBV_VERITY (vbseqlong1->length() == 0);
542 OBV_VERITY (vbseqlong2->length() == 0);
543 CORBA::Long *longarray = 0;
544 ACE_NEW_RETURN (longarray,
545 CORBA::Long[3],
547 longarray[0] = 101;
548 longarray[1] = 202;
549 longarray[2] = 303;
551 // Create a sequence
552 TDseqlong *temp2 = 0;
553 ACE_NEW_RETURN (temp2,
554 TDseqlong(10, 3, longarray, 1),
556 TDseqlong_var seqlong1 (temp2);
557 OBV_VERITY (seqlong1[0] == 101 && seqlong1[2] == 303);
559 VBseqlong *vbseqlong3 = 0;
560 ACE_NEW_RETURN (vbseqlong3,
561 VBseqlong(seqlong1.in()),
564 // Test sequence ctor.
565 VBseqlong *vbseqlong4 = 0;
566 ACE_NEW_RETURN (vbseqlong4,
567 VBseqlong(10, 3, longarray, 0),
570 // Test assignment and subscript operators
571 vbseqlong2 = vbseqlong3;
572 OBV_VERITY (vbseqlong2->length() == 3);
573 VBseqlong &vbseqlong5 = *vbseqlong2.inout();
574 OBV_VERITY (vbseqlong5[2] == 303);
575 vbseqlong5[2] = 444;
576 OBV_VERITY (vbseqlong5[2] == 444);
577 OBV_VERITY (seqlong1[0] == 101 && seqlong1[2] == 303);
578 OBV_VERITY ((*vbseqlong4)[0] == 101 && (*vbseqlong4)[2] == 303);
579 seqlong1[0] = 111;
580 OBV_VERITY ((*vbseqlong4)[0] == 111);
581 OBV_VERITY (vbseqlong4->maximum() == 10);
582 *vbseqlong4 = vbseqlong1->_value();
583 OBV_VERITY (vbseqlong4->length() == 0);
585 // Test copy_value
586 VBseqlong *vbseqlong6 = VBseqlong::_downcast( vbseqlong4->_copy_value() );
587 if (vbseqlong6 == 0)
589 fail++;
590 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Failure at line %l\n"));
592 else
594 OBV_VERITY (vbseqlong6->length() == 0);
595 vbseqlong6->_remove_ref ();
598 // release
599 vbseqlong1->_remove_ref ();
600 vbseqlong4->_remove_ref ();
602 catch (const ::CORBA::Exception &ex)
604 ex._tao_print_exception ("test_boxed_sequence");
605 fail = 1;
607 catch (...)
609 ACE_ERROR ((LM_ERROR, "test_boxed_sequence : unexpected exception caught\n"));
611 return fail;
616 int test_boxed_sequence_invocations (Test * test_object)
618 int fail = 0;
619 VBseqlong *p1 = 0;
620 VBseqlong *p2 = 0;
621 VBseqlong *p3;
626 //============================================================
627 // Test method invocation with boxed value
628 //============================================================
630 ACE_NEW_RETURN (p1,
631 VBseqlong(4),
633 ACE_NEW_RETURN (p2,
634 VBseqlong(3),
636 p1->length(4);
637 p2->length(3);
639 (*p1)[0] = 10;
640 (*p1)[1] = 9;
641 (*p1)[2] = 8;
642 (*p1)[3] = 7;
644 (*p2)[0] = 100;
645 (*p2)[1] = 99;
646 (*p2)[2] = 98;
648 OBV_VERITY ((*p1)[0] == 10);
649 OBV_VERITY ((*p1)[1] == 9);
650 OBV_VERITY ((*p1)[2] == 8);
651 OBV_VERITY ((*p1)[3] == 7);
653 VBseqlong_var result = test_object->seq_op1(p1, p2, p3);
655 OBV_VERITY ((*p2)[0] == 100*3);
656 OBV_VERITY ((*p2)[1] == 99*3);
657 OBV_VERITY ((*p2)[2] == 98*3);
658 OBV_VERITY ((*p3)[0] == 100*5);
659 OBV_VERITY ((*p3)[1] == 99*5);
660 OBV_VERITY ((*p3)[2] == 98*5);
661 OBV_VERITY ((*result.in ())[0] == 10);
662 OBV_VERITY ((*result.in ())[1] == 9);
663 OBV_VERITY ((*result.in ())[2] == 8);
664 OBV_VERITY ((*result.in ())[3] == 7);
666 //============================================================
667 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
668 //============================================================
670 test_object->seq_op2(p1->_boxed_in(), p2->_boxed_inout(),
671 p3->_boxed_out());
673 OBV_VERITY ((*p2)[0] == 100*3*3);
674 OBV_VERITY ((*p2)[1] == 99*3*3);
675 OBV_VERITY ((*p2)[2] == 98*3*3);
676 OBV_VERITY ((*p3)[0] == (*p1)[0]*5);
677 OBV_VERITY ((*p3)[1] == (*p1)[1]*5);
678 OBV_VERITY ((*p3)[2] == (*p1)[2]*5);
679 OBV_VERITY ((*p3)[3] == (*p1)[3]*5);
681 catch (const CORBA::Exception& ex)
683 ex._tao_print_exception ("test_boxed_sequence_invocations");
684 fail = 1;
686 catch (...)
688 ACE_DEBUG ((LM_DEBUG,
689 "(%P|%t) test_boxed_sequence_invocations: "
690 "caught a C++ exception\n"));
691 fail = 1;
694 if (p1) p1->_remove_ref ();
695 if (p2) p2->_remove_ref ();
696 if (p3) p3->_remove_ref ();
698 return fail;
703 // Test a boxed struct type. This is not templated since the struct
704 // members are accessed by name, so this is specific to a certain IDL.
706 int test_boxed_struct (void)
708 int fail = 0;
710 Fixed_Struct1 *fixed_struct_a = 0;
711 ACE_NEW_RETURN (fixed_struct_a,
712 Fixed_Struct1,
714 fixed_struct_a->l = 3233;
715 fixed_struct_a->abstruct.s1 = 73;
716 fixed_struct_a->abstruct.s2 = 37;
718 // Test the VBfixed_struct1 constructor
719 VBfixed_struct1 *valuebox1 = 0;
720 ACE_NEW_RETURN (valuebox1,
721 VBfixed_struct1 (*fixed_struct_a),
724 // Test boxed copy ctor.
725 VBfixed_struct1* valuebox2_ptr = 0;
726 ACE_NEW_RETURN (valuebox2_ptr,
727 VBfixed_struct1 (*valuebox1),
729 VBfixed_struct1_var valuebox2 = valuebox2_ptr;
731 OBV_VERITY (valuebox1->l () == valuebox2->l ());
732 OBV_VERITY ((valuebox1->abstruct ()).s1 == (valuebox2->abstruct ()).s1 );
733 OBV_VERITY ((valuebox1->abstruct ()).s2 == (valuebox2->abstruct ()).s2 );
735 // Change an element
736 valuebox1->l (505);
737 OBV_VERITY (valuebox1->l () != valuebox2->l ());
739 // Change some more, to test other types.
740 (valuebox2->abstruct ()).s1 = 667;
741 OBV_VERITY ((valuebox1->abstruct ()).s1 != (valuebox2->abstruct ()).s1 );
742 (valuebox2->abstruct ()).s2 = 1667;
743 OBV_VERITY ((valuebox1->abstruct ()).s2 != (valuebox2->abstruct ()).s2 );
745 Fixed_Struct1 *fixed_struct_b = 0;
746 ACE_NEW_RETURN (fixed_struct_b,
747 Fixed_Struct1,
749 fixed_struct_b->l = 7372;
750 fixed_struct_b->abstruct.s1 = 11;
751 fixed_struct_b->abstruct.s2 = 51;
753 // Make another VBfixed_struct1
754 VBfixed_struct1 *valuebox3 = 0;
755 ACE_NEW_RETURN (valuebox3,
756 VBfixed_struct1 (),
759 // Test assignment operator
760 *valuebox3 = *fixed_struct_b;
762 OBV_VERITY (valuebox3->l () == fixed_struct_b->l);
763 OBV_VERITY ((valuebox3->abstruct ()).s1 == fixed_struct_b->abstruct.s1);
764 OBV_VERITY ((valuebox3->abstruct ()).s2 == fixed_struct_b->abstruct.s2);
766 // Test _value modifier method
767 valuebox2->_value (*fixed_struct_b);
768 OBV_VERITY (valuebox2->l () == fixed_struct_b->l);
769 OBV_VERITY ((valuebox2->abstruct ()).s1 == fixed_struct_b->abstruct.s1);
770 OBV_VERITY ((valuebox2->abstruct ()).s2 == fixed_struct_b->abstruct.s2);
772 // Test _copy_value and _downcast
773 VBfixed_struct1_var valuebox4 =
774 VBfixed_struct1::_downcast (valuebox3->_copy_value ());
775 if (valuebox4.in () == 0)
777 fail++;
778 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Failure at line %l\n"));
780 else
782 OBV_VERITY (valuebox4->l () == fixed_struct_b->l);
783 OBV_VERITY ((valuebox4->abstruct ()).s1 == fixed_struct_b->abstruct.s1);
784 OBV_VERITY ((valuebox4->abstruct ()).s2 == fixed_struct_b->abstruct.s2);
788 // valuebox1 and valuebox3 must be explicitly removed.
789 CORBA::remove_ref (valuebox1);
790 CORBA::remove_ref (valuebox3);
793 // as well as the structs we new'ed.
794 delete fixed_struct_a;
795 delete fixed_struct_b;
798 // Other types are _var so their dtors will clean up remaining
799 // allocations.
801 return fail;
806 int test_boxed_struct_invocations (Test * test_object)
808 int fail = 0;
813 //============================================================
814 // Fixed struct
815 // Test method invocation with boxed value
816 //============================================================
817 Fixed_Struct1 fs1;
818 fs1.l = 29;
819 fs1.abstruct.s1 = 117;
820 fs1.abstruct.s2 = 21;
822 VBfixed_struct1 *p1 = 0;
823 ACE_NEW_RETURN (p1,
824 VBfixed_struct1(fs1),
827 Fixed_Struct1 fs2;
828 fs2.l = 92;
829 fs2.abstruct.s1 = 171;
830 fs2.abstruct.s2 = 12;
832 VBfixed_struct1 *p2 = 0;
833 ACE_NEW_RETURN (p2,
834 VBfixed_struct1(fs2),
837 VBfixed_struct1 *p3;
839 OBV_VERITY (p1->l() == 29);
840 OBV_VERITY ((p1->abstruct()).s1 == 117);
841 OBV_VERITY ((p1->abstruct()).s2 == 21);
843 VBfixed_struct1_var result = test_object->struct_op1(p1, p2, p3);
845 OBV_VERITY (p2->l() == 92*3);
846 OBV_VERITY ((p2->abstruct()).s1 == 171*3);
847 OBV_VERITY ((p2->abstruct()).s2 == 12*3);
849 OBV_VERITY (p3->l() == 92*5);
850 OBV_VERITY ((p3->abstruct()).s1 == 171*5);
851 OBV_VERITY ((p3->abstruct()).s2 == 12*5);
853 OBV_VERITY (result->l() == fs1.l);
854 OBV_VERITY ((result->abstruct()).s1 == fs1.abstruct.s1);
855 OBV_VERITY ((result->abstruct()).s2 == fs1.abstruct.s2);
857 //============================================================
858 // Fixed struct
859 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
860 //============================================================
862 test_object->struct_op2(p1->_boxed_in(), p2->_boxed_inout(),
863 p3->_boxed_out());
865 OBV_VERITY (p2->l() == 92*3*3);
866 OBV_VERITY ((p2->abstruct()).s1 == 171*3*3);
867 OBV_VERITY ((p2->abstruct()).s2 == 12*3*3);
869 OBV_VERITY (p3->l() == fs1.l);
870 OBV_VERITY ((p3->abstruct()).s1 == fs1.abstruct.s1);
871 OBV_VERITY ((p3->abstruct()).s2 == fs1.abstruct.s2);
874 p1->_remove_ref ();
875 p2->_remove_ref ();
876 p3->_remove_ref ();
879 //============================================================
880 // Variable struct
881 // Test method invocation with boxed value
882 //============================================================
884 Variable_Struct1 vs1;
885 vs1.l = 29;
886 vs1.str = CORBA::string_dup ("variable1");
888 VBvariable_struct1 *p4 = 0;
889 ACE_NEW_RETURN (p4,
890 VBvariable_struct1 (vs1),
893 Variable_Struct1 vs2;
894 vs2.l = 37;
895 vs2.str = "variable2";
897 VBvariable_struct1 *p5 = 0;
898 ACE_NEW_RETURN (p5,
899 VBvariable_struct1 (vs2),
902 VBvariable_struct1 *p6;
905 OBV_VERITY (p4->l() == 29);
906 OBV_VERITY (ACE_OS::strcmp(p4->str(), "variable1") == 0);
908 VBvariable_struct1_var result2 = test_object->struct_op3(p4, p5, p6);
910 OBV_VERITY (p5->l() == vs2.l*3);
911 OBV_VERITY (ACE_OS::strcmp(p5->str(), "2variable") == 0);
913 OBV_VERITY (p6->l() == vs2.l*3);
914 OBV_VERITY (ACE_OS::strcmp(p6->str(), "2variable") == 0);
916 OBV_VERITY (result2->l() == vs1.l);
917 OBV_VERITY (ACE_OS::strcmp(result2->str(), vs1.str) == 0);
920 //============================================================
921 // Variable struct
922 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
923 //============================================================
925 test_object->struct_op4(p4->_boxed_in(), p5->_boxed_inout(),
926 p6->_boxed_out());
928 OBV_VERITY (p5->l() == vs2.l*3*3);
929 OBV_VERITY (ACE_OS::strcmp(p5->str(), "e2variabl") == 0);
931 OBV_VERITY (p6->l() == vs1.l);
932 OBV_VERITY (ACE_OS::strcmp(p6->str(), vs1.str) == 0);
935 p4->_remove_ref ();
936 p5->_remove_ref ();
937 p6->_remove_ref ();
939 catch (const CORBA::Exception& ex)
941 ex._tao_print_exception ("test_boxed_struct_invocations");
942 fail = 1;
944 catch (...)
946 ACE_DEBUG ((LM_DEBUG,
947 "(%P|%t) test_boxed_struct_invocations: "
948 "caught a C++ exception\n"));
949 fail = 1;
952 return fail;
956 // Test boxed array types.
958 int test_boxed_array()
960 int fail = 0;
961 LongArray la;
962 la[0] = 101;
963 la[1] = 202;
964 la[2] = 303;
966 // three ctors
967 VBlongarray *valuebox1 = 0;
968 ACE_NEW_RETURN (valuebox1,
969 VBlongarray,
971 VBlongarray *valuebox2 = 0;
972 ACE_NEW_RETURN (valuebox2,
973 VBlongarray(la),
975 VBlongarray *valuebox3 = 0;
976 ACE_NEW_RETURN (valuebox3,
977 VBlongarray(*valuebox2),
980 OBV_VERITY ((*valuebox2)[0] == 101
981 && valuebox2->_value()[1] == 202
982 && valuebox2->_value()[2] == 303);
984 OBV_VERITY ((*valuebox3)[0] == 101
985 && (*valuebox3)[1] == 202
986 && (*valuebox3)[2] == 303);
988 (*valuebox3)[0] = 111;
989 valuebox3->_value()[1] = 222;
991 OBV_VERITY ((*valuebox2)[0] == 101
992 && (*valuebox2)[1] == 202
993 && (*valuebox2)[2] == 303);
995 OBV_VERITY ((*valuebox3)[0] == 111
996 && (*valuebox3)[1] == 222
997 && (*valuebox3)[2] == 303);
999 *valuebox1 = la;
1001 OBV_VERITY ((*valuebox1)[0] == 101
1002 && valuebox1->_value()[1] == 202
1003 && valuebox1->_value()[2] == 303);
1005 valuebox2->_value(la);
1007 OBV_VERITY ((*valuebox2)[0] == 101
1008 && valuebox2->_value()[1] == 202
1009 && valuebox2->_value()[2] == 303);
1011 LongArray_var lv_la(LongArray_dup(la));
1012 *valuebox2 = lv_la.in();
1014 *valuebox2 = valuebox3->_value();
1015 valuebox3->_value()[1] = 777;
1016 OBV_VERITY ((*valuebox2)[0] == 111
1017 && valuebox2->_value()[1] == 222
1018 && valuebox2->_value()[2] == 303);
1020 // release
1021 valuebox1->_remove_ref ();
1022 valuebox2->_remove_ref ();
1023 valuebox3->_remove_ref ();
1025 return fail;
1030 int test_boxed_array_invocations (Test * test_object)
1032 int fail = 0;
1036 //============================================================
1037 // Array (fixed)
1038 // Test method invocation with boxed value
1039 //============================================================
1041 LongArray la;
1042 la[0] = 101;
1043 la[1] = 202;
1044 la[2] = 303;
1046 VBlongarray *p1 = 0;
1047 ACE_NEW_RETURN (p1,
1048 VBlongarray (la),
1051 LongArray la2;
1052 la2[0] = 3101;
1053 la2[1] = 3202;
1054 la2[2] = 3303;
1056 VBlongarray *p2 = 0;
1057 ACE_NEW_RETURN (p2,
1058 VBlongarray (la2),
1061 OBV_VERITY ((*p1)[0] == 101
1062 && (*p1)[1] == 202
1063 && (*p1)[2] == 303);
1065 VBlongarray *p3;
1067 VBlongarray_var result = test_object->array_op1 (p1, p2, p3);
1069 OBV_VERITY ((*p2)[0] == (3101*3)
1070 && (*p2)[1] == (3202*3)
1071 && (*p3)[2] == (3303*3));
1073 OBV_VERITY ((*p3)[0] == (3101*3)
1074 && (*p3)[1] == (3202*3)
1075 && (*p3)[2] == (3303*3));
1077 OBV_VERITY ((*result.in ())[0] == 101
1078 && (*result.in ())[1] == 202
1079 && (*result.in ())[2] == 303);
1081 //============================================================
1082 // Array (fixed)
1083 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
1084 //============================================================
1086 // Exclude the following test for now until issues with _boxed_out()
1087 // for arrays are resolved.
1088 #if 0
1089 test_object->array_op2(p1->_boxed_in(), p2->_boxed_inout(),
1090 p3->_boxed_out());
1092 OBV_VERITY ((*p2)[0] == (3101*3*3)
1093 && (*p2)[1] == (3202*3*3)
1094 && (*p2)[2] == (3303*3*3));
1096 OBV_VERITY ((*p3)[0] == (*p1)[0]
1097 && (*p3)[1] == (*p1)[1]
1098 && (*p3)[2] == (*p1)[2]);
1099 #endif
1101 p1->_remove_ref ();
1102 p2->_remove_ref ();
1103 p3->_remove_ref ();
1105 //============================================================
1106 // Array (variable)
1107 // Test method invocation with boxed value
1108 //============================================================
1110 StringArray sa;
1111 sa[0] = CORBA::string_dup ("in string1");
1112 sa[1] = CORBA::string_dup ("in string2");
1114 VBstringarray *p4 = 0;
1115 ACE_NEW_RETURN (p4,
1116 VBstringarray (sa),
1119 StringArray sa2;
1120 sa2[0] = CORBA::string_dup ("inout string1");
1121 sa2[1] = CORBA::string_dup ("inout string2");
1123 VBstringarray *p5 = 0;
1124 ACE_NEW_RETURN (p5,
1125 VBstringarray (sa2),
1128 OBV_VERITY (ACE_OS::strcmp((*p4)[0], sa[0]) == 0);
1129 OBV_VERITY (ACE_OS::strcmp((*p4)[1], sa[1]) == 0);
1131 VBstringarray *p6;
1133 VBstringarray_var result2 = test_object->array_op3 (p4, p5, p6);
1135 OBV_VERITY (ACE_OS::strcmp((*p5)[0], "1inout string") == 0);
1136 OBV_VERITY (ACE_OS::strcmp((*p5)[1], "2inout string") == 0);
1137 OBV_VERITY (ACE_OS::strcmp((*p6)[0], "1inout string") == 0);
1138 OBV_VERITY (ACE_OS::strcmp((*p6)[1], "2inout string") == 0);
1139 OBV_VERITY (ACE_OS::strcmp((*result2.in ())[0], sa[0]) == 0);
1140 OBV_VERITY (ACE_OS::strcmp((*result2.in ())[1], sa[1]) == 0);
1142 //============================================================
1143 // Array (variable)
1144 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
1145 //============================================================
1147 // Disable the following for now. Need to troubleshoot it.
1148 #if 0
1149 // Following gets compilation error on parameter 3
1150 // test_object->array_op4(p4->_boxed_in(), p5->_boxed_inout(),
1151 // p6->_boxed_out());
1153 // Trying the following variation to troubleshoot. No compilation error
1154 // but p6 is unchanged after return from method.
1155 StringArray sa_experimental;
1156 StringArray_slice *slice = p6->_boxed_out();
1157 StringArray_out an_out (slice);
1159 test_object->array_op4(p4->_boxed_in(), p5->_boxed_inout(),
1160 an_out);
1162 ACE_DEBUG ((LM_DEBUG, "(%P|%t) after array_op4\n"));
1163 ACE_DEBUG ((LM_DEBUG, "(%P|%t) p5[0]=%s\n", (const char *)((*p5)[0])));
1164 ACE_DEBUG ((LM_DEBUG, "(%P|%t) p5[1]=%s\n", (const char *)((*p5)[1])));
1165 ACE_DEBUG ((LM_DEBUG, "(%P|%t) p6[0]=%s\n", (const char *)((*p6)[0])));
1166 ACE_DEBUG ((LM_DEBUG, "(%P|%t) p6[1]=%s\n", (const char *)((*p6)[1])));
1167 OBV_VERITY (ACE_OS::strcmp((*p5)[0], "g1inout strin") == 0);
1168 OBV_VERITY (ACE_OS::strcmp((*p5)[1], "g2inout strin") == 0);
1169 OBV_VERITY (ACE_OS::strcmp((*p6)[0], sa[0]) == 0);
1170 OBV_VERITY (ACE_OS::strcmp((*p6)[1], sa[1]) == 0);
1171 #endif
1173 p4->_remove_ref ();
1174 p5->_remove_ref ();
1175 p6->_remove_ref ();
1178 catch (const CORBA::Exception& ex)
1180 ex._tao_print_exception ("test_boxed_array_invocations");
1181 fail = 1;
1183 catch (...)
1185 ACE_DEBUG ((LM_DEBUG,
1186 "(%P|%t) test_boxed_array_invocations: "
1187 "caught a C++ exception\n"));
1188 fail = 1;
1191 return fail;
1196 // Test a boxed union type.
1198 int test_boxed_union()
1200 int fail = 0;
1202 VBfixed_union1 *ptemp;
1203 ACE_NEW_RETURN (ptemp,
1204 VBfixed_union1 (),
1206 VBfixed_union1_var valuebox1(ptemp);
1209 Fixed_Union1 *ptemp2;
1210 ACE_NEW_RETURN (ptemp2,
1211 Fixed_Union1 (),
1213 Fixed_Union1_var fixed_union1(ptemp2);
1215 // Test modifiers, accessors, discriminant access
1216 valuebox1->m1 (37);
1217 OBV_VERITY (valuebox1->m1 () == 37);
1218 OBV_VERITY (valuebox1->_d () == 1 || valuebox1->_d () == 2);
1220 // Explicitly set discriminant, make sure thats the only thing
1221 // that changes.
1222 valuebox1->_d (2);
1223 OBV_VERITY (valuebox1->_d () == 2);
1224 OBV_VERITY (valuebox1->m1 () == 37);
1225 valuebox1->_d (1);
1226 OBV_VERITY (valuebox1->_d () == 1);
1227 OBV_VERITY (valuebox1->m1 () == 37);
1229 // Use _value() to access
1230 valuebox1->_value ()._d (2);
1231 OBV_VERITY (valuebox1->_d () == 2);
1233 // Use _value as modifier.
1234 valuebox1->_value (fixed_union1.in());
1235 OBV_VERITY (valuebox1->_d () != 1 && valuebox1->_d () != 2);
1238 VBfixed_union1* valuebox2_ptr = 0;
1239 ACE_NEW_RETURN (valuebox2_ptr,
1240 VBfixed_union1 (),
1242 VBfixed_union1_var valuebox2 (valuebox2_ptr);
1243 valuebox2->m2(333);
1244 OBV_VERITY (valuebox2->_d () == 2);
1246 // Test copy ctor
1247 VBfixed_union1* valuebox3_ptr = 0;
1248 ACE_NEW_RETURN (valuebox3_ptr,
1249 VBfixed_union1 (*valuebox2.in ()),
1251 VBfixed_union1_var valuebox3 (valuebox3_ptr);
1252 OBV_VERITY (valuebox3->_d () == 2);
1253 OBV_VERITY (valuebox3->m2 () == 333);
1255 // Test assignment op
1256 valuebox3->m2 (456);
1257 *valuebox3.in () = valuebox2->_value ();
1258 OBV_VERITY (valuebox3->_d () == 2);
1259 OBV_VERITY (valuebox3->m2 () == 333);
1261 // Test constructor taking union argument
1262 fixed_union1->m2 (137);
1263 VBfixed_union1 *valuebox4_ptr = 0;
1264 ACE_NEW_RETURN (valuebox4_ptr,
1265 VBfixed_union1 (fixed_union1.in ()),
1267 VBfixed_union1_var valuebox4 (valuebox4_ptr);
1268 OBV_VERITY (valuebox4->m2 () == 137);
1269 OBV_VERITY (valuebox4->_d () == 1 || valuebox4->_d () == 2);
1271 return fail;
1277 int test_boxed_union_invocations (Test * test_object)
1279 int fail = 0;
1283 //============================================================
1284 // Union (fixed)
1285 // Test method invocation with boxed value
1286 //============================================================
1288 Fixed_Union1 *ptemp = 0;
1289 ACE_NEW_RETURN (ptemp,
1290 Fixed_Union1 (),
1292 Fixed_Union1_var fixed_union1(ptemp);
1294 fixed_union1->m1 (321);
1295 VBfixed_union1 *p1 = 0;
1296 ACE_NEW_RETURN (p1,
1297 VBfixed_union1 (fixed_union1.in ()),
1300 Fixed_Union1 *ptemp2 = 0;
1301 ACE_NEW_RETURN (ptemp2,
1302 Fixed_Union1 (),
1304 Fixed_Union1_var fixed_union2(ptemp2);
1305 fixed_union2->m2 (789);
1306 VBfixed_union1 *p2 = 0;
1307 ACE_NEW_RETURN (p2,
1308 VBfixed_union1 (fixed_union2.in ()),
1311 OBV_VERITY (p1->_d () == 1);
1312 OBV_VERITY (p1->m1 () == 321);
1313 OBV_VERITY (p2->_d () == 2);
1314 OBV_VERITY (p2->m2 () == 789);
1316 VBfixed_union1 * p3;
1318 VBfixed_union1_var result = test_object->union_op1 (p1, p2, p3);
1320 OBV_VERITY (p2->_d () == 2);
1321 OBV_VERITY (p2->m2 () == 789*3);
1322 OBV_VERITY (p3->_d () == 1);
1323 OBV_VERITY (p3->m1 () == 321*3);
1324 OBV_VERITY (result->_d () == 1);
1325 OBV_VERITY (result->m1 () == 321*3);
1328 //============================================================
1329 // Union (fixed)
1330 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
1331 //============================================================
1333 test_object->union_op2(p1->_boxed_in(), p2->_boxed_inout(),
1334 p3->_boxed_out());
1336 OBV_VERITY (p2->_d () == 2);
1337 OBV_VERITY (p2->m2 () == 789*3*3);
1339 OBV_VERITY (p3->_d () == 1);
1340 OBV_VERITY (p3->m1 () == 321);
1342 p1->_remove_ref ();
1343 p2->_remove_ref ();
1344 p3->_remove_ref ();
1346 //============================================================
1347 // Union (variable)
1348 // Test method invocation with boxed value
1349 //============================================================
1351 Variable_Union1_var variable_union1;
1352 ACE_NEW_RETURN (variable_union1,
1353 Variable_Union1 (),
1355 variable_union1->m1 (321);
1356 // TODO : resource leak
1357 VBvariable_union1 *p4 = 0;
1358 ACE_NEW_RETURN (p4,
1359 VBvariable_union1 (variable_union1.in ()),
1362 Variable_Union1_var variable_union2;
1363 ACE_NEW_RETURN (variable_union2,
1364 Variable_Union1 (),
1366 variable_union2->m2 (CORBA::string_dup ("abracadabra"));
1367 VBvariable_union1 *p5 = 0;
1368 ACE_NEW_RETURN (p5,
1369 VBvariable_union1 (variable_union2.in ()),
1372 OBV_VERITY (p4->_d () == 1);
1373 OBV_VERITY (p4->m1 () == 321);
1374 OBV_VERITY (p5->_d () == 2);
1375 OBV_VERITY (ACE_OS::strcmp(p5->m2 (), "abracadabra") == 0);
1377 VBvariable_union1 * p6;
1379 VBvariable_union1_var result2 = test_object->union_op3 (p4, p5, p6);
1381 OBV_VERITY (p5->_d () == 2);
1382 OBV_VERITY (ACE_OS::strcmp(p5->m2 (), "aabracadabr") == 0);
1383 OBV_VERITY (p6->_d () == 1);
1384 OBV_VERITY (p6->m1 () == 321);
1385 OBV_VERITY (result2->_d () == 1);
1386 OBV_VERITY (result2->m1 () == 321);
1388 //============================================================
1389 // Union (variable)
1390 // Test _boxed_in(), _boxed_inout(), and _boxed_out())
1391 //============================================================
1393 p4->m1 (1722);
1395 test_object->union_op4(p4->_boxed_in(), p5->_boxed_inout(),
1396 p6->_boxed_out());
1398 OBV_VERITY (p5->_d () == 2);
1399 OBV_VERITY (ACE_OS::strcmp(p5->m2 (), "raabracadab") == 0);
1401 OBV_VERITY (p6->_d () == 1);
1402 OBV_VERITY (p6->m1 () == 1722);
1404 p4->_remove_ref ();
1405 p5->_remove_ref ();
1406 p6->_remove_ref ();
1409 catch (const CORBA::Exception& ex)
1411 ex._tao_print_exception ("test_boxed_union_invocations");
1412 fail = 1;
1414 catch (...)
1416 ACE_DEBUG ((LM_DEBUG,
1417 "(%P|%t) test_boxed_union_invocations: "
1418 "caught a C++ exception\n"));
1419 fail = 1;
1422 return fail;
1426 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
1428 Test_var test_object;
1429 CORBA::ORB_var orb;
1434 orb = CORBA::ORB_init (argc, argv);
1436 if (parse_args (argc, argv) != 0)
1437 return 1;
1439 // Obtain reference to the object.
1440 CORBA::Object_var tmp =
1441 orb->string_to_object(ior);
1443 test_object = Test::_narrow(tmp.in ());
1445 if (CORBA::is_nil (test_object.in ()))
1447 ACE_ERROR_RETURN ((LM_DEBUG,
1448 "Nil Test reference <%s>\n",
1449 ior),
1453 catch (const CORBA::Exception& ex)
1455 ex._tao_print_exception ("Initialization failure");
1456 return 1;
1458 catch (...)
1460 ACE_DEBUG ((LM_DEBUG,
1461 "(%P|%t) Initialization failure: caught a C++ exception\n"));
1462 return 1;
1465 int fail = 0;
1467 fail = test_basic ();
1469 fail += test_basic_invocations (test_object.in ());
1471 fail += test_boxed_string ();
1473 fail += test_boxed_string_invocations (test_object.in ());
1475 fail += test_boxed_sequence ();
1477 fail += test_boxed_sequence_invocations (test_object.in ());
1479 fail += test_boxed_struct ();
1481 fail += test_boxed_struct_invocations (test_object.in ());
1483 fail += test_boxed_array ();
1485 fail += test_boxed_array_invocations (test_object.in ());
1487 fail += test_boxed_union();
1489 fail += test_boxed_union_invocations (test_object.in ());
1494 test_object->shutdown ();
1496 ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - test finished\n"));
1498 orb->destroy ();
1500 catch (const CORBA::Exception& ex)
1502 ex._tao_print_exception ("Exception caught:");
1503 return 1;
1506 return (fail) ? 1 : 0;