diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/Ice/value/Client.cpp | 16 | ||||
-rw-r--r-- | cpp/test/Ice/exceptions/AllTests.cpp | 20 | ||||
-rw-r--r-- | cpp/test/Ice/facets/AllTests.cpp | 12 | ||||
-rw-r--r-- | cpp/test/Ice/slicing/exceptions/AllTests.cpp | 78 | ||||
-rw-r--r-- | cpp/test/IceUtil/thread/StartTest.cpp | 4 |
5 files changed, 44 insertions, 86 deletions
diff --git a/cpp/demo/Ice/value/Client.cpp b/cpp/demo/Ice/value/Client.cpp index e991c89d643..1ec3920d9d1 100644 --- a/cpp/demo/Ice/value/Client.cpp +++ b/cpp/demo/Ice/value/Client.cpp @@ -66,17 +66,16 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) PrinterPtr printer; PrinterPrx printerProxy; - bool gotException = false; try { initial->getPrinter(printer, printerProxy); + cerr << argv[0] << "Did not get the expected NoObjectFactoryException!" << endl; + exit(EXIT_FAILURE); } catch(const Ice::NoObjectFactoryException& ex) { cout << "==> " << ex << endl; - gotException = true; } - assert(gotException); cout << '\n' << "Yep, that's what we expected. Now let's try again, but with\n" @@ -154,18 +153,21 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) << "[press enter]\n"; cin.getline(c, 2); - gotException = false; try { initial->throwDerivedPrinter(); + cerr << argv[0] << "Did not get the expected DerivedPrinterException!" << endl; + exit(EXIT_FAILURE); } catch(const DerivedPrinterException& ex) { derived = ex.derived; - assert(derived); - gotException = true; + if(!derived) + { + cerr << argv[0] << "Unexpected null pointer for `derived'" << endl; + exit(EXIT_FAILURE); + } } - assert(gotException); cout << "==> " << derived->derivedMessage << endl; cout << "==> "; diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp index eebeffd68cc..22f0c720a0c 100644 --- a/cpp/test/Ice/exceptions/AllTests.cpp +++ b/cpp/test/Ice/exceptions/AllTests.cpp @@ -566,28 +566,24 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter1"); Ice::ObjectPtr obj = new EmptyI; adapter->add(obj, Ice::stringToIdentity("x")); - bool gotException = false; try { adapter->add(obj, Ice::stringToIdentity("x")); + test(false); } catch(const Ice::AlreadyRegisteredException&) { - gotException = true; } - test(gotException); - gotException = false; adapter->remove(Ice::stringToIdentity("x")); try { adapter->remove(Ice::stringToIdentity("x")); + test(false); } catch(const Ice::NotRegisteredException&) { - gotException = true; } - test(gotException); adapter->deactivate(); } @@ -598,16 +594,14 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter2"); Ice::ServantLocatorPtr loc = new ServantLocatorI; adapter->addServantLocator(loc, "x"); - bool gotException = false; try { adapter->addServantLocator(loc, "x"); + test(false); } catch(const Ice::AlreadyRegisteredException&) { - gotException = true; } - test(gotException); adapter->deactivate(); } @@ -617,28 +611,24 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { Ice::ObjectFactoryPtr of = new ObjectFactoryI; communicator->addObjectFactory(of, "x"); - bool gotException = false; try { communicator->addObjectFactory(of, "x"); + test(false); } catch(const Ice::AlreadyRegisteredException&) { - gotException = true; } - test(gotException); - gotException = false; communicator->removeObjectFactory("x"); try { communicator->removeObjectFactory("x"); + test(false); } catch(const Ice::NotRegisteredException&) { - gotException = true; } - test(gotException); } cout << "ok" << endl; diff --git a/cpp/test/Ice/facets/AllTests.cpp b/cpp/test/Ice/facets/AllTests.cpp index 620b826905e..982da0bf97f 100644 --- a/cpp/test/Ice/facets/AllTests.cpp +++ b/cpp/test/Ice/facets/AllTests.cpp @@ -26,27 +26,23 @@ allTests(const Ice::CommunicatorPtr& communicator) Ice::ObjectPtr obj = new EmptyI; adapter->add(obj, Ice::stringToIdentity("d")); adapter->addFacet(obj, Ice::stringToIdentity("d"), "facetABCD"); - bool gotException = false; try { adapter->addFacet(obj, Ice::stringToIdentity("d"), "facetABCD"); + test(false); } catch(Ice::AlreadyRegisteredException&) { - gotException = true; } - test(gotException); adapter->removeFacet(Ice::stringToIdentity("d"), "facetABCD"); - gotException = false; try { adapter->removeFacet(Ice::stringToIdentity("d"), "facetABCD"); + test(false); } catch(Ice::NotRegisteredException&) { - gotException = true; } - test(gotException); cout << "ok" << endl; cout << "testing removeAllFacets..." << flush; @@ -62,16 +58,14 @@ allTests(const Ice::CommunicatorPtr& communicator) test(fm.size() == 2); test(fm["f1"] == obj1); test(fm["f2"] == obj2); - gotException = false; try { adapter->removeAllFacets(Ice::stringToIdentity("id1")); + test(false); } catch(Ice::NotRegisteredException&) { - gotException = true; } - test(gotException); fm = adapter->removeAllFacets(Ice::stringToIdentity("id2")); test(fm.size() == 3); test(fm["f1"] == obj1); diff --git a/cpp/test/Ice/slicing/exceptions/AllTests.cpp b/cpp/test/Ice/slicing/exceptions/AllTests.cpp index e010fe75897..0dd7f9f63b7 100644 --- a/cpp/test/Ice/slicing/exceptions/AllTests.cpp +++ b/cpp/test/Ice/slicing/exceptions/AllTests.cpp @@ -474,22 +474,20 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "base... " << flush; { - bool gotException = false; try { test->baseAsBase(); + test(false); } catch(const Base& b) { test(b.b == "Base.b"); test(b.ice_name() =="Test::Base"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -503,22 +501,20 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "slicing of unknown derived... " << flush; { - bool gotException = false; try { test->unknownDerivedAsBase(); + test(false); } catch(const Base& b) { test(b.b == "UnknownDerived.b"); test(b.ice_name() =="Test::Base"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -532,23 +528,21 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "non-slicing of known derived as base... " << flush; { - bool gotException = false; try { test->knownDerivedAsBase(); + test(false); } catch(const KnownDerived& k) { test(k.b == "KnownDerived.b"); test(k.kd == "KnownDerived.kd"); test(k.ice_name() =="Test::KnownDerived"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -562,23 +556,21 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "non-slicing of known derived as derived... " << flush; { - bool gotException = false; try { test->knownDerivedAsKnownDerived(); + test(false); } catch(const KnownDerived& k) { test(k.b == "KnownDerived.b"); test(k.kd == "KnownDerived.kd"); test(k.ice_name() =="Test::KnownDerived"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -592,22 +584,20 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "slicing of unknown intermediate as base... " << flush; { - bool gotException = false; try { test->unknownIntermediateAsBase(); + test(false); } catch(const Base& b) { test(b.b == "UnknownIntermediate.b"); test(b.ice_name() =="Test::Base"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -621,23 +611,21 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "slicing of known intermediate as base... " << flush; { - bool gotException = false; try { test->knownIntermediateAsBase(); + test(false); } catch(const KnownIntermediate& ki) { test(ki.b == "KnownIntermediate.b"); test(ki.ki == "KnownIntermediate.ki"); test(ki.ice_name() =="Test::KnownIntermediate"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -651,10 +639,10 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "slicing of known most derived as base... " << flush; { - bool gotException = false; try { test->knownMostDerivedAsBase(); + test(false); } catch(const KnownMostDerived& kmd) { @@ -662,13 +650,11 @@ allTests(const Ice::CommunicatorPtr& communicator) test(kmd.ki == "KnownMostDerived.ki"); test(kmd.kmd == "KnownMostDerived.kmd"); test(kmd.ice_name() =="Test::KnownMostDerived"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -682,23 +668,21 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "non-slicing of known intermediate as intermediate... " << flush; { - bool gotException = false; try { test->knownIntermediateAsKnownIntermediate(); + test(false); } catch(const KnownIntermediate& ki) { test(ki.b == "KnownIntermediate.b"); test(ki.ki == "KnownIntermediate.ki"); test(ki.ice_name() =="Test::KnownIntermediate"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -712,10 +696,10 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "non-slicing of known most derived exception as intermediate... " << flush; { - bool gotException = false; try { test->knownMostDerivedAsKnownIntermediate(); + test(false); } catch(const KnownMostDerived& kmd) { @@ -723,13 +707,11 @@ allTests(const Ice::CommunicatorPtr& communicator) test(kmd.ki == "KnownMostDerived.ki"); test(kmd.kmd == "KnownMostDerived.kmd"); test(kmd.ice_name() =="Test::KnownMostDerived"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -743,10 +725,10 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "non-slicing of known most derived as most derived... " << flush; { - bool gotException = false; try { test->knownMostDerivedAsKnownMostDerived(); + test(false); } catch(const KnownMostDerived& kmd) { @@ -754,13 +736,11 @@ allTests(const Ice::CommunicatorPtr& communicator) test(kmd.ki == "KnownMostDerived.ki"); test(kmd.kmd == "KnownMostDerived.kmd"); test(kmd.ice_name() =="Test::KnownMostDerived"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -774,23 +754,21 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "slicing of unknown most derived, known intermediate as base... " << flush; { - bool gotException = false; try { test->unknownMostDerived1AsBase(); + test(false); } catch(const KnownIntermediate& ki) { test(ki.b == "UnknownMostDerived1.b"); test(ki.ki == "UnknownMostDerived1.ki"); test(ki.ice_name() =="Test::KnownIntermediate"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -804,23 +782,21 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "slicing of unknown most derived, known intermediate as intermediate... " << flush; { - bool gotException = false; try { test->unknownMostDerived1AsKnownIntermediate(); + test(false); } catch(const KnownIntermediate& ki) { test(ki.b == "UnknownMostDerived1.b"); test(ki.ki == "UnknownMostDerived1.ki"); test(ki.ice_name() =="Test::KnownIntermediate"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; @@ -834,22 +810,20 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "slicing of unknown most derived, unknown intermediate as base... " << flush; { - bool gotException = false; try { test->unknownMostDerived2AsBase(); + test(false); } catch(const Base& b) { test(b.b == "UnknownMostDerived2.b"); test(b.ice_name() =="Test::Base"); - gotException = true; } catch(...) { - test(0); + test(false); } - test(gotException); } cout << "ok" << endl; diff --git a/cpp/test/IceUtil/thread/StartTest.cpp b/cpp/test/IceUtil/thread/StartTest.cpp index 1a7f180db93..492b3c30531 100644 --- a/cpp/test/IceUtil/thread/StartTest.cpp +++ b/cpp/test/IceUtil/thread/StartTest.cpp @@ -48,16 +48,14 @@ StartTest::run() StartTestThreadPtr t = new StartTestThread(); ThreadControl control = t->start(); control.join(); - bool gotException = false; try { t->start(); + test(false); } catch(const ThreadStartedException&) { - gotException = true; } - test(gotException); // // Now let's create a bunch of short-lived threads |