X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8d8087fc9b1ab1403b17104c509f834083a48fc7..b42d5f75565e01358a4636cf536da6ceb935ee9e:/tests/net/socket.cpp diff --git a/tests/net/socket.cpp b/tests/net/socket.cpp index e571a566bf..5928915e41 100644 --- a/tests/net/socket.cpp +++ b/tests/net/socket.cpp @@ -26,6 +26,8 @@ #if wxUSE_SOCKETS #include "wx/socket.h" +#include "wx/url.h" +#include "wx/sstream.h" #include "wx/evtloop.h" #include @@ -48,7 +50,8 @@ private: CPPUNIT_TEST( ReadNormal ); \ CPPUNIT_TEST( ReadBlock ); \ CPPUNIT_TEST( ReadNowait ); \ - CPPUNIT_TEST( ReadWaitall ) + CPPUNIT_TEST( ReadWaitall ); \ + CPPUNIT_TEST( UrlTest ) CPPUNIT_TEST_SUITE( SocketTestCase ); ALL_SOCKET_TESTS(); @@ -95,6 +98,8 @@ private: void ReadNowait(); void ReadWaitall(); + void UrlTest(); + static bool ms_useLoop; DECLARE_NO_COPY_CLASS(SocketTestCase) @@ -174,7 +179,7 @@ void SocketTestCase::ReadNormal() sock->Read(bufSmall, WXSIZEOF(bufSmall)); CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() ); - CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), sock->LastCount() ); + CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), (size_t)sock->LastCount() ); char bufBig[102400]; @@ -194,7 +199,7 @@ void SocketTestCase::ReadBlock() sock->Read(bufSmall, WXSIZEOF(bufSmall)); CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() ); - CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), sock->LastCount() ); + CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), (size_t)sock->LastCount() ); char bufBig[102400]; @@ -230,7 +235,23 @@ void SocketTestCase::ReadWaitall() sock->Read(buf, WXSIZEOF(buf)); CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() ); - CPPUNIT_ASSERT_EQUAL( WXSIZEOF(buf), sock->LastCount() ); + CPPUNIT_ASSERT_EQUAL( WXSIZEOF(buf), (size_t)sock->LastCount() ); +} + +void SocketTestCase::UrlTest() +{ + if ( gs_serverHost.empty() ) + return; + + SocketTestEventLoop loop(ms_useLoop); + + wxURL url("http://" + gs_serverHost); + + const std::auto_ptr in(url.GetInputStream()); + CPPUNIT_ASSERT( in.get() ); + + wxStringOutputStream out; + CPPUNIT_ASSERT_EQUAL( wxSTREAM_EOF, in->Read(out).GetLastError() ); } #endif // wxUSE_SOCKETS