ReactOS 0.4.15-dev-7942-gd23573b
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
10
11# if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
12using namespace std;
13# endif
14
15//
16// TestCase class
17//
18class IOStreamTest : public CPPUNIT_NS::TestCase
19{
23//#if defined (STLPORT) && defined (_STLP_NO_WCHAR_T)
24 //CPPUNIT_IGNORE;
25//#endif
26 //CPPUNIT_TEST(wimbue);
28
29private:
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
CPPUNIT_TEST(in_avail)
void manipulators()
CPPUNIT_TEST_SUITE_END()
CPPUNIT_TEST_SUITE(IOStreamTest)
CPPUNIT_TEST(manipulators)
void clear(iostate __state=goodbit)
Definition: _ios.h:91
_String str() const
Definition: _sstream.h:141
bool fail() const
Definition: _ios_base.h:174
bool eof() const
Definition: _ios_base.h:173
bool good() const
Definition: _ios_base.h:172
#define CPPUNIT_CHECK(X)
Definition: cppunit_mini.h:195
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
_STLP_DECLSPEC _Stl_aligned_buffer< wostream > wcout
Definition: iostream.cpp:120
#define cout
Definition: iostream.cpp:38
_STLP_DECLSPEC _Stl_aligned_buffer< wostream > wcerr
Definition: iostream.cpp:121
#define cin
Definition: iostream.cpp:37
#define cerr
Definition: iostream.cpp:39
_STLP_DECLSPEC _Stl_aligned_buffer< wostream > wclog
Definition: iostream.cpp:122
#define clog
Definition: iostream.cpp:40
_STLP_DECLSPEC _Stl_aligned_buffer< wistream > wcin
Definition: iostream.cpp:119
Definition: features.h:417
const char * ws
Definition: skip_ws.cpp:7