]> git.saurik.com Git - wxWidgets.git/blame - tests/streams/textstreamtest.cpp
Applied patch #1181805 TextEditMixin and EVT_LIST_END_LABEL_EDIT
[wxWidgets.git] / tests / streams / textstreamtest.cpp
CommitLineData
ba854691
RN
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/uris/uris.cpp
3// Purpose: wxTextXXXStream unit test
4// Author: Ryan Norton
5// Created: 2004-08-14
6// RCS-ID: $Id$
7// Copyright: (c) 2004 Ryan Norton
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
8899b155 14#include "testprec.h"
ba854691
RN
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#ifndef WX_PRECOMP
21 #include "wx/wx.h"
22#endif // WX_PRECOMP
23
24#include "wx/txtstrm.h"
25#include "wx/wfstream.h"
26
ba854691
RN
27// ----------------------------------------------------------------------------
28// test class
29// ----------------------------------------------------------------------------
30
31class TextStreamTestCase : public CppUnit::TestCase
32{
33public:
34 TextStreamTestCase();
35
36private:
37 CPPUNIT_TEST_SUITE( TextStreamTestCase );
38 CPPUNIT_TEST( Endline );
39 CPPUNIT_TEST_SUITE_END();
40
41 void Endline();
42
43
44 DECLARE_NO_COPY_CLASS(TextStreamTestCase)
45};
46
47// register in the unnamed registry so that these tests are run by default
48CPPUNIT_TEST_SUITE_REGISTRATION( TextStreamTestCase );
49
50// also include in it's own registry so that these tests can be run alone
51CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TextStreamTestCase, "TextStreamTestCase" );
52
53TextStreamTestCase::TextStreamTestCase()
54{
55}
56
57#if defined(__WXMSW__) || defined(__WXPM__)
58# define NEWLINE "\r\n"
59# define NEWLINELEN 2
60#elif defined(__WXMAC__) && !defined(__DARWIN__)
61# define NEWLINE "\r"
62# define NEWLINELEN 1
63#else
64# define NEWLINE "\n"
65# define NEWLINELEN 1
66#endif
67
68void TextStreamTestCase::Endline()
69{
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)");
74
75 delete pOutText;
76 delete pOutFile;
77
78 wxFileInputStream* pInFile = new wxFileInputStream(_T("test.txt"));
79
80 char szIn[9 + NEWLINELEN];
81
82 pInFile->Read(szIn, 9 + NEWLINELEN);
83
84 CPPUNIT_ASSERT( memcmp(&szIn[9], NEWLINE, NEWLINELEN) == 0 );
85
86 delete pInFile;
87}