Update contrib.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
24 # include "cppunit/cppunit_proxy.h"
26 # if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
33 class IOStreamTest : public CPPUNIT_NS::TestCase
35 CPPUNIT_TEST_SUITE(IOStreamTest);
36 CPPUNIT_TEST(manipulators);
37 CPPUNIT_TEST(stringstream_cov);
38 // CPPUNIT_TEST(iostream_cov1);
39 CPPUNIT_TEST(iostream_cov2);
40 CPPUNIT_TEST_SUITE_END();
44 void stringstream_cov();
45 // void iostream_cov1();
49 CPPUNIT_TEST_SUITE_REGISTRATION(IOStreamTest);
50 void testfn (ios_base::event ev, ios_base& /*iosobj*/, int /*index*/)
55 case ios_base::copyfmt_event:
57 case ios_base::imbue_event:
61 case ios_base::erase_event:
68 // tests implementation
70 void IOStreamTest::manipulators()
77 CPPUNIT_ASSERT( istr.good() );
81 CPPUNIT_ASSERT( istr.eof() );
82 CPPUNIT_ASSERT( !istr.fail() );
83 CPPUNIT_ASSERT( foo == "bar" );
86 CPPUNIT_ASSERT( istr.eof() );
87 CPPUNIT_ASSERT( !istr.fail() );
96 CPPUNIT_ASSERT( istr.good() );
100 CPPUNIT_ASSERT( !istr.eof() );
101 CPPUNIT_ASSERT( !istr.fail() );
102 CPPUNIT_ASSERT( foo == "bar" );
105 CPPUNIT_ASSERT( istr.eof() );
106 CPPUNIT_ASSERT( !istr.fail() );
111 void IOStreamTest::stringstream_cov()
114 basic_string<char> i( "stdcpp" );
115 stringstream ss1,ss2,ss3;
116 ss1.rdbuf( )->str( i );
117 string foo1,foo2,foo3;
119 CPPUNIT_ASSERT(foo1 == "stdcpp");
122 CPPUNIT_ASSERT(foo2 == "pips");
123 ss3.rdbuf( )->str( "stdcppwithpips" );
125 CPPUNIT_ASSERT(foo3 == "stdcppwithpips");
129 void IOStreamTest::iostream_cov1()
133 static const int i = ios_base::xalloc();
134 cout.iword( i ) = 11;
136 CPPUNIT_ASSERT(cout.iword( i ) == 11);
137 CPPUNIT_ASSERT(cin.iword( i ) == 13);
142 void IOStreamTest::iostream_cov2()
146 filestr.register_callback (testfn,0);
147 bool x = filestr.sync_with_stdio();
149 filestr.imbue (cout.getloc());