Replace remaining std::auto_ptr<> with wxScopedPtr in the tests

This should have been done in b8c9cd3528
to avoid all warnings about std::auto_ptr<> being deprecated when using
g++ 6 or later which compiles in C++14 mode by default.
This commit is contained in:
Vadim Zeitlin
2017-10-31 21:14:05 +01:00
parent 91697a8724
commit 11a5728b32
4 changed files with 19 additions and 20 deletions

View File

@@ -20,7 +20,6 @@
#include "archivetest.h" #include "archivetest.h"
#include "wx/dir.h" #include "wx/dir.h"
#include "wx/scopedptr.h"
#include <string> #include <string>
#include <list> #include <list>
#include <map> #include <map>

View File

@@ -12,6 +12,7 @@
#define WX_TEST_ARCHIVE_ITERATOR #define WX_TEST_ARCHIVE_ITERATOR
#include "wx/archive.h" #include "wx/archive.h"
#include "wx/scopedptr.h"
#include "wx/wfstream.h" #include "wx/wfstream.h"
#include <map> #include <map>
@@ -215,7 +216,7 @@ protected:
typedef std::map<wxString, TestEntry*> TestEntries; typedef std::map<wxString, TestEntry*> TestEntries;
TestEntries m_testEntries; // test data TestEntries m_testEntries; // test data
std::auto_ptr<ClassFactoryT> m_factory; // factory to make classes wxScopedPtr<ClassFactoryT> m_factory; // factory to make classes
int m_options; // test options int m_options; // test options
wxDateTime m_timeStamp; // timestamp to give test entries wxDateTime m_timeStamp; // timestamp to give test entries
int m_id; // select between the possibilites int m_id; // select between the possibilites

View File

@@ -22,7 +22,6 @@
#include "wx/zipstrm.h" #include "wx/zipstrm.h"
using std::string; using std::string;
using std::auto_ptr;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@@ -188,7 +187,7 @@ void ZipPipeTestCase::runTest()
TestInputStream in(out, m_id % ((m_options & PipeIn) ? 4 : 3)); TestInputStream in(out, m_id % ((m_options & PipeIn) ? 4 : 3));
wxZipInputStream zip(in); wxZipInputStream zip(in);
auto_ptr<wxZipEntry> entry(zip.GetNextEntry()); wxScopedPtr<wxZipEntry> entry(zip.GetNextEntry());
CPPUNIT_ASSERT(entry.get() != NULL); CPPUNIT_ASSERT(entry.get() != NULL);
if ((m_options & PipeIn) == 0) if ((m_options & PipeIn) == 0)

View File

@@ -26,12 +26,12 @@
#include "wx/socket.h" #include "wx/socket.h"
#include "wx/url.h" #include "wx/url.h"
#include "wx/scopedptr.h"
#include "wx/sstream.h" #include "wx/sstream.h"
#include "wx/evtloop.h" #include "wx/evtloop.h"
#include <memory>
typedef std::auto_ptr<wxSockAddress> wxSockAddressPtr; typedef wxScopedPtr<wxSockAddress> wxSockAddressPtr;
typedef std::auto_ptr<wxSocketClient> wxSocketClientPtr; typedef wxScopedPtr<wxSocketClient> wxSocketClientPtr;
static wxString gs_serverHost(wxGetenv("WX_TEST_SERVER")); static wxString gs_serverHost(wxGetenv("WX_TEST_SERVER"));
@@ -88,11 +88,11 @@ private:
// get the address to connect to, if NULL is returned it means that the // get the address to connect to, if NULL is returned it means that the
// test is disabled and shouldn't run at all // test is disabled and shouldn't run at all
wxSockAddressPtr GetServer() const; wxSockAddress* GetServer() const;
// get the socket to read HTTP reply from, returns NULL if the test is // get the socket to read HTTP reply from, returns NULL if the test is
// disabled // disabled
wxSocketClientPtr GetHTTPSocket(int flags = wxSOCKET_NONE) const; wxSocketClient* GetHTTPSocket(int flags = wxSOCKET_NONE) const;
void PseudoTest_SetUseEventLoop() { ms_useLoop = true; } void PseudoTest_SetUseEventLoop() { ms_useLoop = true; }
@@ -115,23 +115,23 @@ bool SocketTestCase::ms_useLoop = false;
CPPUNIT_TEST_SUITE_REGISTRATION( SocketTestCase ); CPPUNIT_TEST_SUITE_REGISTRATION( SocketTestCase );
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SocketTestCase, "SocketTestCase" ); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SocketTestCase, "SocketTestCase" );
wxSockAddressPtr SocketTestCase::GetServer() const wxSockAddress* SocketTestCase::GetServer() const
{ {
if ( gs_serverHost.empty() ) if ( gs_serverHost.empty() )
return wxSockAddressPtr(); return NULL;
wxIPV4address *addr = new wxIPV4address; wxIPV4address *addr = new wxIPV4address;
addr->Hostname(gs_serverHost); addr->Hostname(gs_serverHost);
addr->Service("www"); addr->Service("www");
return wxSockAddressPtr(addr); return addr;
} }
wxSocketClientPtr SocketTestCase::GetHTTPSocket(int flags) const wxSocketClient* SocketTestCase::GetHTTPSocket(int flags) const
{ {
wxSockAddressPtr addr = GetServer(); wxSockAddress *addr = GetServer();
if ( !addr.get() ) if ( !addr )
return wxSocketClientPtr(); return NULL;
wxSocketClient *sock = new wxSocketClient(flags); wxSocketClient *sock = new wxSocketClient(flags);
sock->SetTimeout(1); sock->SetTimeout(1);
@@ -144,12 +144,12 @@ wxSocketClientPtr SocketTestCase::GetHTTPSocket(int flags) const
sock->Write(httpGetRoot.ToAscii(), httpGetRoot.length()); sock->Write(httpGetRoot.ToAscii(), httpGetRoot.length());
return wxSocketClientPtr(sock); return sock;
} }
void SocketTestCase::BlockingConnect() void SocketTestCase::BlockingConnect()
{ {
wxSockAddressPtr addr = GetServer(); wxSockAddressPtr addr(GetServer());
if ( !addr.get() ) if ( !addr.get() )
return; return;
@@ -159,7 +159,7 @@ void SocketTestCase::BlockingConnect()
void SocketTestCase::NonblockingConnect() void SocketTestCase::NonblockingConnect()
{ {
wxSockAddressPtr addr = GetServer(); wxSockAddressPtr addr(GetServer());
if ( !addr.get() ) if ( !addr.get() )
return; return;
@@ -257,7 +257,7 @@ void SocketTestCase::UrlTest()
wxURL url("http://" + gs_serverHost); wxURL url("http://" + gs_serverHost);
const std::auto_ptr<wxInputStream> in(url.GetInputStream()); const wxScopedPtr<wxInputStream> in(url.GetInputStream());
CPPUNIT_ASSERT( in.get() ); CPPUNIT_ASSERT( in.get() );
wxStringOutputStream out; wxStringOutputStream out;