]> git.saurik.com Git - wxWidgets.git/blame - tests/streams/sstream.cpp
support for fractional characters widths under Mac
[wxWidgets.git] / tests / streams / sstream.cpp
CommitLineData
32d49041
VZ
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".
8899b155
RN
11// and "wx/cppunit.h"
12#include "testprec.h"
32d49041
VZ
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
32d49041
VZ
22#include "wx/sstream.h"
23
24#include "bstream.h"
25
32d49041
VZ
26///////////////////////////////////////////////////////////////////////////////
27// The test case
28//
29// Try to fully test wxStringInputStream and wxStringOutputStream
30
31class strStream :
32 public BaseStreamTestCase<wxStringInputStream, wxStringOutputStream>
33{
34public:
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_SeekI);
46 CPPUNIT_TEST(Input_TellI);
47 CPPUNIT_TEST(Input_Peek);
48 CPPUNIT_TEST(Input_Ungetch);
49
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);
56
57 // Other test specific for String stream test case.
58 CPPUNIT_TEST_SUITE_END();
59
60protected:
61 // Add own test here.
62
63private:
64 // Implement base class functions.
3e5f6c1c 65 virtual wxStringInputStream *DoCreateInStream();
32d49041
VZ
66 virtual wxStringOutputStream *DoCreateOutStream();
67
68 wxString m_str;
69};
70
71strStream::strStream()
72{
73 static const size_t LEN = 256;
74 m_str.reserve(LEN);
75 for ( size_t n = 0; n < LEN; n++ )
76 {
77 m_str += _T('A') + n % (_T('Z') - _T('A') + 1);
78 }
79}
80
81strStream::~strStream()
82{
83}
84
3e5f6c1c
WS
85wxStringInputStream *strStream::DoCreateInStream()
86{
32d49041
VZ
87 wxStringInputStream *pStrInStream = new wxStringInputStream(m_str);
88 CPPUNIT_ASSERT(pStrInStream->IsOk());
89 return pStrInStream;
90}
91
92wxStringOutputStream *strStream::DoCreateOutStream()
3e5f6c1c 93{
32d49041
VZ
94 wxStringOutputStream *pStrOutStream = new wxStringOutputStream();
95 CPPUNIT_ASSERT(pStrOutStream->IsOk());
96 return pStrOutStream;
97}
98
99
100// Register the stream sub suite, by using some stream helper macro.
101STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(strStream)