]>
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".
18 // for all others, include the necessary headers
22 #include "wx/sstream.h"
26 ///////////////////////////////////////////////////////////////////////////////
29 // Try to fully test wxStringInputStream and wxStringOutputStream
32 public BaseStreamTestCase
<wxStringInputStream
, wxStringOutputStream
>
38 CPPUNIT_TEST_SUITE(strStream
);
39 // Base class stream tests the strStream supports.
40 CPPUNIT_TEST(Input_GetSize
);
41 CPPUNIT_TEST(Input_GetC
);
42 CPPUNIT_TEST(Input_Read
);
43 CPPUNIT_TEST(Input_Eof
);
44 CPPUNIT_TEST(Input_LastRead
);
45 CPPUNIT_TEST(Input_SeekI
);
46 CPPUNIT_TEST(Input_TellI
);
47 CPPUNIT_TEST(Input_Peek
);
48 CPPUNIT_TEST(Input_Ungetch
);
50 CPPUNIT_TEST(Output_PutC
);
51 CPPUNIT_TEST(Output_Write
);
52 CPPUNIT_TEST(Output_LastWrite
);
53 // seeking currently not supported by output string stream
54 //CPPUNIT_TEST(Output_SeekO);
55 //CPPUNIT_TEST(Output_TellO);
57 // Other test specific for String stream test case.
58 CPPUNIT_TEST_SUITE_END();
64 // Implement base class functions.
65 virtual wxStringInputStream
*DoCreateInStream();
66 virtual wxStringOutputStream
*DoCreateOutStream();
71 strStream::strStream()
73 static const size_t LEN
= 256;
75 for ( size_t n
= 0; n
< LEN
; n
++ )
77 m_str
+= _T('A') + n
% (_T('Z') - _T('A') + 1);
81 strStream::~strStream()
85 wxStringInputStream
*strStream::DoCreateInStream()
87 wxStringInputStream
*pStrInStream
= new wxStringInputStream(m_str
);
88 CPPUNIT_ASSERT(pStrInStream
->IsOk());
92 wxStringOutputStream
*strStream::DoCreateOutStream()
94 wxStringOutputStream
*pStrOutStream
= new wxStringOutputStream();
95 CPPUNIT_ASSERT(pStrOutStream
->IsOk());
100 // Register the stream sub suite, by using some stream helper macro.
101 STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(strStream
)