diff options
Diffstat (limited to 'cpp/test/Ice/objects/AllTests.cpp')
-rw-r--r-- | cpp/test/Ice/objects/AllTests.cpp | 116 |
1 files changed, 90 insertions, 26 deletions
diff --git a/cpp/test/Ice/objects/AllTests.cpp b/cpp/test/Ice/objects/AllTests.cpp index ea7feee2778..c1115c698c2 100644 --- a/cpp/test/Ice/objects/AllTests.cpp +++ b/cpp/test/Ice/objects/AllTests.cpp @@ -26,9 +26,9 @@ void testUOE(const Ice::CommunicatorPtr& communicator) { string ref = "uoet:default -p 12010"; - Ice::ObjectPrx base = communicator->stringToProxy(ref); + Ice::ObjectPrxPtr base = communicator->stringToProxy(ref); test(base); - UnexpectedObjectExceptionTestPrx uoet = UnexpectedObjectExceptionTestPrx::uncheckedCast(base); + UnexpectedObjectExceptionTestPrxPtr uoet = ICE_UNCHECKED_CAST(UnexpectedObjectExceptionTestPrx, base); test(uoet); try { @@ -51,30 +51,34 @@ testUOE(const Ice::CommunicatorPtr& communicator) } } -InitialPrx +InitialPrxPtr allTests(const Ice::CommunicatorPtr& communicator) { cout << "testing stringToProxy... " << flush; string ref = "initial:default -p 12010"; - Ice::ObjectPrx base = communicator->stringToProxy(ref); + Ice::ObjectPrxPtr base = communicator->stringToProxy(ref); test(base); cout << "ok" << endl; cout << "testing checked cast... " << flush; - InitialPrx initial = InitialPrx::checkedCast(base); + InitialPrxPtr initial = ICE_CHECKED_CAST(InitialPrx, base); test(initial); +#ifdef ICE_CPP11_MAPPING + test(Ice::targetEquals(initial, base)); +#else test(initial == base); +#endif cout << "ok" << endl; cout << "testing constructor, copy constructor, and assignment operator... " << flush; - BasePtr ba1 = new Base; + BasePtr ba1 = ICE_MAKE_SHARED(Base); test(ba1->theS.str == ""); test(ba1->str == ""); S s; s.str = "hello"; - BasePtr ba2 = new Base(s, "hi"); + BasePtr ba2 = ICE_MAKE_SHARED(Base, s, "hi"); test(ba2->theS.str == "hello"); test(ba2->str == "hi"); @@ -82,7 +86,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(ba1->theS.str == "hello"); test(ba1->str == "hi"); - BasePtr bp1 = new Base(); + BasePtr bp1 = ICE_MAKE_SHARED(Base); *bp1 = *ba2; test(bp1->theS.str == "hello"); test(bp1->str == "hi"); @@ -91,11 +95,15 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing ice_clone..." << flush; - BasePtr bp2 = BasePtr::dynamicCast(bp1->ice_clone()); + BasePtr bp2 = ICE_DYNAMIC_CAST(Base, bp1->ice_clone()); test(bp1->theS.str == bp2->theS.str); test(bp1->str == bp2->str); - AbstractBasePtr abp1 = new AbstractBaseI; +#ifndef ICE_CPP11_MAPPING + // + // With C++11 mapping value classes are never abstracts. + // + AbstractBasePtr abp1 = new AbstractBaseI(); try { abp1->ice_clone(); @@ -104,6 +112,7 @@ allTests(const Ice::CommunicatorPtr& communicator) catch(const Ice::CloneNotImplementedException&) { } +#endif cout << "ok" << endl; cout << "getting B1... " << flush; @@ -128,29 +137,42 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "checking consistency... " << flush; test(b1 != b2); +#ifdef ICE_CPP11_MAPPING + test(b1 != dynamic_pointer_cast<B>(c)); + test(b1 != dynamic_pointer_cast<B>(d)); + test(b2 != dynamic_pointer_cast<B>(c)); + test(b2 != dynamic_pointer_cast<B>(d)); + test(c != dynamic_pointer_cast<C>(d)); +#else test(b1 != c); test(b1 != d); test(b2 != c); test(b2 != d); test(c != d); +#endif test(b1->theB == b1); - test(b1->theC == 0); - test(BPtr::dynamicCast(b1->theA)); - test(BPtr::dynamicCast(b1->theA)->theA == b1->theA); - test(BPtr::dynamicCast(b1->theA)->theB == b1); - test(CPtr::dynamicCast(BPtr::dynamicCast(b1->theA)->theC)); - test(CPtr::dynamicCast(BPtr::dynamicCast(b1->theA)->theC)->theB == b1->theA); + test(b1->theC == ICE_NULLPTR); + test(ICE_DYNAMIC_CAST(B, b1->theA)); + test(ICE_DYNAMIC_CAST(B, b1->theA)->theA == b1->theA); + test(ICE_DYNAMIC_CAST(B, b1->theA)->theB == b1); + test(ICE_DYNAMIC_CAST(C, ICE_DYNAMIC_CAST(B, b1->theA)->theC)); + test(ICE_DYNAMIC_CAST(C, ICE_DYNAMIC_CAST(B, b1->theA)->theC)->theB == b1->theA); +#ifdef ICE_CPP11_MAPPING + test(b1->preMarshalInvoked); + test(b1->theA->preMarshalInvoked); + test(dynamic_pointer_cast<B>(b1->theA)->theC->preMarshalInvoked); +#else test(b1->preMarshalInvoked); test(b1->postUnmarshalInvoked()); test(b1->theA->preMarshalInvoked); test(b1->theA->postUnmarshalInvoked()); test(BPtr::dynamicCast(b1->theA)->theC->preMarshalInvoked); test(BPtr::dynamicCast(b1->theA)->theC->postUnmarshalInvoked()); - +#endif // More tests possible for b2 and d, but I think this is already sufficient. test(b2->theA == b2); - test(d->theC == 0); + test(d->theC == ICE_NULLPTR); cout << "ok" << endl; cout << "getting B1, B2, C, and D all at once... " << flush; @@ -162,6 +184,29 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "ok" << endl; cout << "checking consistency... " << flush; +#ifdef ICE_CPP11_MAPPING + test(b1 != b2); + test(b1 != dynamic_pointer_cast<B>(c)); + test(b1 != dynamic_pointer_cast<B>(d)); + test(b2 != dynamic_pointer_cast<B>(c)); + test(b2 != dynamic_pointer_cast<B>(d)); + test(c != dynamic_pointer_cast<C>(d)); + test(b1->theA == dynamic_pointer_cast<B>(b2)); + test(b1->theB == dynamic_pointer_cast<B>(b1)); + test(b1->theC == nullptr); + test(b2->theA == b2); + test(b2->theB == b1); + test(b2->theC == dynamic_pointer_cast<C>(c)); + test(c->theB == b2); + test(d->theA == dynamic_pointer_cast<A>(b1)); + test(d->theB == dynamic_pointer_cast<B>(b2)); + test(d->theC == nullptr); + + test(d->preMarshalInvoked); + test(d->theA->preMarshalInvoked); + test(d->theB->preMarshalInvoked); + test(d->theB->theC->preMarshalInvoked); +#else test(b1 != b2); test(b1 != c); test(b1 != d); @@ -170,15 +215,15 @@ allTests(const Ice::CommunicatorPtr& communicator) test(c != d); test(b1->theA == b2); test(b1->theB == b1); - test(b1->theC == 0); + test(b1->theC == ICE_NULLPTR); test(b2->theA == b2); test(b2->theB == b1); test(b2->theC == c); test(c->theB == b2); test(d->theA == b1); test(d->theB == b2); - test(d->theC == 0); - + test(d->theC == ICE_NULLPTR); + test(d->preMarshalInvoked); test(d->postUnmarshalInvoked()); test(d->theA->preMarshalInvoked); @@ -187,28 +232,44 @@ allTests(const Ice::CommunicatorPtr& communicator) test(d->theB->postUnmarshalInvoked()); test(d->theB->theC->preMarshalInvoked); test(d->theB->theC->postUnmarshalInvoked()); - +#endif cout << "ok" << endl; cout << "testing protected members... " << flush; + EPtr e = initial->getE(); - test(e->checkValues()); FPtr f = initial->getF(); +#ifndef ICE_CPP11_MAPPING + test(e->checkValues()); test(f->checkValues()); test(f->e2->checkValues()); +#endif cout << "ok" << endl; cout << "getting I, J and H... " << flush; +#ifdef ICE_CPP11_MAPPING + shared_ptr<Ice::Value> i = initial->getI(); + test(i->ice_id() == "::Test::I"); + shared_ptr<Ice::Value> j = initial->getJ(); + test(j->ice_id() == "::Test::J"); + shared_ptr<Ice::Value> h = initial->getH(); + test(h && dynamic_pointer_cast<H>(h)); +#else IPtr i = initial->getI(); test(i); IPtr j = initial->getJ(); test(j && JPtr::dynamicCast(j)); IPtr h = initial->getH(); test(h && HPtr::dynamicCast(h)); +#endif cout << "ok" << endl; cout << "getting D1... " << flush; - D1Ptr d1 = new D1(new A1("a1"), new A1("a2"), new A1("a3"), new A1("a4")); + D1Ptr d1 = ICE_MAKE_SHARED(D1, + ICE_MAKE_SHARED(A1, "a1"), + ICE_MAKE_SHARED(A1, "a2"), + ICE_MAKE_SHARED(A1, "a3"), + ICE_MAKE_SHARED(A1, "a4")); d1 = initial->getD1(d1); test(d1->a1->name == "a1"); test(d1->a2->name == "a2"); @@ -242,7 +303,7 @@ allTests(const Ice::CommunicatorPtr& communicator) retS = initial->opBaseSeq(inS, outS); inS.resize(1); - inS[0] = new Base(); + inS[0] = ICE_MAKE_SHARED(Base); retS = initial->opBaseSeq(inS, outS); test(retS.size() == 1 && outS.size() == 1); cout << "ok" << endl; @@ -257,9 +318,12 @@ allTests(const Ice::CommunicatorPtr& communicator) } cout << "ok" << endl; +#ifdef ICE_CPP11_MAPPING + // TODO +#else cout << "testing UnexpectedObjectException... " << flush; testUOE(communicator); cout << "ok" << endl; - +#endif return initial; } |