]>
git.saurik.com Git - wxWidgets.git/blob - tests/streams/textstreamtest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/uris/uris.cpp
3 // Purpose: wxTextXXXStream unit test
7 // Copyright: (c) 2004 Ryan Norton
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
24 #include "wx/txtstrm.h"
25 #include "wx/wfstream.h"
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class TextStreamTestCase
: public CppUnit::TestCase
37 CPPUNIT_TEST_SUITE( TextStreamTestCase
);
38 CPPUNIT_TEST( Endline
);
39 CPPUNIT_TEST_SUITE_END();
44 DECLARE_NO_COPY_CLASS(TextStreamTestCase
)
47 // register in the unnamed registry so that these tests are run by default
48 CPPUNIT_TEST_SUITE_REGISTRATION( TextStreamTestCase
);
50 // also include in it's own registry so that these tests can be run alone
51 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TextStreamTestCase
, "TextStreamTestCase" );
53 TextStreamTestCase::TextStreamTestCase()
57 #if defined(__WXMSW__) || defined(__WXPM__)
58 # define NEWLINE "\r\n"
60 #elif defined(__WXMAC__) && !defined(__DARWIN__)
68 void TextStreamTestCase::Endline()
70 wxFileOutputStream
* pOutFile
= new wxFileOutputStream(_T("test.txt"));
71 wxTextOutputStream
* pOutText
= new wxTextOutputStream(*pOutFile
);
72 *pOutText
<< _T("Test text") << endl
73 << _T("More Testing Text (There should be newline before this)");
78 wxFileInputStream
* pInFile
= new wxFileInputStream(_T("test.txt"));
80 char szIn
[9 + NEWLINELEN
];
82 pInFile
->Read(szIn
, 9 + NEWLINELEN
);
84 CPPUNIT_ASSERT( memcmp(&szIn
[9], NEWLINE
, NEWLINELEN
) == 0 );