reactos/lib/3rdparty/stlport/test/unit/iostream_test.cpp
Amine Khaldi 4efda499f7 [CMAKE]
Jerome Gardou:
- Add STLport 5.2.1 (yes, STLport, the c++ stl implementation) to build. For now, it works only in user mode.
- Link some c++ executables to it
- sol.exe : one step towards a complete and modern OS.
- Dedicated to Amine for his patience and his help.
- Might Break Things! (tm)

svn path=/branches/cmake-bringup/; revision=49046
2010-10-07 22:09:31 +00:00

117 lines
2.3 KiB
C++

#include <string>
#if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
# include <sstream>
//# include <locale>
# include <iostream>
//# include <stdexcept>
# include "cppunit/cppunit_proxy.h"
# if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
using namespace std;
# endif
//
// TestCase class
//
class IOStreamTest : public CPPUNIT_NS::TestCase
{
CPPUNIT_TEST_SUITE(IOStreamTest);
CPPUNIT_TEST(manipulators);
CPPUNIT_TEST(in_avail);
//#if defined (STLPORT) && defined (_STLP_NO_WCHAR_T)
//CPPUNIT_IGNORE;
//#endif
//CPPUNIT_TEST(wimbue);
CPPUNIT_TEST_SUITE_END();
private:
void manipulators();
void in_avail();
//void wimbue();
};
CPPUNIT_TEST_SUITE_REGISTRATION(IOStreamTest);
//
// tests implementation
//
void IOStreamTest::manipulators()
{
{
istringstream istr;
istr.str("bar");
istr >> ws;
CPPUNIT_ASSERT( istr.good() );
string foo;
istr >> foo;
CPPUNIT_ASSERT( istr.eof() );
CPPUNIT_ASSERT( !istr.fail() );
CPPUNIT_ASSERT( foo == "bar" );
istr >> ws;
CPPUNIT_ASSERT( istr.eof() );
CPPUNIT_ASSERT( !istr.fail() );
istr.clear();
}
{
istringstream istr;
istr.str(" bar ");
istr >> ws;
CPPUNIT_ASSERT( istr.good() );
string foo;
istr >> foo;
CPPUNIT_ASSERT( !istr.eof() );
CPPUNIT_ASSERT( !istr.fail() );
CPPUNIT_ASSERT( foo == "bar" );
istr >> ws;
CPPUNIT_ASSERT( istr.eof() );
CPPUNIT_ASSERT( !istr.fail() );
istr.clear();
}
}
void IOStreamTest::in_avail()
{
CPPUNIT_CHECK( cin.rdbuf()->in_avail() == 0 );
CPPUNIT_CHECK( cout.rdbuf()->in_avail() == -1 );
CPPUNIT_CHECK( clog.rdbuf()->in_avail() == -1 );
CPPUNIT_CHECK( cerr.rdbuf()->in_avail() == -1 );
#if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
CPPUNIT_CHECK( wcin.rdbuf()->in_avail() == 0 );
CPPUNIT_CHECK( wcout.rdbuf()->in_avail() == 0 );
CPPUNIT_CHECK( wclog.rdbuf()->in_avail() == 0 );
CPPUNIT_CHECK( wcerr.rdbuf()->in_avail() == 0 );
#endif
}
//void IOStreamTest::wimbue()
//{
//#if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
// locale loc;
// try {
// locale tmp(".866");
// loc = tmp;
// }
// catch (const runtime_error&) {
// return;
// }
//
// wcout.imbue(loc);
// wcout << L"Hello world" << endl;
// wcout.imbue(loc);
// wcout << L"Hello world" << endl;
//#endif
//}
#endif