]>
git.saurik.com Git - wxWidgets.git/blob - tests/streams/sstream.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/streams/sstream.cpp
3 // Purpose: Test wxStringInputStream/wxStringOutputStream
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2004 Vadim Zeitlin
7 // Licence: wxWidgets licence
8 ///////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx/wx.h".
11 #include "wx/wxprec.h"
17 // for all others, include the necessary headers
21 #include "wx/cppunit.h"
22 #include "wx/sstream.h"
27 using namespace CppUnit
;
29 ///////////////////////////////////////////////////////////////////////////////
32 // Try to fully test wxStringInputStream and wxStringOutputStream
35 public BaseStreamTestCase
<wxStringInputStream
, wxStringOutputStream
>
41 CPPUNIT_TEST_SUITE(strStream
);
42 // Base class stream tests the strStream supports.
43 CPPUNIT_TEST(Input_GetSize
);
44 CPPUNIT_TEST(Input_GetC
);
45 CPPUNIT_TEST(Input_Read
);
46 CPPUNIT_TEST(Input_Eof
);
47 CPPUNIT_TEST(Input_LastRead
);
48 CPPUNIT_TEST(Input_SeekI
);
49 CPPUNIT_TEST(Input_TellI
);
50 CPPUNIT_TEST(Input_Peek
);
51 CPPUNIT_TEST(Input_Ungetch
);
53 CPPUNIT_TEST(Output_PutC
);
54 CPPUNIT_TEST(Output_Write
);
55 CPPUNIT_TEST(Output_LastWrite
);
56 // seeking currently not supported by output string stream
57 //CPPUNIT_TEST(Output_SeekO);
58 //CPPUNIT_TEST(Output_TellO);
60 // Other test specific for String stream test case.
61 CPPUNIT_TEST_SUITE_END();
67 // Implement base class functions.
68 virtual wxStringInputStream
*DoCreateInStream();
69 virtual wxStringOutputStream
*DoCreateOutStream();
74 strStream::strStream()
76 static const size_t LEN
= 256;
78 for ( size_t n
= 0; n
< LEN
; n
++ )
80 m_str
+= _T('A') + n
% (_T('Z') - _T('A') + 1);
84 strStream::~strStream()
88 wxStringInputStream
*strStream::DoCreateInStream()
90 wxStringInputStream
*pStrInStream
= new wxStringInputStream(m_str
);
91 CPPUNIT_ASSERT(pStrInStream
->IsOk());
95 wxStringOutputStream
*strStream::DoCreateOutStream()
97 wxStringOutputStream
*pStrOutStream
= new wxStringOutputStream();
98 CPPUNIT_ASSERT(pStrOutStream
->IsOk());
103 // Register the stream sub suite, by using some stream helper macro.
104 STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(strStream
)