]>
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 #if defined(__GNUG__) && !defined(__APPLE__)
11 #pragma implementation
15 // For compilers that support precompilation, includes "wx/wx.h".
16 #include "wx/wxprec.h"
22 // for all others, include the necessary headers
27 #include "wx/cppunit.h"
28 #include "wx/mstream.h"
32 #define DATABUFFER_SIZE 256
34 ///////////////////////////////////////////////////////////////////////////////
37 // Try to fully test wxMemoryInputStream and wxMemoryOutputStream
39 class memStream
: public BaseStreamTestCase
<wxMemoryInputStream
, wxMemoryOutputStream
>
45 CPPUNIT_TEST_SUITE(memStream
);
46 // Base class stream tests the memStream supports.
47 CPPUNIT_TEST(Input_GetSize
);
48 CPPUNIT_TEST(Input_GetC
);
49 CPPUNIT_TEST(Input_Read
);
50 CPPUNIT_TEST(Input_Eof
);
51 CPPUNIT_TEST(Input_LastRead
);
52 CPPUNIT_TEST(Input_SeekI
);
53 CPPUNIT_TEST(Input_TellI
);
54 CPPUNIT_TEST(Input_Peek
);
55 CPPUNIT_TEST(Input_Ungetch
);
57 CPPUNIT_TEST(Output_PutC
);
58 CPPUNIT_TEST(Output_Write
);
59 CPPUNIT_TEST(Output_LastWrite
);
60 CPPUNIT_TEST(Output_SeekO
);
61 CPPUNIT_TEST(Output_TellO
);
63 // Other test specific for Memory stream test case.
64 CPPUNIT_TEST_SUITE_END();
70 const char *GetDataBuffer();
73 // Implement base class functions.
74 virtual wxMemoryInputStream
*DoCreateInStream();
75 virtual wxMemoryOutputStream
*DoCreateOutStream();
78 char m_DataBuffer
[DATABUFFER_SIZE
];
81 memStream::memStream()
83 // Init the data buffer.
84 for (size_t i
= 0; i
< DATABUFFER_SIZE
; i
++)
85 m_DataBuffer
[i
] = (i
% 0xFF);
88 memStream::~memStream()
90 /* Nothing extra for now. */
93 const char *memStream::GetDataBuffer()
98 wxMemoryInputStream
*memStream::DoCreateInStream()
100 wxMemoryInputStream
*pMemInStream
= new wxMemoryInputStream(GetDataBuffer(), DATABUFFER_SIZE
);
101 CPPUNIT_ASSERT(pMemInStream
->IsOk());
104 wxMemoryOutputStream
*memStream::DoCreateOutStream()
106 wxMemoryOutputStream
*pMemOutStream
= new wxMemoryOutputStream();
107 CPPUNIT_ASSERT(pMemOutStream
->IsOk());
108 return pMemOutStream
;
112 // Register the stream sub suite, by using some stream helper macro.
113 // Note: Don't forget to connect it to the base suite (See: bstream.cpp => StreamCase::suite())
114 STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(memStream
)