1 //=============================================================================
3 * @file test_dynarray.cpp
5 * Implementation of the DynArray test
7 * @author Jeff Parsons <parsons@cs.wustl.edu>
9 //=============================================================================
12 #include "test_dynarray.h"
13 #include "da_testsC.h"
15 #include "tao/DynamicAny/DynamicAny.h"
18 Test_DynArray::Test_DynArray (CORBA::ORB_var orb
, int debug
)
20 test_name_ (CORBA::string_dup ("test_dynarray")),
26 Test_DynArray::~Test_DynArray ()
28 CORBA::string_free (this->test_name_
);
33 Test_DynArray::test_name () const
35 return this->test_name_
;
39 Test_DynArray::run_test ()
41 Data
data (this->orb_
);
43 DynAnyTests::test_array ta
= {0};
48 "\t*=*=*=*= %C =*=*=*=*\n",
52 "testing: constructor(Any)/insert/get/seek/rewind/current_component\n"));
54 CORBA::Object_var factory_obj
=
55 this->orb_
->resolve_initial_references ("DynAnyFactory");
57 DynamicAny::DynAnyFactory_var dynany_factory
=
58 DynamicAny::DynAnyFactory::_narrow (factory_obj
.in ());
60 if (CORBA::is_nil (dynany_factory
.in ()))
62 ACE_ERROR_RETURN ((LM_ERROR
,
63 "Nil dynamic any factory after narrow\n"),
67 DynAnyAnalyzer
analyzer (this->orb_
.in (),
72 in_any1
<<= DynAnyTests::test_array_forany (ta
);
73 DynamicAny::DynAny_var dp1
=
74 dynany_factory
->create_dyn_any (in_any1
);
76 DynamicAny::DynArray_var fa1
=
77 DynamicAny::DynArray::_narrow (dp1
.in ());
81 fa1
->insert_long (data
.m_long1
);
85 CORBA::Long l_out1
= data
.m_long2
;
88 l_out1
= fa1
->get_long ();
90 if (l_out1
== data
.m_long1
)
100 ACE_DEBUG ((LM_DEBUG
,
101 "testing: constructor(TypeCode)/from_any/to_any\n"));
103 DynamicAny::DynAny_var ftc1_base
=
104 dynany_factory
->create_dyn_any_from_type_code (DynAnyTests::_tc_test_array
);
106 DynamicAny::DynArray_var ftc1
=
107 DynamicAny::DynArray::_narrow (ftc1_base
.in ());
109 if (CORBA::is_nil (ftc1
.in ()))
111 ACE_ERROR_RETURN ((LM_ERROR
,
112 "DynArray::_narrow() returned nil\n"),
116 ta
[1U] = data
.m_long1
;
118 in_any2
<<= DynAnyTests::test_array_forany (ta
);
120 ftc1
->from_any (in_any2
);
123 analyzer
.analyze (ftc1
.in ());
125 CORBA::Any_var out_any1
=
128 DynAnyTests::test_array_forany ta_out
;
129 out_any1
.in () >>= ta_out
;
131 if (ta_out
[1U] == data
.m_long1
)
133 ACE_DEBUG ((LM_DEBUG
,
138 ++this->error_count_
;
141 ACE_DEBUG ((LM_DEBUG
,
142 "testing: set_elements/get_elements\n"));
144 DynamicAny::AnySeq
as_in (2);
147 in_any3
<<= data
.m_long1
;
150 ftc1
->set_elements (as_in
);
152 DynamicAny::AnySeq_var as_out
=
153 ftc1
->get_elements ();
154 CORBA::Any out_any2
= as_out
[1U];
158 if (l_out2
== data
.m_long1
)
160 ACE_DEBUG ((LM_DEBUG
,
165 ++this->error_count_
;
172 catch (const CORBA::Exception
& ex
)
174 ex
._tao_print_exception ("test_dynarray::run_test");
175 ++this->error_count_
;
178 ACE_DEBUG ((LM_DEBUG
,
180 this->error_count_
));
182 return !!error_count_
;