]> git.saurik.com Git - wxWidgets.git/blame - tests/streams/memstream.cpp
file dialog with wxMULTIPLE style still doesn't allow to select multiple files but...
[wxWidgets.git] / tests / streams / memstream.cpp
CommitLineData
340da6ae
VS
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/streams/memstream.cpp
3// Purpose: Test wxMemoryInputStream/wxMemoryOutputStream
4// Author: Hans Van Leemputten
5// RCS-ID: $Id$
6// Copyright: (c) 2004 Hans Van Leemputten
7// Licence: wxWidgets licence
8///////////////////////////////////////////////////////////////////////////////
9
340da6ae 10// For compilers that support precompilation, includes "wx/wx.h".
8899b155
RN
11// and "wx/cppunit.h"
12#include "testprec.h"
340da6ae
VS
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
18// for all others, include the necessary headers
19#ifndef WX_PRECOMP
20 #include "wx/wx.h"
21#endif
22
340da6ae
VS
23#include "wx/mstream.h"
24
25#include "bstream.h"
26
340da6ae
VS
27#define DATABUFFER_SIZE 256
28
29///////////////////////////////////////////////////////////////////////////////
30// The test case
31//
32// Try to fully test wxMemoryInputStream and wxMemoryOutputStream
33
34class memStream : public BaseStreamTestCase<wxMemoryInputStream, wxMemoryOutputStream>
35{
36public:
37 memStream();
38 virtual ~memStream();
39
40 CPPUNIT_TEST_SUITE(memStream);
41 // Base class stream tests the memStream supports.
42 CPPUNIT_TEST(Input_GetSize);
43 CPPUNIT_TEST(Input_GetC);
44 CPPUNIT_TEST(Input_Read);
45 CPPUNIT_TEST(Input_Eof);
46 CPPUNIT_TEST(Input_LastRead);
47 CPPUNIT_TEST(Input_SeekI);
48 CPPUNIT_TEST(Input_TellI);
49 CPPUNIT_TEST(Input_Peek);
50 CPPUNIT_TEST(Input_Ungetch);
51
52 CPPUNIT_TEST(Output_PutC);
53 CPPUNIT_TEST(Output_Write);
54 CPPUNIT_TEST(Output_LastWrite);
55 CPPUNIT_TEST(Output_SeekO);
56 CPPUNIT_TEST(Output_TellO);
57
58 // Other test specific for Memory stream test case.
59 CPPUNIT_TEST_SUITE_END();
60
61protected:
62 // Add own test here.
63
64private:
65 const char *GetDataBuffer();
66
67private:
68 // Implement base class functions.
3e5f6c1c 69 virtual wxMemoryInputStream *DoCreateInStream();
340da6ae
VS
70 virtual wxMemoryOutputStream *DoCreateOutStream();
71
72private:
73 char m_DataBuffer[DATABUFFER_SIZE];
74};
75
76memStream::memStream()
77{
78 // Init the data buffer.
79 for (size_t i = 0; i < DATABUFFER_SIZE; i++)
80 m_DataBuffer[i] = (i % 0xFF);
81}
82
83memStream::~memStream()
84{
85 /* Nothing extra for now. */
86}
87
88const char *memStream::GetDataBuffer()
89{
90 return m_DataBuffer;
91}
92
3e5f6c1c
WS
93wxMemoryInputStream *memStream::DoCreateInStream()
94{
340da6ae
VS
95 wxMemoryInputStream *pMemInStream = new wxMemoryInputStream(GetDataBuffer(), DATABUFFER_SIZE);
96 CPPUNIT_ASSERT(pMemInStream->IsOk());
97 return pMemInStream;
98}
99wxMemoryOutputStream *memStream::DoCreateOutStream()
3e5f6c1c 100{
340da6ae
VS
101 wxMemoryOutputStream *pMemOutStream = new wxMemoryOutputStream();
102 CPPUNIT_ASSERT(pMemOutStream->IsOk());
103 return pMemOutStream;
104}
105
106
107// Register the stream sub suite, by using some stream helper macro.
108// Note: Don't forget to connect it to the base suite (See: bstream.cpp => StreamCase::suite())
109STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(memStream)