summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/exceptions/AllTests.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2001-10-14 16:20:03 +0000
committerMarc Laukien <marc@zeroc.com>2001-10-14 16:20:03 +0000
commit909bb608a222169ac6dd3c4e88cfaf4f147e4cd7 (patch)
treeb7af1a3cb0240a05a223b2fb8924fd362e950ffa /cpp/test/Ice/exceptions/AllTests.cpp
parentmore exception cleanup (diff)
downloadice-909bb608a222169ac6dd3c4e88cfaf4f147e4cd7.tar.bz2
ice-909bb608a222169ac6dd3c4e88cfaf4f147e4cd7.tar.xz
ice-909bb608a222169ac6dd3c4e88cfaf4f147e4cd7.zip
more exception fixes
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;