finally get rid of std::auto_ptr

This commit is contained in:
Günter Obiltschnig
2019-12-15 09:40:40 +01:00
parent 56fe4eaf97
commit 9c197e0ed1
19 changed files with 85 additions and 229 deletions

View File

@@ -79,16 +79,12 @@ void FTPStreamFactoryTest::testDownload()
uri.setPort(server.port());
uri.setPath("/test.txt;type=a");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
pStr.reset();
std::string s(dataStr.str());
assertTrue (s == "line1\r\nline2\r\n");
}
@@ -120,17 +116,13 @@ void FTPStreamFactoryTest::testList()
uri.setPort(server.port());
uri.setPath("/usr/guest/data;type=d");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
pStr.reset();
std::string s(dataStr.str());
assertTrue (s == "file1\r\nfile2\r\n");
}
@@ -162,17 +154,13 @@ void FTPStreamFactoryTest::testUserInfo()
uri.setPath("/test.txt;type=a");
uri.setUserInfo("user:secret");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
pStr.reset();
std::string s(dataStr.str());
assertTrue (s == "line1\r\nline2\r\n");
}
@@ -205,17 +193,13 @@ void FTPStreamFactoryTest::testPasswordProvider()
uri.setPath("/test.txt;type=a");
uri.setUserInfo("user");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
pStr.reset();
std::string s(dataStr.str());
assertTrue (s == "line1\r\nline2\r\n");
}
@@ -239,11 +223,7 @@ void FTPStreamFactoryTest::testMissingPasswordProvider()
try
{
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
fail("no password provider - must throw");
}
catch (FTPException&)

View File

@@ -44,11 +44,7 @@ void HTTPStreamFactoryTest::testNoRedirect()
HTTPStreamFactory factory;
URI uri("http://127.0.0.1/large");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPTestServer::LARGE_BODY);
@@ -61,11 +57,7 @@ void HTTPStreamFactoryTest::testEmptyPath()
HTTPStreamFactory factory;
URI uri("http://127.0.0.1");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPTestServer::SMALL_BODY);
@@ -79,11 +71,7 @@ void HTTPStreamFactoryTest::testRedirect()
opener.registerStreamFactory("http", new HTTPStreamFactory);
URI uri("http://127.0.0.1/redirect");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(opener.open(uri));
#else
std::unique_ptr<std::istream> pStr(opener.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPTestServer::LARGE_BODY);
@@ -95,11 +83,7 @@ void HTTPStreamFactoryTest::testProxy()
HTTPTestServer server;
HTTPStreamFactory factory("127.0.0.1", server.port());
URI uri("http://www.somehost.com/large");
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPTestServer::LARGE_BODY);