diff options
Diffstat (limited to 'project2/ice/unittests/testClient.cpp')
-rw-r--r-- | project2/ice/unittests/testClient.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/project2/ice/unittests/testClient.cpp b/project2/ice/unittests/testClient.cpp index e151055..5abedd7 100644 --- a/project2/ice/unittests/testClient.cpp +++ b/project2/ice/unittests/testClient.cpp @@ -32,25 +32,25 @@ class Dummy : public UnitTest::SimpleInterface { UnitTest::SimplePtr SingleRow(const Ice::Current&) { - return new UnitTest::Simple { 3, "single" }; + return std::make_shared<UnitTest::Simple>( 3, "single" ); } UnitTest::Simples SomeRows(const Ice::Current&) { UnitTest::Simples rtn { - new UnitTest::Simple { 1, "test a" }, - new UnitTest::Simple { 2, "test b" } + std::make_shared<UnitTest::Simple>( 1, "test a" ), + std::make_shared<UnitTest::Simple>( 2, "test b" ) }; execCount += 1; return rtn; } - UnitTest::Simples SomeRowsParams(Ice::Int pi, const std::string & ps, const Ice::Current&) + UnitTest::Simples SomeRowsParams(Ice::Int pi, const std::string ps, const Ice::Current&) { UnitTest::Simples rtn { - new UnitTest::Simple { 0, "before" }, - new UnitTest::Simple { pi, ps }, - new UnitTest::Simple { 2, "after" } + std::make_shared<UnitTest::Simple>( 0, "before" ), + std::make_shared<UnitTest::Simple>( pi, ps ), + std::make_shared<UnitTest::Simple>( 2, "after" ) }; execCount += 1; return rtn; @@ -61,7 +61,7 @@ class Dummy : public UnitTest::SimpleInterface { execCount += 1; } - void SomeTaskParams(Ice::Int a, const std::string & b, const Ice::Current&) + void SomeTaskParams(Ice::Int a, const std::string b, const Ice::Current&) { BOOST_REQUIRE_EQUAL(a, 1); BOOST_REQUIRE_EQUAL(b, "first"); @@ -80,10 +80,10 @@ class DummyComplex : public UnitTestComplex::ComplexInterface { UnitTestComplex::ComplexPtr ComplexRow(const Ice::Current&) { - return new UnitTestComplex::Complex { 3, "single", new UnitTestComplex::Date { 1980, 7, 9, 1, 2, 3 } }; + return std::make_shared<UnitTestComplex::Complex>( 3, "single", std::make_shared<UnitTestComplex::Date>(1980, 7, 9, 1, 2, 3) ); } - void ComplexParam(Ice::Int a, const std::string & b, const UnitTestComplex::DatePtr & d, const Ice::Current&) + void ComplexParam(Ice::Int a, const std::string b, const UnitTestComplex::DatePtr d, const Ice::Current&) { BOOST_REQUIRE_EQUAL(a, 1); BOOST_REQUIRE_EQUAL(b, "first"); @@ -114,21 +114,20 @@ commonTests(ExecContext * ec) BOOST_REQUIRE(RowSetFactory::get("UnitTestComplex-ComplexInterface-ComplexRow")); BOOST_TEST_CHECKPOINT("Load test script"); - ScriptReaderPtr r = new XmlScriptParser(iceroot / "testClient.xml"); + ScriptReaderPtr r = std::make_shared<XmlScriptParser>(iceroot / "testClient.xml"); BOOST_TEST_CHECKPOINT("Initialize ICE service"); - int paramCount = 0; - Ice::CommunicatorPtr ic = Ice::initialize(paramCount, NULL); + Ice::CommunicatorPtr ic = Ice::initialize(); auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12000"); - IceUtil::Handle<Dummy> dummy = new Dummy(); - IceUtil::Handle<DummyComplex> dummyComplex = new DummyComplex(); - adapter->add(dummy, ic->stringToIdentity("testObject")); - adapter->add(dummyComplex, ic->stringToIdentity("testObjectComplex")); + auto dummy = std::make_shared<Dummy>(); + auto dummyComplex = std::make_shared<DummyComplex>(); + adapter->add(dummy, Ice::stringToIdentity("testObject")); + adapter->add(dummyComplex, Ice::stringToIdentity("testObjectComplex")); adapter->activate(); AdHoc::ScopeExit _([&ic]{ ic->destroy(); }); BOOST_TEST_CHECKPOINT("Execute test script"); - boost::intrusive_ptr<TestScriptHost> sr = new TestScriptHost(r); + auto sr = std::make_shared<TestScriptHost>(r); BOOST_REQUIRE_EQUAL(dummy->execCount, 0); BOOST_REQUIRE_EQUAL(dummyComplex->execCount, 0); sr->process(ec); |