sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: #include "twiostreams.h" sl@0: #define STDCPP_OOM FALSE sl@0: using namespace std; sl@0: sl@0: sl@0: sl@0: // ============================ MEMBER FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CCtwiostreams::Delete sl@0: // Delete here all resources allocated and opened from test methods. sl@0: // Called from destructor. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void Ctwiostreams::Delete() sl@0: { sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CCtwiostreams::RunMethodL sl@0: // Run specified method. Contains also table of test mothods and their names. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt Ctwiostreams::RunMethodL( sl@0: CStifItemParser& aItem ) sl@0: { sl@0: sl@0: static TStifFunctionInfo const KFunctions[] = sl@0: { sl@0: // Copy this line for every implemented function. sl@0: // First string is the function name used in TestScripter script file. sl@0: // Second is the actual implementation member function. sl@0: ENTRY( "basicstring", Ctwiostreams::basicstring ), sl@0: ENTRY( "basicfilebufL", Ctwiostreams::basicfilebufL ), sl@0: ENTRY( "basicistreamL", Ctwiostreams::basicistreamL ), sl@0: ENTRY( "wfstreamL", Ctwiostreams::wfstreamL ), sl@0: ENTRY( "wifstreamL", Ctwiostreams::wifstreamL ), sl@0: ENTRY( "wistreamL", Ctwiostreams::wistreamL ), sl@0: ENTRY( "wofstreamL", Ctwiostreams::wofstreamL ), sl@0: ENTRY( "wistringstreamL", Ctwiostreams::wistringstreamL ), sl@0: ENTRY( "wostringstreamL", Ctwiostreams::wostringstreamL ), sl@0: ENTRY( "wstreambufL", Ctwiostreams::wstreambufL ), sl@0: ENTRY( "wostreamL", Ctwiostreams::wostreamL ), sl@0: ENTRY( "wstringbufL", Ctwiostreams::wstringbufL ), sl@0: sl@0: sl@0: }; sl@0: sl@0: const TInt count = sizeof( KFunctions ) / sl@0: sizeof( TStifFunctionInfo ); sl@0: sl@0: return RunInternalL( KFunctions, count, aItem ); sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::basic_string sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt Ctwiostreams::basicstring( CStifItemParser& aItem ) sl@0: { sl@0: int failures =0; sl@0: sl@0: try sl@0: { sl@0: sl@0: sl@0: const char *cstr1a = "Hello Out There."; sl@0: cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: basic_string str1a(cstr1a ,5); sl@0: sl@0: if(str1a.compare("Hello")!=0) sl@0: failures++; sl@0: sl@0: str1a.append("Out There"); sl@0: if(!str1a.compare("Hello Out There")) sl@0: failures++; sl@0: sl@0: sl@0: string str2a ( "How Do You Do?" ); sl@0: basic_string str2b ( str2a , 7 , 7 ); sl@0: sl@0: if(str2b.compare("You Do?")!=0) sl@0: failures++; sl@0: sl@0: sl@0: sl@0: basic_string str3a ( 5, '9' ); sl@0: if(str3a.compare("99999")!=0) sl@0: failures++; sl@0: sl@0: sl@0: sl@0: basic_string str4a; sl@0: string str4b; sl@0: basic_string str4c ( str4b.get_allocator( ) ); sl@0: if (!str4c.empty ()) sl@0: failures++; sl@0: sl@0: sl@0: sl@0: string str5a ( "Hello World"); sl@0: basic_string ::iterator strp_Iter; sl@0: sl@0: sl@0: sl@0: strp_Iter = str5a.begin(); sl@0: if(*strp_Iter != 'H' ) sl@0: failures++; sl@0: sl@0: sl@0: sl@0: sl@0: basic_string ::reference refStr2 = str5a.at ( 3 ); sl@0: sl@0: if(refStr2 != 'l') sl@0: failures++; sl@0: sl@0: sl@0: if(str5a.size()!=11) sl@0: failures++; sl@0: if(str5a.length()!=11) sl@0: failures++; sl@0: if(str5a.capacity()!=11) sl@0: failures++; sl@0: sl@0: sl@0: sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: /* if(failures) sl@0: return KErrGeneral; sl@0: return KErrNone; sl@0: */ sl@0: sl@0: } sl@0: sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::basic_filebuf sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: TInt Ctwiostreams::basicfilebufL( CStifItemParser& aItem ) sl@0: { sl@0: sl@0: int failures=0; sl@0: try sl@0: { sl@0: sl@0: sl@0: char* wszHello = "Hello World"; sl@0: // char wBuffer[128]; sl@0: cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: sl@0: basic_filebuf wOutFile; sl@0: sl@0: sl@0: // Open a file, wcHello.txt, then write to it, then dump the sl@0: // file's contents in hex sl@0: wOutFile.open("c:\\TestFramework\\docs\\basicfilebuf.txt",ios_base::out | ios_base::trunc | ios_base::binary); sl@0: if(!wOutFile.is_open()) sl@0: failures++; sl@0: sl@0: wOutFile.sputn(wszHello, 11); sl@0: wOutFile.close(); sl@0: if(wOutFile.is_open()) sl@0: failures++; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: /* if(failures) sl@0: return KErrGeneral; sl@0: else sl@0: return KErrNone; sl@0: sl@0: */ sl@0: sl@0: sl@0: sl@0: sl@0: } sl@0: sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::basic_istream sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: TInt Ctwiostreams::basicistreamL( CStifItemParser& aItem ) sl@0: { sl@0: sl@0: sl@0: int failures = 0; sl@0: try sl@0: { sl@0: cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: sl@0: sl@0: typedef std::basic_istream > Input; sl@0: typedef std::basic_ofstream Output; sl@0: sl@0: sl@0: // Input::char_type s [200]; sl@0: sl@0: Output out ("c:\\TestFramework\\docs\\basicistream.txt", std::ios::in | std::ios::out | std::ios::trunc); sl@0: sl@0: Input in (out.rdbuf ()); sl@0: sl@0: float f = 3.14159; sl@0: int i = 3; sl@0: sl@0: // output to the file sl@0: out << "He lifted his head and pondered.\n" sl@0: << f << std::endl << i << std::endl; sl@0: sl@0: // seek to the beginning of the file sl@0: in.seekg (0); sl@0: sl@0: if(!out.is_open()) sl@0: failures++; sl@0: sl@0: out.close(); sl@0: sl@0: if(out.is_open()) sl@0: failures++; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: /*if(failures) sl@0: return KErrGeneral; sl@0: else sl@0: return KErrNone; sl@0: sl@0: */ sl@0: sl@0: sl@0: } sl@0: sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::wfstream sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt Ctwiostreams::wfstreamL( CStifItemParser& aItem ) sl@0: sl@0: { sl@0: sl@0: int failures=0; sl@0: sl@0: try sl@0: { sl@0: cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: sl@0: wfstream file; sl@0: sl@0: sl@0: file.open("c:\\TestFramework\\docs\\wfstream.txt"); sl@0: file.rdbuf(); sl@0: if(!file.is_open()) sl@0: failures++; sl@0: sl@0: file.close(); sl@0: sl@0: if(file.is_open()) sl@0: failures++; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: /* if(failures) sl@0: return KErrGeneral; sl@0: return KErrNone; sl@0: sl@0: */ sl@0: sl@0: } sl@0: sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::wifstream sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt Ctwiostreams::wifstreamL( CStifItemParser& aItem ) sl@0: sl@0: { sl@0: int failures =0; sl@0: sl@0: try sl@0: { sl@0: cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: sl@0: wifstream file; sl@0: sl@0: sl@0: file.open("c:\\TestFramework\\docs\\wifstream.txt"); sl@0: sl@0: sl@0: file.rdbuf(); sl@0: if(!file.is_open()) sl@0: failures++; sl@0: sl@0: file.close(); sl@0: sl@0: if(file.is_open()) sl@0: failures++; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: /* if(failures) sl@0: return KErrGeneral; sl@0: return KErrNone; sl@0: sl@0: */ sl@0: sl@0: } sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::wfilebuf,wistream sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt Ctwiostreams::wistreamL( CStifItemParser& aItem ) sl@0: sl@0: { sl@0: int failures=0; sl@0: try sl@0: { sl@0: sl@0: sl@0: int length; sl@0: //wchar_t * buffer; sl@0: wchar_t getl[16] ; sl@0: sl@0: wfilebuf fb; sl@0: fb.open ("c:\\TestFramework\\docs\\wistream.txt",ios::in); sl@0: cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: wistream is(&fb); sl@0: sl@0: if(!fb.is_open()) sl@0: failures++; sl@0: sl@0: //if( char(is.get())!= 'S') sl@0: // failures++; sl@0: sl@0: //if(sizeof(fb)!=140) sl@0: //failures++; sl@0: sl@0: sl@0: sl@0: sl@0: // get length of file: sl@0: is.seekg (0, ios::end); sl@0: length = is.tellg(); sl@0: is.seekg (0, ios::beg); sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: if(length != 15) sl@0: failures++; sl@0: sl@0: wchar_t ch = is.get(); sl@0: sl@0: sl@0: if(is.gcount() != 1) sl@0: failures++; sl@0: sl@0: sl@0: if( ch != L'S') sl@0: failures++; sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: wchar_t pk1 = is.peek(); sl@0: sl@0: if(pk1!= 'a') sl@0: failures++; sl@0: sl@0: sl@0: is.unget(); sl@0: sl@0: wchar_t pk2 = is.peek(); sl@0: if(pk2!= 'S') sl@0: failures++; sl@0: sl@0: is.get(); sl@0: is.putback('K'); sl@0: sl@0: is.getline(getl,16,'\0'); sl@0: sl@0: if(getl == L"Kample sentence") sl@0: failures++; sl@0: sl@0: sl@0: sl@0: fb.close(); sl@0: sl@0: if(fb.is_open()) sl@0: failures++; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: /* sl@0: if(failures) sl@0: sl@0: return sizeof(fb); sl@0: return KErrNone; sl@0: sl@0: */ sl@0: sl@0: sl@0: sl@0: sl@0: } sl@0: sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::wofstream sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: TInt Ctwiostreams::wofstreamL( CStifItemParser& aItem ) sl@0: { sl@0: sl@0: int failures=0; sl@0: try sl@0: { sl@0: cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: sl@0: wofstream outfile; sl@0: sl@0: outfile.open("c:\\TestFramework\\docs\\wostream.txt"); sl@0: outfile.write(L"This is an ostreamfile",22); sl@0: sl@0: outfile.rdbuf(); sl@0: if(!outfile.is_open()) sl@0: failures++; sl@0: sl@0: outfile.close(); sl@0: sl@0: sl@0: if(outfile.is_open()) sl@0: failures++; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: /* if(failures) sl@0: return KErrGeneral; sl@0: else sl@0: return KErrNone; sl@0: sl@0: */ sl@0: sl@0: sl@0: } sl@0: sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::wistringstream sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt Ctwiostreams::wistringstreamL( CStifItemParser& aItem ) sl@0: { sl@0: int failures=0; sl@0: try sl@0: { sl@0: sl@0: sl@0: int output[5]; sl@0: int n = 0,val = 0; sl@0: wstring strvalues ; sl@0: sl@0: strvalues = L"1 2 3 4 5"; sl@0: cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: wistringstream iss(strvalues,wistringstream::in); sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: sl@0: for(n=0;n<5;n++) sl@0: { sl@0: sl@0: static int j; sl@0: sl@0: iss>>val; sl@0: sl@0: output[j]=val; sl@0: sl@0: j++; sl@0: sl@0: sl@0: } sl@0: sl@0: if(iss.str()!=L"1 2 3 4 5") sl@0: failures++; sl@0: /* sl@0: if(output[0]== 1) sl@0: if(output[1]== 2) sl@0: if(output[2]== 3) sl@0: if(output[3]== 4 ) sl@0: if(output[4]== 5) sl@0: sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: */ sl@0: sl@0: if(output[0]!= 1) sl@0: failures++; sl@0: if(output[1]!= 2) sl@0: failures++; sl@0: if(output[2]!= 3) sl@0: failures++; sl@0: if(output[3]!= 4 ) sl@0: failures++; sl@0: if(output[4]!= 5) sl@0: failures++; sl@0: } sl@0: sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::wostringstream,wstring sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt Ctwiostreams::wostringstreamL( CStifItemParser& aItem ) sl@0: { sl@0: int failures=0; sl@0: try sl@0: { cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: sl@0: sl@0: wostringstream oss; sl@0: wstring mystr; sl@0: sl@0: oss << L"wostringstream testcase"; sl@0: oss.rdbuf(); sl@0: mystr=oss.str(); sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: /*if(mystr.compare(L"wostringstream testcase")==0) sl@0: return KErrNone; sl@0: return KErrGeneral; sl@0: */ sl@0: if(mystr.compare(L"wostringstream testcase")!=0) sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::wstreambuf,wofstreams sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: TInt Ctwiostreams::wstreambufL( CStifItemParser& aItem ) sl@0: { sl@0: sl@0: sl@0: //locale loc ("en_GB.UTF-8"); sl@0: sl@0: sl@0: sl@0: int failures = 0; sl@0: try sl@0: { sl@0: sl@0: sl@0: wchar_t a[4]= sl@0: { sl@0: 0 sl@0: }; sl@0: sl@0: wchar_t sentence[]= L"Sample sentence"; cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: wstreambuf * pbuf; sl@0: wofstream ostr ("c:\\TestFramework\\docs\\wstreambuf.txt"); sl@0: sl@0: sl@0: sl@0: // if(cout.rdbuf( )->getloc( ).name( ).c_str( ) != "C") //failing sl@0: //failures++; sl@0: sl@0: wchar_t ch[28]; sl@0: //rdbuf()s sl@0: pbuf = ostr.rdbuf(); sl@0: sl@0: sl@0: //sputn() sl@0: sl@0: sl@0: sl@0: sl@0: pbuf->sputn (sentence,sizeof(sentence)-1); sl@0: sl@0: sl@0: ostr.open("c:\\TestFramework\\docs\\wstreambuf.txt"); sl@0: sl@0: if(!ostr.is_open()) sl@0: failures++; sl@0: sl@0: sl@0: long size1 = pbuf->pubseekoff(0,ios_base::end); sl@0: if(size1!=31) sl@0: failures++; sl@0: sl@0: sl@0: pbuf->sputc('a'); sl@0: sl@0: sl@0: long size2 = pbuf->pubseekoff(0,ios_base::end); sl@0: if(size2!=32) sl@0: failures++; sl@0: sl@0: wifstream istr("c:\\TestFramework\\docs\\wstreambuf.txt"); sl@0: pbuf = istr.rdbuf(); sl@0: sl@0: streamsize i = istr.rdbuf()->sgetn(&a[0], 3); sl@0: //a[i] = istr.widen('\0'); sl@0: sl@0: // Display the size and contents of the buffer passed to sgetn. sl@0: if(i!=3) sl@0: failures++; sl@0: sl@0: sl@0: int k = pbuf->snextc(); sl@0: sl@0: sl@0: //sgetc() sl@0: while (pbuf->sgetc()!=EOF) sl@0: { sl@0: static int i; sl@0: //sbumpc() sl@0: ch[i] = pbuf->sbumpc(); sl@0: i++; sl@0: } sl@0: sl@0: sl@0: if(ch[0]!='l' ) sl@0: failures++; sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: istr.close(); sl@0: ostr.close(); sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: /* if(failures) sl@0: return KErrGeneral; sl@0: else sl@0: return KErrNone; sl@0: */ sl@0: sl@0: sl@0: sl@0: } sl@0: sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::wostream sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: TInt Ctwiostreams::wostreamL( CStifItemParser& aItem ) sl@0: { sl@0: sl@0: sl@0: sl@0: int failures = 0; sl@0: try sl@0: { sl@0: sl@0: sl@0: wfilebuf fb; sl@0: wchar_t input[18] = L"wostream testcase"; sl@0: streamsize size = 5; sl@0: fb.open ("c:\\TestFramework\\docs\\wostream.txt",ios::out); cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: wostream os(&fb); sl@0: sl@0: os.write(input,size); sl@0: streamoff i = os.tellp(); sl@0: if(i!= 5) sl@0: failures++; sl@0: sl@0: os.put('K'); sl@0: streamoff j = os.tellp(); sl@0: if(j!=6) sl@0: failures++; sl@0: sl@0: os.seekp(2); sl@0: os<<"i"; sl@0: streamoff k = os.tellp(); sl@0: sl@0: if(k!=3) sl@0: failures++; sl@0: sl@0: os.flush(); sl@0: sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: if(failures) sl@0: return KErrGeneral; sl@0: return KErrNone; sl@0: */ sl@0: sl@0: sl@0: } sl@0: sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // Ctwiostreams::wstringbuf sl@0: // Example test method function. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: TInt Ctwiostreams::wstringbufL( CStifItemParser& aItem ) sl@0: { sl@0: int failures=0; sl@0: try sl@0: { sl@0: cout<<""; sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1); sl@0: #endif sl@0: wstringbuf sb; sl@0: wstring mystr; sl@0: sl@0: sl@0: sb.sputn (L"Sample string",13); sl@0: mystr=sb.str(); sl@0: sl@0: /*if(mystr.compare(L"Sample string") == 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: */ sl@0: #if STDCPP_OOM sl@0: User::__DbgSetAllocFail(FALSE,RHeap::ENone,1); sl@0: #endif sl@0: if(mystr.compare(L"Sample string") != 0) sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: catch(bad_alloc&) sl@0: { sl@0: //do nothing sl@0: } sl@0: catch(...) sl@0: { sl@0: failures++; sl@0: sl@0: } sl@0: sl@0: if( failures == 0 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: // End of File sl@0: sl@0: // End of File