diff options
Diffstat (limited to 'TAO/tests/Var_Deref')
-rw-r--r-- | TAO/tests/Var_Deref/README.txt | 8 | ||||
-rw-r--r-- | TAO/tests/Var_Deref/Test.idl | 19 | ||||
-rw-r--r-- | TAO/tests/Var_Deref/Var_Deref.mpc | 23 | ||||
-rw-r--r-- | TAO/tests/Var_Deref/var_deref.cpp | 83 |
4 files changed, 133 insertions, 0 deletions
diff --git a/TAO/tests/Var_Deref/README.txt b/TAO/tests/Var_Deref/README.txt new file mode 100644 index 00000000000..2f6afd2fc07 --- /dev/null +++ b/TAO/tests/Var_Deref/README.txt @@ -0,0 +1,8 @@ +$Id$ + +This test is intended to demonstrate that Var types can be +dereferenced to the pointer type using a casting operation. + +This behavior is dangerous in that the reference count is not +increased by extracting the pointer, thus using for anything more than +simple status testing should not be done. diff --git a/TAO/tests/Var_Deref/Test.idl b/TAO/tests/Var_Deref/Test.idl new file mode 100644 index 00000000000..b395b3a0711 --- /dev/null +++ b/TAO/tests/Var_Deref/Test.idl @@ -0,0 +1,19 @@ +// $Id$ + +module Test +{ + + struct FixedStruct + { + long l; + }; + + struct VarStruct + { + string st; + }; + + typedef sequence <FixedStruct> FixedSeq; + typedef sequence <VarStruct> VarSeq; + +}; diff --git a/TAO/tests/Var_Deref/Var_Deref.mpc b/TAO/tests/Var_Deref/Var_Deref.mpc new file mode 100644 index 00000000000..05811812315 --- /dev/null +++ b/TAO/tests/Var_Deref/Var_Deref.mpc @@ -0,0 +1,23 @@ +// -*- MPC -*- +// $Id$ + +project(*idl): taoidldefaults { + idlflags += -Sp + IDL_Files { + Test.idl + } + custom_only = 1 +} + +project(*exe): taoclient { + exename = var_deref + after += *idl + Source_Files { + var_deref.cpp + } + Source_Files { + TestC.cpp + } + IDL_Files { + } +} diff --git a/TAO/tests/Var_Deref/var_deref.cpp b/TAO/tests/Var_Deref/var_deref.cpp new file mode 100644 index 00000000000..d48bba980c3 --- /dev/null +++ b/TAO/tests/Var_Deref/var_deref.cpp @@ -0,0 +1,83 @@ +// $Id$ + +#include "TestC.h" + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + int errors = 0; + Test::FixedStruct *ft = 0; + Test::FixedStruct_var ftvar ( new Test::FixedStruct ); + Test::FixedStruct_var nftvar (0); + + Test::FixedSeq *fs = 0; + Test::FixedSeq_var fsvar ( new Test::FixedSeq (0) ); + Test::FixedSeq_var nfsvar (0); + + Test::VarStruct *vt = 0; + Test::VarStruct_var vtvar ( new Test::VarStruct ); + Test::VarStruct_var nvtvar (0); + + Test::VarSeq *vs = 0; + Test::VarSeq_var vsvar (new Test::VarSeq (0) ); + Test::VarSeq_var nvsvar (0); + + ft = ftvar; + if (ft == 0) + { + ACE_DEBUG ((LM_DEBUG, "Expected a non-null FixedStruct ref, got null\n")); + ++errors; + } + ft = nftvar; + if (ft != 0) + { + ACE_DEBUG ((LM_DEBUG, "Expected a null FixedStruct ref, got non-null\n")); + ++errors; + } + + fs = fsvar; + if (fs == 0) + { + ACE_DEBUG ((LM_DEBUG, "Expected a non-null FixedSeq ref, got null\n")); + ++errors; + } + fs = nfsvar; + if (fs != 0) + { + ACE_DEBUG ((LM_DEBUG, "Expected a null FixedSeq ref, got non-null\n")); + ++errors; + } + + vt = vtvar; + if (vt == 0) + { + ACE_DEBUG ((LM_DEBUG, "Expected a non-null VarStruct rev, got null\n")); + ++errors; + } + vt = nvtvar; + if (vt != 0) + { + ACE_DEBUG ((LM_DEBUG, "Expected a null VarStruct rev, got non-null\n")); + ++errors; + } + + vs = vsvar; + if (vs == 0) + { + ACE_DEBUG ((LM_DEBUG, "Expected a non-null VarSeq rev, got null\n")); + ++errors; + } + vs = nvsvar; + if (vs != 0) + { + ACE_DEBUG ((LM_DEBUG, "Expected a null VarSeq rev, got non-null\n")); + ++errors; + } + + if (errors == 0) + ACE_DEBUG ((LM_DEBUG, "Success: all dereferences worked as expected\n")); + else + ACE_DEBUG ((LM_DEBUG, "Failure: %d dereferences didn't work\n", errors)); + + return errors; +} |