1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// -*- c++ -*-
// $Id$
// ============================================================================
//
// = LIBRARY
// TAO/tests/DynAny_Test
//
// = FILENAME
// test_dynenum.cpp
//
// = DESCRIPTION
// Implementation of the simple DynEnum test
//
// = AUTHOR
// Jeff Parsons <jp4@cs.wustl.edu>
//
// ============================================================================
#include "tao/corba.h"
#include "tao/DynEnum_i.h"
#include "test_dynenum.h"
#include "da_testsC.h"
#include "data.h"
Test_DynEnum::Test_DynEnum (CORBA::ORB_var orb)
: test_name_ (CORBA::string_dup ("test_dynenum")),
orb_ (orb),
error_count_ (0)
{
}
Test_DynEnum::~Test_DynEnum (void)
{
CORBA::string_free (this->test_name_);
this->test_name_ = 0;
}
const char*
Test_DynEnum::test_name (void) const
{
return this->test_name_;
}
int
Test_DynEnum::run_test (void)
{
DynAnyTests::test_enum te;
TAO_TRY
{
ACE_DEBUG ((LM_DEBUG,
"testing: constructor(Any)/value_as_ulong\n"));
CORBA_Any in_any1;
in_any1 <<= DynAnyTests::SECOND;
TAO_DynEnum_i de1 (in_any1);
CORBA::ULong ul_out1 = de1.value_as_ulong (TAO_TRY_ENV);
TAO_CHECK_ENV;
if (ul_out1 == 2)
ACE_DEBUG ((LM_DEBUG,
"++ OK ++\n"));
else
++this->error_count_;
ACE_DEBUG ((LM_DEBUG,
"testing: value_as_string\n"));
CORBA::String s = de1.value_as_string (TAO_TRY_ENV);
TAO_CHECK_ENV;
if (!ACE_OS::strcmp (s, "SECOND"))
ACE_DEBUG ((LM_DEBUG,
"++ OK ++\n"));
else
++this->error_count_;
ACE_DEBUG ((LM_DEBUG,
"testing: constructor(TypeCode)/from_any/to_any\n"));
TAO_DynEnum_i de2 (DynAnyTests::_tc_test_enum);
de2.from_any (in_any1,
TAO_TRY_ENV);
TAO_CHECK_ENV;
CORBA_Any* out_any1 = de2.to_any (TAO_TRY_ENV);
TAO_CHECK_ENV;
ul_out1 = 0;
*out_any1 >>= te;
if (te == DynAnyTests::SECOND)
ACE_DEBUG ((LM_DEBUG,
"++ OK ++\n"));
else
++this->error_count_;
// Created with NEW
delete out_any1;
}
TAO_CATCHANY
{
TAO_TRY_ENV.print_exception ("test_dynenum::run_test");
return -1;
}
TAO_ENDTRY;
ACE_DEBUG ((LM_DEBUG,
"\n%d errors\n",
this->error_count_));
return 0;
}
|