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