]>
git.saurik.com Git - wxWidgets.git/blob - tests/streams/iostreams.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/streams/iostreams.cpp
3 // Purpose: unit test for input/output streams
4 // Author: Vadim Zeitlin
6 ///////////////////////////////////////////////////////////////////////////////
8 // ----------------------------------------------------------------------------
10 // ----------------------------------------------------------------------------
20 #include "wx/filename.h"
21 #include "wx/wfstream.h"
23 // --------------------------------------------------------------------------
25 // --------------------------------------------------------------------------
27 class IOStreamsTestCase
: public CppUnit::TestCase
30 IOStreamsTestCase() { }
32 virtual void tearDown()
34 if ( !m_fnTemp
.empty() )
36 wxRemoveFile(m_fnTemp
);
42 CPPUNIT_TEST_SUITE( IOStreamsTestCase
);
43 CPPUNIT_TEST( FStream
);
44 CPPUNIT_TEST( FFStream
);
45 CPPUNIT_TEST_SUITE_END();
47 void FStream() { wxFileStream
s(GetTempFName()); DoTest(s
); }
48 void FFStream() { wxFFileStream
s(GetTempFName()); DoTest(s
); }
50 wxString
GetTempFName()
52 m_fnTemp
= wxFileName::CreateTempFileName("wxtest");
56 template <class Stream
>
57 void DoTest(Stream
& s
)
60 CPPUNIT_ASSERT_EQUAL( 1, s
.LastWrite() );
63 CPPUNIT_ASSERT_EQUAL( int('x'), s
.GetC() );
68 DECLARE_NO_COPY_CLASS(IOStreamsTestCase
)
71 // register in the unnamed registry so that these tests are run by default
72 CPPUNIT_TEST_SUITE_REGISTRATION( IOStreamsTestCase
);
74 // also include in its own registry so that these tests can be run alone
75 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( IOStreamsTestCase
, "IOStreamsTestCase" );
77 #endif // wxUSE_STREAMS