ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

iostream_test.cpp
Go to the documentation of this file.
00001 #include <string>
00002 
00003 #if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
00004 #  include <sstream>
00005 //#  include <locale>
00006 #  include <iostream>
00007 //#  include <stdexcept>
00008 
00009 #  include "cppunit/cppunit_proxy.h"
00010 
00011 #  if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
00012 using namespace std;
00013 #  endif
00014 
00015 //
00016 // TestCase class
00017 //
00018 class IOStreamTest : public CPPUNIT_NS::TestCase
00019 {
00020   CPPUNIT_TEST_SUITE(IOStreamTest);
00021   CPPUNIT_TEST(manipulators);
00022   CPPUNIT_TEST(in_avail);
00023 //#if defined (STLPORT) && defined (_STLP_NO_WCHAR_T)
00024   //CPPUNIT_IGNORE;
00025 //#endif
00026   //CPPUNIT_TEST(wimbue);
00027   CPPUNIT_TEST_SUITE_END();
00028 
00029 private:
00030   void manipulators();
00031   void in_avail();
00032   //void wimbue();
00033 };
00034 
00035 CPPUNIT_TEST_SUITE_REGISTRATION(IOStreamTest);
00036 
00037 //
00038 // tests implementation
00039 //
00040 void IOStreamTest::manipulators()
00041 {
00042   {
00043     istringstream istr;
00044     istr.str("bar");
00045 
00046     istr >> ws;
00047     CPPUNIT_ASSERT( istr.good() );
00048 
00049     string foo;
00050     istr >> foo;
00051     CPPUNIT_ASSERT( istr.eof() );
00052     CPPUNIT_ASSERT( !istr.fail() );
00053     CPPUNIT_ASSERT( foo == "bar" );
00054 
00055     istr >> ws;
00056     CPPUNIT_ASSERT( istr.eof() );
00057     CPPUNIT_ASSERT( !istr.fail() );
00058     istr.clear();
00059   }
00060 
00061   {
00062     istringstream istr;
00063     istr.str("  bar  ");
00064 
00065     istr >> ws;
00066     CPPUNIT_ASSERT( istr.good() );
00067 
00068     string foo;
00069     istr >> foo;
00070     CPPUNIT_ASSERT( !istr.eof() );
00071     CPPUNIT_ASSERT( !istr.fail() );
00072     CPPUNIT_ASSERT( foo == "bar" );
00073 
00074     istr >> ws;
00075     CPPUNIT_ASSERT( istr.eof() );
00076     CPPUNIT_ASSERT( !istr.fail() );
00077     istr.clear();
00078   }
00079 }
00080 
00081 
00082 void IOStreamTest::in_avail()
00083 {
00084   CPPUNIT_CHECK( cin.rdbuf()->in_avail() == 0 );
00085   CPPUNIT_CHECK( cout.rdbuf()->in_avail() == -1 );
00086   CPPUNIT_CHECK( clog.rdbuf()->in_avail() == -1 );
00087   CPPUNIT_CHECK( cerr.rdbuf()->in_avail() == -1 );
00088 
00089 #if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
00090   CPPUNIT_CHECK( wcin.rdbuf()->in_avail() == 0 );
00091   CPPUNIT_CHECK( wcout.rdbuf()->in_avail() == 0 );
00092   CPPUNIT_CHECK( wclog.rdbuf()->in_avail() == 0 );
00093   CPPUNIT_CHECK( wcerr.rdbuf()->in_avail() == 0 );
00094 #endif
00095 }
00096 
00097 //void IOStreamTest::wimbue()
00098 //{
00099 //#if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
00100 //  locale loc;
00101 //  try {
00102 //    locale tmp(".866");
00103 //    loc = tmp;
00104 //  }
00105 //  catch (const runtime_error&) {
00106 //    return;
00107 //  }
00108 //
00109 //  wcout.imbue(loc);
00110 //  wcout << L"Hello world" << endl;
00111 //  wcout.imbue(loc);
00112 //  wcout << L"Hello world" << endl;
00113 //#endif
00114 //}
00115 
00116 #endif

Generated on Sun May 27 2012 04:35:28 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.