summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/exceptions/AllTests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/Ice/exceptions/AllTests.cpp')
-rw-r--r--cpp/test/Ice/exceptions/AllTests.cpp189
1 files changed, 174 insertions, 15 deletions
diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp
index 91bb5df81a0..128e2ef1bae 100644
--- a/cpp/test/Ice/exceptions/AllTests.cpp
+++ b/cpp/test/Ice/exceptions/AllTests.cpp
@@ -30,78 +30,237 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "ok" << endl;
cout << "catching exact types... " << flush;
+
try
{
thrower->throwAasA(1);
test(false);
}
- catch(const A& ex)
+ catch (const A& ex)
+ {
+ test(ex.a == 1);
+ }
+ catch (...)
+ {
+ test(false);
+ }
+
+ try
+ {
+ thrower->throwAorDasAorD(1);
+ test(false);
+ }
+ catch (const A& ex)
{
test(ex.a == 1);
}
- catch(...)
+ catch (...)
+ {
+ test(false);
+ }
+
+ try
+ {
+ thrower->throwAorDasAorD(-1);
+ test(false);
+ }
+ catch (const D& ex)
{
- assert(false);
+ test(ex.d == -1);
}
+ catch (...)
+ {
+ test(false);
+ }
+
try
{
thrower->throwBasB(1, 2);
test(false);
}
- catch(const B& ex)
+ catch (const B& ex)
{
test(ex.a == 1);
test(ex.b == 2);
}
- catch(...)
+ catch (...)
{
- assert(false);
+ test(false);
}
+
try
{
thrower->throwCasC(1, 2, 3);
test(false);
}
- catch(const C& ex)
+ catch (const C& ex)
{
test(ex.a == 1);
test(ex.b == 2);
test(ex.c == 3);
}
- catch(...)
+ catch (...)
{
- assert(false);
+ test(false);
}
+
cout << "ok" << endl;
cout << "catching base types... " << flush;
+
try
{
thrower->throwBasB(1, 2);
test(false);
}
- catch(const A& ex)
+ catch (const A& ex)
{
test(ex.a == 1);
}
- catch(...)
+ catch (...)
{
- assert(false);
+ test(false);
}
+
try
{
thrower->throwCasC(1, 2, 3);
test(false);
}
- catch(const B& ex)
+ catch (const B& ex)
{
test(ex.a == 1);
test(ex.b == 2);
}
- catch(...)
+ catch (...)
+ {
+ test(false);
+ }
+
+ cout << "ok" << endl;
+
+ cout << "catching derived types w/o exception factories... " << flush;
+
+ try
+ {
+ thrower->throwBasA(1, 2);
+ test(false);
+ }
+ catch (const A& ex)
+ {
+ test(ex.a == 1);
+ }
+ catch (...)
+ {
+ test(false);
+ }
+
+ try
+ {
+ thrower->throwCasA(1, 2, 3);
+ test(false);
+ }
+ catch (const A& ex)
+ {
+ test(ex.a == 1);
+ }
+ catch (...)
{
- assert(false);
+ test(false);
+ }
+
+ try
+ {
+ thrower->throwCasB(1, 2, 3);
+ test(false);
}
+ catch (const B& ex)
+ {
+ test(ex.a == 1);
+ test(ex.b == 2);
+ }
+ catch (...)
+ {
+ test(false);
+ }
+
+ cout << "ok" << endl;
+
+ cout << "catching unknown user exception... " << flush;
+
+ try
+ {
+ thrower->throwUndeclaredA(1);
+ test(false);
+ }
+ catch (const Ice::UnknownUserException&)
+ {
+ }
+ catch (...)
+ {
+ test(false);
+ }
+
+ try
+ {
+ thrower->throwUndeclaredB(1, 2);
+ test(false);
+ }
+ catch (const Ice::UnknownUserException&)
+ {
+ }
+ catch (...)
+ {
+ test(false);
+ }
+
+ try
+ {
+ thrower->throwUndeclaredC(1, 2, 3);
+ test(false);
+ }
+ catch (const Ice::UnknownUserException&)
+ {
+ }
+ catch (...)
+ {
+ test(false);
+ }
+
+ cout << "ok" << endl;
+
+ cout << "catching unknown local exception... " << flush;
+
+ try
+ {
+ thrower->throwLocalException();
+ test(false);
+ }
+ catch (const Ice::UnknownLocalException&)
+ {
+ }
+ catch (...)
+ {
+ test(false);
+ }
+
+ cout << "ok" << endl;
+
+ cout << "catching unknown non-Ice exception... " << flush;
+
+ try
+ {
+ thrower->throwNonIceException();
+ test(false);
+ }
+ catch (const Ice::UnknownException&)
+ {
+ }
+ catch (...)
+ {
+ test(false);
+ }
+
cout << "ok" << endl;
return thrower;