]>
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"
33 using namespace CppUnit
;
35 #define DATABUFFER_SIZE 256
37 ///////////////////////////////////////////////////////////////////////////////
40 // Try to fully test wxMemoryInputStream and wxMemoryOutputStream
42 class memStream
: public BaseStreamTestCase
<wxMemoryInputStream
, wxMemoryOutputStream
>
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
);
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
);
66 // Other test specific for Memory stream test case.
67 CPPUNIT_TEST_SUITE_END();
73 const char *GetDataBuffer();
76 // Implement base class functions.
77 virtual wxMemoryInputStream
*DoCreateInStream();
78 virtual wxMemoryOutputStream
*DoCreateOutStream();
81 char m_DataBuffer
[DATABUFFER_SIZE
];
84 memStream::memStream()
86 // Init the data buffer.
87 for (size_t i
= 0; i
< DATABUFFER_SIZE
; i
++)
88 m_DataBuffer
[i
] = (i
% 0xFF);
91 memStream::~memStream()
93 /* Nothing extra for now. */
96 const char *memStream::GetDataBuffer()
101 wxMemoryInputStream
*memStream::DoCreateInStream()
103 wxMemoryInputStream
*pMemInStream
= new wxMemoryInputStream(GetDataBuffer(), DATABUFFER_SIZE
);
104 CPPUNIT_ASSERT(pMemInStream
->IsOk());
107 wxMemoryOutputStream
*memStream::DoCreateOutStream()
109 wxMemoryOutputStream
*pMemOutStream
= new wxMemoryOutputStream();
110 CPPUNIT_ASSERT(pMemOutStream
->IsOk());
111 return pMemOutStream
;
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
)