]> git.saurik.com Git - wxWidgets.git/blame - tests/streams/iostreams.cpp
Removing more CodeWarrior project files.
[wxWidgets.git] / tests / streams / iostreams.cpp
CommitLineData
02e22828
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/streams/iostreams.cpp
3// Purpose: unit test for input/output streams
4// Author: Vadim Zeitlin
5// Created: 2008-06-15
6// RCS-ID: $Id$
7///////////////////////////////////////////////////////////////////////////////
8
9// ----------------------------------------------------------------------------
10// headers
11// ----------------------------------------------------------------------------
12
13#include "testprec.h"
14
15#ifdef __BORLANDC__
16 #pragma hdrstop
17#endif
18
19#if wxUSE_STREAMS
20
21#include "wx/filename.h"
22#include "wx/wfstream.h"
23
24// --------------------------------------------------------------------------
25// test class
26// --------------------------------------------------------------------------
27
28class IOStreamsTestCase : public CppUnit::TestCase
29{
30public:
31 IOStreamsTestCase() { }
32
33 virtual void tearDown()
34 {
35 if ( !m_fnTemp.empty() )
36 {
37 wxRemoveFile(m_fnTemp);
38 m_fnTemp.clear();
39 }
40 }
41
42private:
43 CPPUNIT_TEST_SUITE( IOStreamsTestCase );
44 CPPUNIT_TEST( FStream );
45 CPPUNIT_TEST( FFStream );
46 CPPUNIT_TEST_SUITE_END();
47
48 void FStream() { wxFileStream s(GetTempFName()); DoTest(s); }
49 void FFStream() { wxFFileStream s(GetTempFName()); DoTest(s); }
50
51 wxString GetTempFName()
52 {
53 m_fnTemp = wxFileName::CreateTempFileName("wxtest");
54 return m_fnTemp;
55 }
56
57 template <class Stream>
58 void DoTest(Stream& s)
59 {
60 s.PutC('x');
1de532f5 61 CPPUNIT_ASSERT_EQUAL( 1, s.LastWrite() );
02e22828
VZ
62
63 s.SeekI(0);
64 CPPUNIT_ASSERT_EQUAL( int('x'), s.GetC() );
65 }
66
67 wxString m_fnTemp;
68
69 DECLARE_NO_COPY_CLASS(IOStreamsTestCase)
70};
71
72// register in the unnamed registry so that these tests are run by default
73CPPUNIT_TEST_SUITE_REGISTRATION( IOStreamsTestCase );
74
75// also include in it's own registry so that these tests can be run alone
76CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( IOStreamsTestCase, "IOStreamsTestCase" );
77
78#endif // wxUSE_STREAMS