]> git.saurik.com Git - wxWidgets.git/blob - tests/streams/memstream.cpp
ActiveX events should be sent to the window, not it's parent.
[wxWidgets.git] / tests / streams / memstream.cpp
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
10 #if defined(__GNUG__) && !defined(__APPLE__)
11 #pragma implementation
12 #pragma interface
13 #endif
14
15 // For compilers that support precompilation, includes "wx/wx.h".
16 #include "wx/wxprec.h"
17
18 #ifdef __BORLANDC__
19 #pragma hdrstop
20 #endif
21
22 // for all others, include the necessary headers
23 #ifndef WX_PRECOMP
24 #include "wx/wx.h"
25 #endif
26
27 #include "wx/cppunit.h"
28 #include "wx/mstream.h"
29
30 #include "bstream.h"
31
32 using namespace std;
33 using namespace CppUnit;
34
35 #define DATABUFFER_SIZE 256
36
37 ///////////////////////////////////////////////////////////////////////////////
38 // The test case
39 //
40 // Try to fully test wxMemoryInputStream and wxMemoryOutputStream
41
42 class memStream : public BaseStreamTestCase<wxMemoryInputStream, wxMemoryOutputStream>
43 {
44 public:
45 memStream();
46 virtual ~memStream();
47
48 CPPUNIT_TEST_SUITE(memStream);
49 // Base class stream tests the memStream supports.
50 CPPUNIT_TEST(Input_GetSize);
51 CPPUNIT_TEST(Input_GetC);
52 CPPUNIT_TEST(Input_Read);
53 CPPUNIT_TEST(Input_Eof);
54 CPPUNIT_TEST(Input_LastRead);
55 CPPUNIT_TEST(Input_SeekI);
56 CPPUNIT_TEST(Input_TellI);
57 CPPUNIT_TEST(Input_Peek);
58 CPPUNIT_TEST(Input_Ungetch);
59
60 CPPUNIT_TEST(Output_PutC);
61 CPPUNIT_TEST(Output_Write);
62 CPPUNIT_TEST(Output_LastWrite);
63 CPPUNIT_TEST(Output_SeekO);
64 CPPUNIT_TEST(Output_TellO);
65
66 // Other test specific for Memory stream test case.
67 CPPUNIT_TEST_SUITE_END();
68
69 protected:
70 // Add own test here.
71
72 private:
73 const char *GetDataBuffer();
74
75 private:
76 // Implement base class functions.
77 virtual wxMemoryInputStream *DoCreateInStream();
78 virtual wxMemoryOutputStream *DoCreateOutStream();
79
80 private:
81 char m_DataBuffer[DATABUFFER_SIZE];
82 };
83
84 memStream::memStream()
85 {
86 // Init the data buffer.
87 for (size_t i = 0; i < DATABUFFER_SIZE; i++)
88 m_DataBuffer[i] = (i % 0xFF);
89 }
90
91 memStream::~memStream()
92 {
93 /* Nothing extra for now. */
94 }
95
96 const char *memStream::GetDataBuffer()
97 {
98 return m_DataBuffer;
99 }
100
101 wxMemoryInputStream *memStream::DoCreateInStream()
102 {
103 wxMemoryInputStream *pMemInStream = new wxMemoryInputStream(GetDataBuffer(), DATABUFFER_SIZE);
104 CPPUNIT_ASSERT(pMemInStream->IsOk());
105 return pMemInStream;
106 }
107 wxMemoryOutputStream *memStream::DoCreateOutStream()
108 {
109 wxMemoryOutputStream *pMemOutStream = new wxMemoryOutputStream();
110 CPPUNIT_ASSERT(pMemOutStream->IsOk());
111 return pMemOutStream;
112 }
113
114
115 // Register the stream sub suite, by using some stream helper macro.
116 // Note: Don't forget to connect it to the base suite (See: bstream.cpp => StreamCase::suite())
117 STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(memStream)