]>
git.saurik.com Git - wxWidgets.git/blob - tests/streams/iostreams.cpp
07fdb16506dbbf0537ceffac1275eace51418d40
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/streams/iostreams.cpp
3 // Purpose: unit test for input/output streams
4 // Author: Vadim Zeitlin
7 ///////////////////////////////////////////////////////////////////////////////
9 // ----------------------------------------------------------------------------
11 // ----------------------------------------------------------------------------
21 #include "wx/filename.h"
22 #include "wx/wfstream.h"
24 // --------------------------------------------------------------------------
26 // --------------------------------------------------------------------------
28 class IOStreamsTestCase
: public CppUnit::TestCase
31 IOStreamsTestCase() { }
33 virtual void tearDown()
35 if ( !m_fnTemp
.empty() )
37 wxRemoveFile(m_fnTemp
);
43 CPPUNIT_TEST_SUITE( IOStreamsTestCase
);
44 CPPUNIT_TEST( FStream
);
45 CPPUNIT_TEST( FFStream
);
46 CPPUNIT_TEST_SUITE_END();
48 void FStream() { wxFileStream
s(GetTempFName()); DoTest(s
); }
49 void FFStream() { wxFFileStream
s(GetTempFName()); DoTest(s
); }
51 wxString
GetTempFName()
53 m_fnTemp
= wxFileName::CreateTempFileName("wxtest");
57 template <class Stream
>
58 void DoTest(Stream
& s
)
61 CPPUNIT_ASSERT_EQUAL( 1, s
.LastWrite() );
64 CPPUNIT_ASSERT_EQUAL( int('x'), s
.GetC() );
69 DECLARE_NO_COPY_CLASS(IOStreamsTestCase
)
72 // register in the unnamed registry so that these tests are run by default
73 CPPUNIT_TEST_SUITE_REGISTRATION( IOStreamsTestCase
);
75 // also include in its own registry so that these tests can be run alone
76 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( IOStreamsTestCase
, "IOStreamsTestCase" );
78 #endif // wxUSE_STREAMS