]> git.saurik.com Git - wxWidgets.git/blob - tests/streams/sstream.cpp
Added SetScrollLinesX, SetScrollLinesY so apps can work around scrollbar
[wxWidgets.git] / tests / streams / sstream.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/streams/sstream.cpp
3 // Purpose: Test wxStringInputStream/wxStringOutputStream
4 // Author: Vadim Zeitlin
5 // RCS-ID: $Id$
6 // Copyright: (c) 2004 Vadim Zeitlin
7 // Licence: wxWidgets licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx/wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 // for all others, include the necessary headers
18 #ifndef WX_PRECOMP
19 #endif
20
21 #include "wx/cppunit.h"
22 #include "wx/sstream.h"
23
24 #include "bstream.h"
25
26 using namespace std;
27 using namespace CppUnit;
28
29 ///////////////////////////////////////////////////////////////////////////////
30 // The test case
31 //
32 // Try to fully test wxStringInputStream and wxStringOutputStream
33
34 class strStream :
35 public BaseStreamTestCase<wxStringInputStream, wxStringOutputStream>
36 {
37 public:
38 strStream();
39 virtual ~strStream();
40
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);
52
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);
59
60 // Other test specific for String stream test case.
61 CPPUNIT_TEST_SUITE_END();
62
63 protected:
64 // Add own test here.
65
66 private:
67 // Implement base class functions.
68 virtual wxStringInputStream *DoCreateInStream();
69 virtual wxStringOutputStream *DoCreateOutStream();
70
71 wxString m_str;
72 };
73
74 strStream::strStream()
75 {
76 static const size_t LEN = 256;
77 m_str.reserve(LEN);
78 for ( size_t n = 0; n < LEN; n++ )
79 {
80 m_str += _T('A') + n % (_T('Z') - _T('A') + 1);
81 }
82 }
83
84 strStream::~strStream()
85 {
86 }
87
88 wxStringInputStream *strStream::DoCreateInStream()
89 {
90 wxStringInputStream *pStrInStream = new wxStringInputStream(m_str);
91 CPPUNIT_ASSERT(pStrInStream->IsOk());
92 return pStrInStream;
93 }
94
95 wxStringOutputStream *strStream::DoCreateOutStream()
96 {
97 wxStringOutputStream *pStrOutStream = new wxStringOutputStream();
98 CPPUNIT_ASSERT(pStrOutStream->IsOk());
99 return pStrOutStream;
100 }
101
102
103 // Register the stream sub suite, by using some stream helper macro.
104 STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(strStream)