diff options
author | eas <eas@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-02-21 18:23:14 +0000 |
---|---|---|
committer | eas <eas@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-02-21 18:23:14 +0000 |
commit | 5b750fa0642bd9003ac998792e2e09fa6efbe3a3 (patch) | |
tree | 61f2a50aab0d7841b0787f9a85c3b70d48dcb7ce /TAO/tests | |
parent | eb2e944301735f7cd49788255ec680352d55affa (diff) | |
download | ATCD-5b750fa0642bd9003ac998792e2e09fa6efbe3a3.tar.gz |
ChangeLogTag:Fri Feb 21 17:49:54 2003 Edward Scott <eas@prismtechnologies.com>
Diffstat (limited to 'TAO/tests')
-rw-r--r-- | TAO/tests/DynAny_Test/da_tests.idl | 14 | ||||
-rw-r--r-- | TAO/tests/DynAny_Test/test_dynstruct.cpp | 85 | ||||
-rw-r--r-- | TAO/tests/DynAny_Test/test_dynunion.cpp | 68 |
3 files changed, 164 insertions, 3 deletions
diff --git a/TAO/tests/DynAny_Test/da_tests.idl b/TAO/tests/DynAny_Test/da_tests.idl index 4b797e77f4d..7bf0456b638 100644 --- a/TAO/tests/DynAny_Test/da_tests.idl +++ b/TAO/tests/DynAny_Test/da_tests.idl @@ -6,13 +6,13 @@ module DynAnyTests { - struct enclosed_struct + struct enclosed_struct { float f; short s; }; - struct test_struct + struct test_struct { char c; long l; @@ -24,7 +24,7 @@ module DynAnyTests const unsigned long DIM = 2; typedef long test_array [DIM]; - enum test_enum + enum test_enum { TE_ZEROTH, TE_FIRST, @@ -41,4 +41,12 @@ module DynAnyTests case TE_THIRD: string str; case TE_ZEROTH: octet o; }; + + typedef test_struct test_struct_alias; + typedef test_union test_union_alias; + + union test_implicit_def switch (boolean) { + case TRUE : + test_enum tenum; + } ; }; diff --git a/TAO/tests/DynAny_Test/test_dynstruct.cpp b/TAO/tests/DynAny_Test/test_dynstruct.cpp index 1e8658bdb77..2795352f146 100644 --- a/TAO/tests/DynAny_Test/test_dynstruct.cpp +++ b/TAO/tests/DynAny_Test/test_dynstruct.cpp @@ -200,6 +200,63 @@ Test_DynStruct::run_test (void) } ACE_DEBUG ((LM_DEBUG, + "testing: constructor(TypeCode alias)/from_any/to_any\n")); + + + const DynAnyTests::test_struct* ts_out2 = 0; + CORBA_Any_var out_any2 ; + DynamicAny::DynStruct_var ftc2; + + ACE_TRY + { + DynamicAny::DynAny_var ftc2_base = dynany_factory->create_dyn_any_from_type_code (DynAnyTests::_tc_test_struct_alias + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ftc2 = DynamicAny::DynStruct::_narrow (ftc2_base.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (ftc2.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "DynStruct::_narrow() returned nil\n"), + -1); + } + + ts.c = data.m_char1; + ts.l = data.m_long1; + ts.es.f = data.m_float1; + ts.es.s = data.m_short1; + CORBA_Any in_any3; + in_any3 <<= ts; + ftc2->from_any (in_any3 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + out_any2 = ftc2->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + if ((out_any2.in () >>= ts_out2) != 1) // problem + { + ts_out2 = 0; + } + } + ACE_CATCH (CORBA::TypeCode::BadKind, ex) + { + } + ACE_ENDTRY; + + if (ts_out2 != 0 && ts_out2->es.s == data.m_short1) + { + ACE_DEBUG ((LM_DEBUG, + "++ OK ++\n")); + } + else + { + ++this->error_count_; + } + + + ACE_DEBUG ((LM_DEBUG, "testing: current_member_name/current_member_kind\n")); ftc1->seek (2 @@ -229,6 +286,34 @@ Test_DynStruct::run_test (void) } ACE_DEBUG ((LM_DEBUG, + "testing: current_member_name/current_member_kind with alias\n")); + ftc2->seek (2 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + DynamicAny::FieldName_var fn2 = + ftc2->current_member_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (ACE_OS::strcmp (fn2.in (), "es")) + { + ++this->error_count_; + } + + CORBA::TCKind tk2 = ftc2->current_member_kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (tk2 != CORBA::tk_struct) + { + ++this->error_count_; + } + + if (this->error_count_ == 0) + { + ACE_DEBUG ((LM_DEBUG, + "++ OK ++\n")); + } + + ACE_DEBUG ((LM_DEBUG, "testing: get_members/set_members\n")); DynamicAny::NameValuePairSeq_var nvps = fa1->get_members (ACE_ENV_SINGLE_ARG_PARAMETER); diff --git a/TAO/tests/DynAny_Test/test_dynunion.cpp b/TAO/tests/DynAny_Test/test_dynunion.cpp index 64427858f68..1afe066d346 100644 --- a/TAO/tests/DynAny_Test/test_dynunion.cpp +++ b/TAO/tests/DynAny_Test/test_dynunion.cpp @@ -146,6 +146,58 @@ Test_DynUnion::run_test (void) } ACE_DEBUG ((LM_DEBUG, + "testing: constructor(TypeCode alias)/from_any/to_any\n")); + + CORBA_Any_var out_any2 = fa1->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::TypeCode_var s_out3; + + ACE_TRY + { + DynamicAny::DynAny_var ftc2_base = dynany_factory->create_dyn_any_from_type_code + (DynAnyTests::_tc_test_union_alias ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + DynamicAny::DynUnion_var ftc2 = + DynamicAny::DynUnion::_narrow (ftc2_base.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (ftc2.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "DynUnion::_narrow() returned nil\n"), + -1); + } + + ftc2->from_any (out_any2.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + ftc2->seek (1 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + s_out3 = ftc2->get_typecode (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + } + ACE_CATCH (CORBA::TypeCode::BadKind, ex) + { + // Failed to create + } + ACE_ENDTRY; + + if ( ! CORBA::is_nil (s_out3.in ()) && + s_out3.in ()->equal (data.m_typecode1)) + { + ACE_DEBUG ((LM_DEBUG, + "++ OK ++\n")); + } + else + { + ++this->error_count_; + } + + ACE_DEBUG ((LM_DEBUG, "testing:discriminator/discriminator_kind\n")); DynamicAny::DynAny_var dp2 = ftc1->get_discriminator (ACE_ENV_SINGLE_ARG_PARAMETER); @@ -225,6 +277,22 @@ Test_DynUnion::run_test (void) ACE_TRY_CHECK; ftc1->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "testing: create_dyn_any with _default()\n")); + DynAnyTests::test_implicit_def test_implicit_def_union; + CORBA::Any any_union; + + test_implicit_def_union._default(); + ACE_TRY_CHECK; + any_union <<= test_implicit_def_union; + ACE_TRY_CHECK; + + DynamicAny::DynAny_var da_union = + dynany_factory->create_dyn_any(any_union); + ACE_TRY_CHECK; + + // if we get here the create_dyn_any worked. } ACE_CATCHANY { |