From: Vadim Zeitlin Date: Sat, 7 Dec 2002 00:31:56 +0000 (+0000) Subject: added trivial test for wxTextInputStream X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/399376561413cc8fdd10a24256f346377ce096ac added trivial test for wxTextInputStream git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18083 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/console/console.cpp b/samples/console/console.cpp index 24c3bf569a..f2c4785572 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -81,6 +81,7 @@ #define TEST_SOCKETS #define TEST_STREAMS #define TEST_STRINGS + #define TEST_TEXTSTREAM #define TEST_THREADS #define TEST_TIMER #define TEST_UNICODE @@ -93,7 +94,7 @@ #undef TEST_ALL static const bool TEST_ALL = TRUE; #else - #define TEST_DATETIME + #define TEST_TEXTSTREAM static const bool TEST_ALL = FALSE; #endif @@ -5156,6 +5157,45 @@ static void TestTimeCompatibility() #endif // TEST_DATETIME +// ---------------------------------------------------------------------------- +// wxTextInput/OutputStream +// ---------------------------------------------------------------------------- + +#ifdef TEST_TEXTSTREAM + +#include "wx/txtstrm.h" +#include "wx/wfstream.h" + +static void TestTextInputStream() +{ + wxPuts(_T("\n*** wxTextInputStream test ***")); + + wxFileInputStream fsIn(_T("testdata.fc")); + if ( !fsIn.Ok() ) + { + wxPuts(_T("ERROR: couldn't open file.")); + } + else + { + wxTextInputStream tis(fsIn); + + size_t line = 1; + for ( ;; ) + { + const wxString s = tis.ReadLine(); + + // line could be non empty if the last line of the file isn't + // terminated with EOL + if ( fsIn.Eof() && s.empty() ) + break; + + wxPrintf(_T("Line %d: %s\n"), line++, s.c_str()); + } + } +} + +#endif // TEST_TEXTSTREAM + // ---------------------------------------------------------------------------- // threads // ---------------------------------------------------------------------------- @@ -6525,6 +6565,10 @@ int main(int argc, char **argv) TestMemoryStream(); #endif // TEST_STREAMS +#ifdef TEST_TEXTSTREAM + TestTextInputStream(); +#endif // TEST_TEXTSTREAM + #ifdef TEST_THREADS int nCPUs = wxThread::GetCPUCount(); wxPrintf(_T("This system has %d CPUs\n"), nCPUs);