]> git.saurik.com Git - wxWidgets.git/commitdiff
Stream error testing.
authorRobert Roebling <robert@roebling.de>
Wed, 8 Dec 1999 08:28:29 +0000 (08:28 +0000)
committerRobert Roebling <robert@roebling.de>
Wed, 8 Dec 1999 08:28:29 +0000 (08:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4869 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/typetest/typetest.cpp
samples/typetest/typetest.h

index cf93e4922a658ef6165635d80546a8a064ff1145..9b3fef09812a209b0d14497bcf39e20d444e26b9 100644 (file)
@@ -60,8 +60,9 @@ BEGIN_EVENT_TABLE(MyApp, wxApp)
 #if wxUSE_UNICODE
     EVT_MENU(TYPES_UNICODE,   MyApp::DoUnicodeDemo)
 #endif
-    EVT_MENU(TYPES_STREAM2, MyApp::DoStreamDemo2)
     EVT_MENU(TYPES_STREAM, MyApp::DoStreamDemo)
+    EVT_MENU(TYPES_STREAM2, MyApp::DoStreamDemo2)
+    EVT_MENU(TYPES_STREAM3, MyApp::DoStreamDemo3)
     EVT_MENU(TYPES_MIME, MyApp::DoMIMEDemo)
 END_EVENT_TABLE()
 
@@ -91,6 +92,7 @@ bool MyApp::OnInit()
 #endif
     test_menu->Append(TYPES_STREAM, "&Stream test");
     test_menu->Append(TYPES_STREAM2, "&Stream seek test");
+    test_menu->Append(TYPES_STREAM3, "&Stream error test");
     test_menu->AppendSeparator();
     test_menu->Append(TYPES_MIME, "&MIME database test");
 
@@ -263,7 +265,7 @@ void MyApp::DoStreamDemo2(wxCommandEvent& WXUNUSED(event))
     wxTextCtrl& textCtrl = * GetTextCtrl();
 
     textCtrl.Clear();
-    textCtrl << _T("\nTest wxBufferedStream:\n\n");
+    textCtrl << _T("\nTesting wxBufferedStream:\n\n");
 
     char ch,ch2;
 
@@ -330,6 +332,119 @@ void MyApp::DoStreamDemo2(wxCommandEvent& WXUNUSED(event))
     
 }
 
+void MyApp::DoStreamDemo3(wxCommandEvent& WXUNUSED(event))
+{
+    wxTextCtrl& textCtrl = * GetTextCtrl();
+
+    textCtrl.Clear();
+    textCtrl << "\nTesting wxFileInputStream's and wxFFileInputStream's error handling:\n\n";
+
+    char ch,ch2;
+
+    textCtrl.WriteText( "Writing number 0 to 9 to wxFileOutputStream:\n\n" );
+
+    wxFileOutputStream file_output( "test_wx.dat" );
+    for (ch = 0; ch < 10; ch++)
+        file_output.Write( &ch, 1 );
+
+    // Testing wxFileInoutStream
+    
+    textCtrl.WriteText( "Reading 0 to 10 to wxFileInputStream:\n\n" );
+
+    wxFileInputStream file_input( "test_wx.dat" );
+    for (ch2 = 0; ch2 < 11; ch2++)
+    {
+        file_input.Read( &ch, 1 );
+       textCtrl.WriteText( "Value read: " );
+       textCtrl.WriteText( (char)(ch + '0') );
+       textCtrl.WriteText( ";  stream.LastError() returns: " );
+       switch (file_input.LastError())
+       {
+           case wxSTREAM_NOERROR:      textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break;
+           case wxSTREAM_EOF:          textCtrl.WriteText( "wxSTREAM_EOF\n" ); break;
+           case wxSTREAM_READ_ERROR:   textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break;
+           case wxSTREAM_WRITE_ERROR:  textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break;
+           default: textCtrl.WriteText( "Huh?\n" ); break;
+       }
+    }
+    textCtrl.WriteText( "\n" );
+    
+    textCtrl.WriteText( "Seeking to 0;  stream.LastError() returns: " );
+    file_input.SeekI( 0 );
+    switch (file_input.LastError())
+    {
+       case wxSTREAM_NOERROR:      textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break;
+       case wxSTREAM_EOF:          textCtrl.WriteText( "wxSTREAM_EOF\n" ); break;
+       case wxSTREAM_READ_ERROR:   textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break;
+       case wxSTREAM_WRITE_ERROR:  textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break;
+       default: textCtrl.WriteText( "Huh?\n" ); break;
+    }
+    textCtrl.WriteText( "\n" );
+    
+    file_input.Read( &ch, 1 );
+    textCtrl.WriteText( "Value read: " );
+    textCtrl.WriteText( (char)(ch + '0') );
+    textCtrl.WriteText( ";  stream.LastError() returns: " );
+    switch (file_input.LastError())
+    {
+       case wxSTREAM_NOERROR:      textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break;
+       case wxSTREAM_EOF:          textCtrl.WriteText( "wxSTREAM_EOF\n" ); break;
+       case wxSTREAM_READ_ERROR:   textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break;
+       case wxSTREAM_WRITE_ERROR:  textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break;
+       default: textCtrl.WriteText( "Huh?\n" ); break;
+    }
+    textCtrl.WriteText( "\n\n" );
+
+    
+    // Testing wxFFileInoutStream
+    
+    textCtrl.WriteText( "Reading 0 to 10 to wxFFileInputStream:\n\n" );
+
+    wxFFileInputStream ffile_input( "test_wx.dat" );
+    for (ch2 = 0; ch2 < 11; ch2++)
+    {
+        ffile_input.Read( &ch, 1 );
+       textCtrl.WriteText( "Value read: " );
+       textCtrl.WriteText( (char)(ch + '0') );
+       textCtrl.WriteText( ";  stream.LastError() returns: " );
+       switch (ffile_input.LastError())
+       {
+           case wxSTREAM_NOERROR:      textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break;
+           case wxSTREAM_EOF:          textCtrl.WriteText( "wxSTREAM_EOF\n" ); break;
+           case wxSTREAM_READ_ERROR:   textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break;
+           case wxSTREAM_WRITE_ERROR:  textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break;
+           default: textCtrl.WriteText( "Huh?\n" ); break;
+       }
+    }
+    textCtrl.WriteText( "\n" );
+    
+    textCtrl.WriteText( "Seeking to 0;  stream.LastError() returns: " );
+    ffile_input.SeekI( 0 );
+    switch (ffile_input.LastError())
+    {
+       case wxSTREAM_NOERROR:      textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break;
+       case wxSTREAM_EOF:          textCtrl.WriteText( "wxSTREAM_EOF\n" ); break;
+       case wxSTREAM_READ_ERROR:   textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break;
+       case wxSTREAM_WRITE_ERROR:  textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break;
+       default: textCtrl.WriteText( "Huh?\n" ); break;
+    }
+    textCtrl.WriteText( "\n" );
+    
+    ffile_input.Read( &ch, 1 );
+    textCtrl.WriteText( "Value read: " );
+    textCtrl.WriteText( (char)(ch + '0') );
+    textCtrl.WriteText( ";  stream.LastError() returns: " );
+    switch (ffile_input.LastError())
+    {
+       case wxSTREAM_NOERROR:      textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break;
+       case wxSTREAM_EOF:          textCtrl.WriteText( "wxSTREAM_EOF\n" ); break;
+       case wxSTREAM_READ_ERROR:   textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break;
+       case wxSTREAM_WRITE_ERROR:  textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break;
+       default: textCtrl.WriteText( "Huh?\n" ); break;
+    }
+
+}
+
 #if wxUSE_UNICODE
 void MyApp::DoUnicodeDemo(wxCommandEvent& WXUNUSED(event))
 {
index c7b9d15e0fb5bb57b8df84c789590895fc20dccd..51e35781976d6339d6141bc5a6b2f01f30ae13dd 100644 (file)
@@ -31,6 +31,7 @@ public:
     void DoByteOrderDemo(wxCommandEvent& event);
     void DoStreamDemo(wxCommandEvent& event);
     void DoStreamDemo2(wxCommandEvent& event);
+    void DoStreamDemo3(wxCommandEvent& event);
 #if wxUSE_UNICODE
     void DoUnicodeDemo(wxCommandEvent& event);
 #endif
@@ -76,6 +77,7 @@ enum
     TYPES_UNICODE,
     TYPES_STREAM,
     TYPES_STREAM2,
+    TYPES_STREAM3,
     TYPES_MIME
 };