ReactOS  0.4.15-dev-1184-g23e04ae
iostream_test.cpp
Go to the documentation of this file.
1 #include <string>
2 
3 #if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
4 # include <sstream>
5 //# include <locale>
6 # include <iostream>
7 //# include <stdexcept>
8 
9 # include "cppunit/cppunit_proxy.h"
10 
11 # if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
12 using namespace std;
13 # endif
14 
15 //
16 // TestCase class
17 //
18 class IOStreamTest : public CPPUNIT_NS::TestCase
19 {
21  CPPUNIT_TEST(manipulators);
22  CPPUNIT_TEST(in_avail);
23 //#if defined (STLPORT) && defined (_STLP_NO_WCHAR_T)
24  //CPPUNIT_IGNORE;
25 //#endif
26  //CPPUNIT_TEST(wimbue);
28 
29 private:
30  void manipulators();
31  void in_avail();
32  //void wimbue();
33 };
34 
36 
37 //
38 // tests implementation
39 //
41 {
42  {
43  istringstream istr;
44  istr.str("bar");
45 
46  istr >> ws;
47  CPPUNIT_ASSERT( istr.good() );
48 
49  string foo;
50  istr >> foo;
51  CPPUNIT_ASSERT( istr.eof() );
52  CPPUNIT_ASSERT( !istr.fail() );
53  CPPUNIT_ASSERT( foo == "bar" );
54 
55  istr >> ws;
56  CPPUNIT_ASSERT( istr.eof() );
57  CPPUNIT_ASSERT( !istr.fail() );
58  istr.clear();
59  }
60 
61  {
62  istringstream istr;
63  istr.str(" bar ");
64 
65  istr >> ws;
66  CPPUNIT_ASSERT( istr.good() );
67 
68  string foo;
69  istr >> foo;
70  CPPUNIT_ASSERT( !istr.eof() );
71  CPPUNIT_ASSERT( !istr.fail() );
72  CPPUNIT_ASSERT( foo == "bar" );
73 
74  istr >> ws;
75  CPPUNIT_ASSERT( istr.eof() );
76  CPPUNIT_ASSERT( !istr.fail() );
77  istr.clear();
78  }
79 }
80 
81 
83 {
84  CPPUNIT_CHECK( cin.rdbuf()->in_avail() == 0 );
85  CPPUNIT_CHECK( cout.rdbuf()->in_avail() == -1 );
86  CPPUNIT_CHECK( clog.rdbuf()->in_avail() == -1 );
87  CPPUNIT_CHECK( cerr.rdbuf()->in_avail() == -1 );
88 
89 #if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
90  CPPUNIT_CHECK( wcin.rdbuf()->in_avail() == 0 );
91  CPPUNIT_CHECK( wcout.rdbuf()->in_avail() == 0 );
92  CPPUNIT_CHECK( wclog.rdbuf()->in_avail() == 0 );
93  CPPUNIT_CHECK( wcerr.rdbuf()->in_avail() == 0 );
94 #endif
95 }
96 
97 //void IOStreamTest::wimbue()
98 //{
99 //#if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
100 // locale loc;
101 // try {
102 // locale tmp(".866");
103 // loc = tmp;
104 // }
105 // catch (const runtime_error&) {
106 // return;
107 // }
108 //
109 // wcout.imbue(loc);
110 // wcout << L"Hello world" << endl;
111 // wcout.imbue(loc);
112 // wcout << L"Hello world" << endl;
113 //#endif
114 //}
115 
116 #endif
const char * ws
Definition: skip_ws.cpp:7
_STLP_DECLSPEC _Stl_aligned_buffer< wostream > wcout
Definition: iostream.cpp:120
#define CPPUNIT_TEST_SUITE(X)
Definition: cppunit_mini.h:142
#define CPPUNIT_TEST(X)
Definition: cppunit_mini.h:182
_String str() const
Definition: _sstream.h:141
_STLP_DECLSPEC _Stl_aligned_buffer< wostream > wcerr
Definition: iostream.cpp:121
void manipulators()
bool fail() const
Definition: _ios_base.h:174
Definition: features.h:417
CPPUNIT_TEST_SUITE_REGISTRATION(IOStreamTest)
#define cout
Definition: iostream.cpp:38
#define cin
Definition: iostream.cpp:37
void clear(iostate __state=goodbit)
Definition: _ios.h:91
#define CPPUNIT_TEST_SUITE_END()
Definition: cppunit_mini.h:191
#define CPPUNIT_CHECK(X)
Definition: cppunit_mini.h:195
_STLP_DECLSPEC _Stl_aligned_buffer< ostream > cerr
Definition: iostream.cpp:102
#define clog
Definition: iostream.cpp:40
int foo()
bool eof() const
Definition: _ios_base.h:173
_STLP_DECLSPEC _Stl_aligned_buffer< wistream > wcin
Definition: iostream.cpp:119
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
bool good() const
Definition: _ios_base.h:172
_STLP_DECLSPEC _Stl_aligned_buffer< wostream > wclog
Definition: iostream.cpp:122