]> git.saurik.com Git - wxWidgets.git/blob - tests/streams/sstream.cpp
compilation fix: wxColour::GetColor() returns const object
[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 // and "wx/cppunit.h"
12 #include "testprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 // for all others, include the necessary headers
19 #ifndef WX_PRECOMP
20 #endif
21
22 #include "wx/sstream.h"
23
24 #include "bstream.h"
25
26 ///////////////////////////////////////////////////////////////////////////////
27 // The test case
28 //
29 // Try to fully test wxStringInputStream and wxStringOutputStream
30
31 class strStream :
32 public BaseStreamTestCase<wxStringInputStream, wxStringOutputStream>
33 {
34 public:
35 strStream();
36 virtual ~strStream();
37
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_CanRead);
46 CPPUNIT_TEST(Input_SeekI);
47 CPPUNIT_TEST(Input_TellI);
48 CPPUNIT_TEST(Input_Peek);
49 CPPUNIT_TEST(Input_Ungetch);
50
51 CPPUNIT_TEST(Output_PutC);
52 CPPUNIT_TEST(Output_Write);
53 CPPUNIT_TEST(Output_LastWrite);
54 // seeking currently not supported by output string stream
55 //CPPUNIT_TEST(Output_SeekO);
56 //CPPUNIT_TEST(Output_TellO);
57
58 // Other test specific for String stream test case.
59 CPPUNIT_TEST_SUITE_END();
60
61 protected:
62 // Add own test here.
63
64 private:
65 // Implement base class functions.
66 virtual wxStringInputStream *DoCreateInStream();
67 virtual wxStringOutputStream *DoCreateOutStream();
68
69 wxString m_str;
70 };
71
72 strStream::strStream()
73 {
74 static const size_t LEN = 256;
75 m_str.reserve(LEN);
76 for ( size_t n = 0; n < LEN; n++ )
77 {
78 m_str += wxChar(_T('A') + n % (_T('Z') - _T('A') + 1));
79 }
80 }
81
82 strStream::~strStream()
83 {
84 }
85
86 wxStringInputStream *strStream::DoCreateInStream()
87 {
88 wxStringInputStream *pStrInStream = new wxStringInputStream(m_str);
89 CPPUNIT_ASSERT(pStrInStream->IsOk());
90 return pStrInStream;
91 }
92
93 wxStringOutputStream *strStream::DoCreateOutStream()
94 {
95 wxStringOutputStream *pStrOutStream = new wxStringOutputStream();
96 CPPUNIT_ASSERT(pStrOutStream->IsOk());
97 return pStrOutStream;
98 }
99
100
101 // Register the stream sub suite, by using some stream helper macro.
102 STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(strStream)