]>
git.saurik.com Git - wxWidgets.git/blob - tests/streams/memstream.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/streams/memstream.cpp
3 // Purpose: Test wxMemoryInputStream/wxMemoryOutputStream
4 // Author: Hans Van Leemputten
6 // Copyright: (c) 2004 Hans Van Leemputten
7 // Licence: wxWidgets licence
8 ///////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx/wx.h".
18 // for all others, include the necessary headers
23 #include "wx/mstream.h"
27 #define DATABUFFER_SIZE 256
29 ///////////////////////////////////////////////////////////////////////////////
32 // Try to fully test wxMemoryInputStream and wxMemoryOutputStream
34 class memStream
: public BaseStreamTestCase
<wxMemoryInputStream
, wxMemoryOutputStream
>
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
);
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
);
58 // Other test specific for Memory stream test case.
59 CPPUNIT_TEST_SUITE_END();
65 const char *GetDataBuffer();
68 // Implement base class functions.
69 virtual wxMemoryInputStream
*DoCreateInStream();
70 virtual wxMemoryOutputStream
*DoCreateOutStream();
73 char m_DataBuffer
[DATABUFFER_SIZE
];
76 memStream::memStream()
78 // Init the data buffer.
79 for (size_t i
= 0; i
< DATABUFFER_SIZE
; i
++)
80 m_DataBuffer
[i
] = (i
% 0xFF);
83 memStream::~memStream()
85 /* Nothing extra for now. */
88 const char *memStream::GetDataBuffer()
93 wxMemoryInputStream
*memStream::DoCreateInStream()
95 wxMemoryInputStream
*pMemInStream
= new wxMemoryInputStream(GetDataBuffer(), DATABUFFER_SIZE
);
96 CPPUNIT_ASSERT(pMemInStream
->IsOk());
99 wxMemoryOutputStream
*memStream::DoCreateOutStream()
101 wxMemoryOutputStream
*pMemOutStream
= new wxMemoryOutputStream();
102 CPPUNIT_ASSERT(pMemOutStream
->IsOk());
103 return pMemOutStream
;
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())
109 STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(memStream
)