blob: 91bb5df81a0ad7c78fc11c889a69b727873d9d3d (
plain)
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
|
// **********************************************************************
//
// Copyright (c) 2001
// MutableRealms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************
#include <Ice/Ice.h>
#include <TestCommon.h>
#include <Test.h>
using namespace std;
ThrowerPrx
allTests(const Ice::CommunicatorPtr& communicator)
{
cout << "testing stringToProxy... " << flush;
string ref("thrower:tcp -p 12345 -t 2000");
Ice::ObjectPrx base = communicator->stringToProxy(ref);
test(base);
cout << "ok" << endl;
cout << "testing checked cast... " << flush;
ThrowerPrx thrower = ThrowerPrx::checkedCast(base);
test(thrower);
test(thrower == base);
cout << "ok" << endl;
cout << "catching exact types... " << flush;
try
{
thrower->throwAasA(1);
test(false);
}
catch(const A& ex)
{
test(ex.a == 1);
}
catch(...)
{
assert(false);
}
try
{
thrower->throwBasB(1, 2);
test(false);
}
catch(const B& ex)
{
test(ex.a == 1);
test(ex.b == 2);
}
catch(...)
{
assert(false);
}
try
{
thrower->throwCasC(1, 2, 3);
test(false);
}
catch(const C& ex)
{
test(ex.a == 1);
test(ex.b == 2);
test(ex.c == 3);
}
catch(...)
{
assert(false);
}
cout << "ok" << endl;
cout << "catching base types... " << flush;
try
{
thrower->throwBasB(1, 2);
test(false);
}
catch(const A& ex)
{
test(ex.a == 1);
}
catch(...)
{
assert(false);
}
try
{
thrower->throwCasC(1, 2, 3);
test(false);
}
catch(const B& ex)
{
test(ex.a == 1);
test(ex.b == 2);
}
catch(...)
{
assert(false);
}
cout << "ok" << endl;
return thrower;
}
|