os/ossrv/stdcpp/tsrc/Stdcpp_test/bcdrivers/tiostreams/src/tiostreamsblocks.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/stdcpp/tsrc/Stdcpp_test/bcdrivers/tiostreams/src/tiostreamsblocks.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1660 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +
    1.24 +// INCLUDE FILES
    1.25 +#include <e32svr.h>
    1.26 +#include <StifParser.h>
    1.27 +#include <Stiftestinterface.h>
    1.28 +#include<iostream>
    1.29 +#include<fstream>
    1.30 +#include<string>
    1.31 +#include<ostream>
    1.32 +#include <sstream>
    1.33 +#include<strstream>
    1.34 +#include<deque>
    1.35 +#include<iterator>
    1.36 +#include<vector>
    1.37 +#include <ios>
    1.38 +#include <iostream>
    1.39 +#include <fstream>
    1.40 +#include <stl/char_traits.h>
    1.41 +#include <new>
    1.42 + #include<e32std.h>
    1.43 +
    1.44 +#include<exception>
    1.45 +
    1.46 +#include "tiostreams.h"
    1.47 +using namespace std;
    1.48 + #define STDCPP_OOM FALSE// TRUE for OOM testing
    1.49 + 
    1.50 +
    1.51 +// ============================ MEMBER FUNCTIONS ===============================
    1.52 +
    1.53 +// -----------------------------------------------------------------------------
    1.54 +// Ctiostreams::Delete
    1.55 +// Delete here all resources allocated and opened from test methods. 
    1.56 +// Called from destructor. 
    1.57 +// -----------------------------------------------------------------------------
    1.58 +//
    1.59 +void Ctiostreams::Delete() 
    1.60 +    {
    1.61 +
    1.62 +    }
    1.63 +
    1.64 +// -----------------------------------------------------------------------------
    1.65 +// Ctiostreams::RunMethodL
    1.66 +// Run specified method. Contains also table of test mothods and their names.
    1.67 +// -----------------------------------------------------------------------------
    1.68 +//
    1.69 +TInt Ctiostreams::RunMethodL( 
    1.70 +    CStifItemParser& aItem ) 
    1.71 +    {
    1.72 +
    1.73 +    static TStifFunctionInfo const KFunctions[] =
    1.74 +        {  
    1.75 +        // Copy this line for every implemented function.
    1.76 +        // First string is the function name used in TestScripter script file.
    1.77 +        // Second is the actual implementation member function. 
    1.78 +              // Second is the actual implementation member function. 
    1.79 + ENTRY( "iofstreamL", Ctiostreams::iofstreamL ),
    1.80 + ENTRY( "stringbufL", Ctiostreams::stringbufL ),
    1.81 + ENTRY( "stringstreamL", Ctiostreams::stringstreamL ),
    1.82 + ENTRY( "streambufL", Ctiostreams:: streambufL ),
    1.83 + ENTRY( "ostreamL", Ctiostreams:: ostreamL ),
    1.84 + ENTRY( "istreamL", Ctiostreams:: istreamL ),
    1.85 + ENTRY( "istringstreamL", Ctiostreams:: istringstreamL ),
    1.86 + ENTRY( "ostringstreamL", Ctiostreams:: ostringstreamL ),
    1.87 + ENTRY( "ostreamiterators", Ctiostreams::ostreamiterators ),
    1.88 + ENTRY( "fstreamL", Ctiostreams::fstreamL),
    1.89 + ENTRY( "istrstreamL", Ctiostreams::istrstreamL),
    1.90 + ENTRY( "strstreamL", Ctiostreams::strstreamL),
    1.91 + ENTRY( "ostrstreamL", Ctiostreams::ostrstreamL),
    1.92 + ENTRY( "istreamiterators", Ctiostreams::istreamiterators ),
    1.93 + ENTRY( "istreambufiterators", Ctiostreams::istreambufiterators ),
    1.94 + ENTRY( "strstreambufL", Ctiostreams::strstreambufL ),
    1.95 + ENTRY( "freezeL", Ctiostreams::freezeL ),
    1.96 + ENTRY( "fposL", Ctiostreams::fposL ),
    1.97 +  ENTRY( "filebufL", Ctiostreams::filebufL ),
    1.98 +  ENTRY( "seekpL", Ctiostreams::seekpL ),
    1.99 +
   1.100 +
   1.101 +        };
   1.102 +
   1.103 +    const TInt count = sizeof( KFunctions ) / 
   1.104 +                        sizeof( TStifFunctionInfo );
   1.105 +
   1.106 +    return RunInternalL( KFunctions, count, aItem );
   1.107 +
   1.108 +    }
   1.109 +
   1.110 +
   1.111 +// -----------------------------------------------------------------------------
   1.112 +// Ctiostreams:: ofstream,ifstream
   1.113 +// Example test method function.
   1.114 +// (other items were commented in a header).
   1.115 +// -----------------------------------------------------------------------------
   1.116 +//
   1.117 +
   1.118 +
   1.119 +TInt Ctiostreams::iofstreamL( CStifItemParser& aItem )
   1.120 +    {
   1.121 + 
   1.122 + 
   1.123 +//__UHEAP_MARK;
   1.124 +int failures=0 ;
   1.125 +try
   1.126 +{
   1.127 +cout<<"";	
   1.128 +#if  STDCPP_OOM
   1.129 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.130 +  #endif 
   1.131 +    ofstream myfile;
   1.132 +    filebuf *fbuf;
   1.133 +    char * buffer;
   1.134 +  long size;
   1.135 +    //ifstream 
   1.136 +  myfile.open ("c:\\TestFramework\\docs\\example.txt");
   1.137 +  if(!myfile.is_open())
   1.138 +  failures++;
   1.139 + 
   1.140 +  myfile << "Writing this to a file.";
   1.141 +  myfile<<"\0";
   1.142 +   myfile.close();
   1.143 +  if(myfile.is_open())
   1.144 +  failures++;
   1.145 +  
   1.146 +  
   1.147 +  
   1.148 +  
   1.149 + // string line;
   1.150 +   ifstream myfile1; 
   1.151 + 
   1.152 + 
   1.153 + myfile1.open("c:\\TestFramework\\docs\\example.txt" );
   1.154 +
   1.155 +fbuf=myfile1.rdbuf();
   1.156 +
   1.157 + 
   1.158 + // get file size using buffer's members
   1.159 +  size=fbuf->pubseekoff (0,ios::end,ios::in);
   1.160 +  fbuf->pubseekpos (0,ios::in);
   1.161 +
   1.162 +  // allocate memory to contain file data
   1.163 +  buffer=new char[size];
   1.164 +
   1.165 +  // get file data  
   1.166 +  fbuf->sgetn (buffer,size);
   1.167 +  
   1.168 +#if  STDCPP_OOM
   1.169 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.170 +  #endif 
   1.171 +  
   1.172 +  
   1.173 +  if(buffer != "Writing this to a file.");
   1.174 +  else
   1.175 +  failures++;
   1.176 +  
   1.177 +  if(size!= 23)
   1.178 +  failures++;
   1.179 +  
   1.180 +
   1.181 +if(!myfile1.is_open())
   1.182 +failures++;
   1.183 +myfile1.close();
   1.184 +if(myfile1.is_open())
   1.185 +failures++;
   1.186 +  
   1.187 +   delete buffer;
   1.188 +ios_base::Init();  // 0 -   218 FUNCTION Init()  iostream.cpp
   1.189 +filebuf*  _Stl_create_filebuf(FILE* f, ios_base::openmode mode );  // 0 -   225 FUNCTION _Stl_create_filebuf() iostream.cpp
   1.190 +ios_base::sync_with_stdio();//0 -   445 FUNCTION ios_base::sync_with_stdio()
   1.191 +/* 
   1.192 + if(failures)
   1.193 + 
   1.194 +  return KErrGeneral;
   1.195 + return KErrNone;
   1.196 +
   1.197 +*/
   1.198 +
   1.199 + 
   1.200 +  //#if STDCPP_OOM
   1.201 +//failures++;
   1.202 +// #endif
   1.203 +
   1.204 +    }
   1.205 + 
   1.206 + catch(bad_alloc&)
   1.207 +   {
   1.208 +   	//do nothing
   1.209 +    }
   1.210 +   catch(...)
   1.211 +   {
   1.212 +   	failures++;
   1.213 +   	
   1.214 +   }
   1.215 +   
   1.216 +	if( failures == 0 )
   1.217 +		return KErrNone;
   1.218 +  else  
   1.219 +		return KErrGeneral;
   1.220 +		  
   1.221 +    }
   1.222 +
   1.223 + 
   1.224 + 
   1.225 +// -----------------------------------------------------------------------------
   1.226 +// Ctiostreams:: stringbuf
   1.227 +// Example test method function.
   1.228 +// (other items were commented in a header).
   1.229 +// -----------------------------------------------------------------------------
   1.230 +//
   1.231 + 
   1.232 + TInt Ctiostreams::stringbufL(CStifItemParser& aItem )
   1.233 + {
   1.234 + 
   1.235 + 	int failures = 0;
   1.236 + 	try
   1.237 + 	{
   1.238 + cout<<"";		
   1.239 + #if  STDCPP_OOM
   1.240 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.241 +  #endif 	
   1.242 +stringbuf sb;
   1.243 +  string mystr;
   1.244 +
   1.245 +  sb.sputn("Sample string",13);
   1.246 +  mystr=sb.str();
   1.247 +
   1.248 +    
   1.249 +   
   1.250 +   if(sb.in_avail()!=13)
   1.251 +  failures++;
   1.252 +   
   1.253 +   
   1.254 +    char ch = sb.sgetc();
   1.255 +   if(ch!= 'S')
   1.256 +   failures++;
   1.257 +   
   1.258 +   
   1.259 +  
   1.260 +  
   1.261 +  
   1.262 +  
   1.263 +   if(mystr.compare("Sample string") != 0)
   1.264 +   failures++;
   1.265 +  
   1.266 +  #if  STDCPP_OOM
   1.267 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.268 +  #endif 
   1.269 +  /* if(failures)
   1.270 +    
   1.271 +  return KErrGeneral;
   1.272 +  else
   1.273 +  return KErrNone;
   1.274 + */
   1.275 + 
   1.276 + 
   1.277 +   //#if STDCPP_OOM
   1.278 +//failures++;
   1.279 +// #endif
   1.280 + 
   1.281 + }
   1.282 + 
   1.283 + catch(bad_alloc&)
   1.284 +   {
   1.285 +   	//do nothing
   1.286 +    }
   1.287 +   catch(...)
   1.288 +   {
   1.289 +   	failures++;
   1.290 +   	
   1.291 +   }
   1.292 +   
   1.293 +	if( failures == 0 )
   1.294 +		return KErrNone;
   1.295 +  else  
   1.296 +		return KErrGeneral;
   1.297 +    }
   1.298 +// -----------------------------------------------------------------------------
   1.299 +// Ctiostreams:: stringstream
   1.300 +// Example test method function.
   1.301 +// (other items were commented in a header).
   1.302 +// -----------------------------------------------------------------------------
   1.303 +//
   1.304 + 
   1.305 + 
   1.306 + TInt Ctiostreams::stringstreamL(CStifItemParser& aItem )
   1.307 + {
   1.308 + 	
   1.309 + 	int val;
   1.310 +  string  teststr;
   1.311 +  int failures = 0;
   1.312 +  try
   1.313 +  {
   1.314 +  cout<<"";	
   1.315 +  #if  STDCPP_OOM
   1.316 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.317 +  #endif 
   1.318 +   stringstream ss (stringstream::in | stringstream::out);
   1.319 +   stringstream teststring;
   1.320 +   
   1.321 +    
   1.322 +   teststring<<"stringstream testcase";
   1.323 +   
   1.324 +   teststr = teststring.str();
   1.325 +   
   1.326 +   if(!teststr.compare("stringstream testcase"))
   1.327 +   ;
   1.328 +   else
   1.329 +   failures++;
   1.330 +
   1.331 + ss << "120 42 377 6 5 2000";
   1.332 +#if  STDCPP_OOM
   1.333 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.334 +  #endif 
   1.335 + for (int n=0; n<6; n++)
   1.336 +  {
   1.337 +    ss >> val;
   1.338 +    
   1.339 +    switch(n)
   1.340 +    {
   1.341 +    	case 0://precision 
   1.342 +    	if(val!=120)
   1.343 +    	failures++;
   1.344 +    	break;
   1.345 +    	case 1:
   1.346 +    	if(val!=42)
   1.347 +    	failures++;
   1.348 +    	break;
   1.349 +    	case 2:
   1.350 +    	if(val!=377)
   1.351 +    	failures++;
   1.352 +    	break;
   1.353 +    	case 3:
   1.354 +    	if(val!=6)
   1.355 +    	failures++;
   1.356 +    	break;
   1.357 +    	
   1.358 +    	case 4:
   1.359 +    	if(val!=5)
   1.360 +    	failures++;
   1.361 +    	break;
   1.362 +       
   1.363 +    	case 5:
   1.364 +    	if(val!=2000)
   1.365 +    	failures++;
   1.366 +    	break;
   1.367 +    
   1.368 +    default:
   1.369 +    break;
   1.370 +    }
   1.371 +    
   1.372 +   
   1.373 +  }
   1.374 +
   1.375 + /* if(failures)
   1.376 +   return KErrGeneral;
   1.377 +  return KErrNone;
   1.378 + */
   1.379 + 
   1.380 + 
   1.381 +  
   1.382 +  //#if STDCPP_OOM
   1.383 +//failures++;
   1.384 +// #endif
   1.385 + }
   1.386 +
   1.387 +catch(bad_alloc&)
   1.388 +   {
   1.389 +   	//do nothing
   1.390 +    }
   1.391 +   catch(...)
   1.392 +   {
   1.393 +   	failures++;
   1.394 +   	
   1.395 +   }
   1.396 +   
   1.397 +	if( failures == 0 )
   1.398 +		return KErrNone;
   1.399 +  else  
   1.400 +		return KErrGeneral;
   1.401 +    }
   1.402 +
   1.403 +// -----------------------------------------------------------------------------
   1.404 +// Ctiostreams:: streambuf
   1.405 +// Example test method function.
   1.406 +// (other items were commented in a header).
   1.407 +// -----------------------------------------------------------------------------
   1.408 +//
   1.409 +
   1.410 + TInt Ctiostreams::streambufL(CStifItemParser& aItem )
   1.411 + {
   1.412 +//    locale   loc ("en_GB.UTF-8");
   1.413 +
   1.414 + 
   1.415 + 
   1.416 + int failures = 0;
   1.417 + try
   1.418 + {
   1.419 + 	
   1.420 + 
   1.421 + char a[4]=
   1.422 + {
   1.423 + 	0
   1.424 + };
   1.425 + 
   1.426 + char sentence[]= "Sample sentence";
   1.427 + cout<<"";
   1.428 + #if  STDCPP_OOM
   1.429 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.430 +  #endif 
   1.431 + streambuf * pbuf;
   1.432 + ofstream ostr ("c:\\TestFramework\\docs\\streambuf.txt");
   1.433 + 
   1.434 + 
   1.435 +  
   1.436 + if(!cout.rdbuf( )->getloc( ).name( ).c_str( ))    //failing
   1.437 +// failures++;
   1.438 + ;
   1.439 + char ch[14];
   1.440 + //rdbuf()s
   1.441 + pbuf = ostr.rdbuf();
   1.442 +
   1.443 +
   1.444 +//sputn()
   1.445 +
   1.446 +
   1.447 +
   1.448 +
   1.449 + pbuf->sputn (sentence,sizeof(sentence)-1);
   1.450 +
   1.451 +  
   1.452 + ostr.open("c:\\TestFramework\\docs\\streambuf.txt");
   1.453 +  
   1.454 + if(!ostr.is_open())
   1.455 + failures++;
   1.456 +   
   1.457 +
   1.458 + long size1 = pbuf->pubseekoff(0,ios_base::end);
   1.459 + if(size1!=15)
   1.460 + failures++;
   1.461 +  
   1.462 +
   1.463 +  pbuf->sputc('a');
   1.464 +  
   1.465 +
   1.466 + long size2 = pbuf->pubseekoff(0,ios_base::end);
   1.467 + if(size2!=16)
   1.468 + failures++;
   1.469 +  
   1.470 + ifstream istr("c:\\TestFramework\\docs\\streambuf.txt");
   1.471 + pbuf = istr.rdbuf();
   1.472 +
   1.473 +streamsize i = istr.rdbuf()->sgetn(&a[0], 3);   
   1.474 + 
   1.475 +    // Display the size and contents of the buffer passed to sgetn.
   1.476 +   if(i!=3)
   1.477 +   failures++;
   1.478 +  
   1.479 + 
   1.480 + int k = pbuf->snextc();
   1.481 + 
   1.482 + 
   1.483 + //sgetc()
   1.484 + while (pbuf->sgetc()!=EOF)
   1.485 +  {
   1.486 +    // static int i;
   1.487 +    int  i=0;
   1.488 +      //sbumpc()
   1.489 +     ch[i] = pbuf->sbumpc();
   1.490 +     i++;
   1.491 +  }
   1.492 +
   1.493 +  
   1.494 +  if(ch[0]!='a' )
   1.495 +  failures++;
   1.496 +  
   1.497 + 
   1.498 +  
   1.499 +  
   1.500 +  
   1.501 +  
   1.502 +  istr.close();
   1.503 +  #if  STDCPP_OOM
   1.504 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.505 +  #endif 
   1.506 +  /*
   1.507 +  if(failures)
   1.508 +  return KErrGeneral;
   1.509 +  else
   1.510 +  return KErrNone;
   1.511 +   
   1.512 +   */
   1.513 +
   1.514 +  
   1.515 +  //#if STDCPP_OOM
   1.516 +//failures++;
   1.517 +// #endif
   1.518 + 
   1.519 + }
   1.520 + catch(bad_alloc&)
   1.521 +   {
   1.522 +   	//do nothing
   1.523 +    }
   1.524 +   catch(...)
   1.525 +   {
   1.526 +   	failures++;
   1.527 +   	
   1.528 +   }
   1.529 +   
   1.530 +	if( failures == 0 )
   1.531 +		return KErrNone;
   1.532 +  else  
   1.533 +		return KErrGeneral;
   1.534 +    }
   1.535 + 
   1.536 + 
   1.537 +// -----------------------------------------------------------------------------
   1.538 +// Ctiostreams:: ostream
   1.539 +// Example test method function.
   1.540 +// (other items were commented in a header).
   1.541 +// -----------------------------------------------------------------------------
   1.542 +//
   1.543 + 
   1.544 + TInt Ctiostreams::ostreamL(CStifItemParser& aItem )
   1.545 + 
   1.546 + {
   1.547 + 
   1.548 +  
   1.549 + int failures = 0;
   1.550 + try
   1.551 + {
   1.552 + 	
   1.553 + 
   1.554 + filebuf fb;
   1.555 +char input[17] = "ostream testcase";
   1.556 +streamsize size = 5;
   1.557 +  fb.open ("c:\\TestFramework\\docs\\ostream.txt",ios::out);
   1.558 +  cout<<"";
   1.559 +  #if  STDCPP_OOM
   1.560 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.561 +  #endif 
   1.562 +  ostream os(&fb);
   1.563 +  
   1.564 +  os.write(input,size);
   1.565 +  streamoff i = os.tellp();
   1.566 +  if(i!= 5)
   1.567 +  failures++;
   1.568 +  
   1.569 +  os.put('K');
   1.570 +  streamoff j = os.tellp();
   1.571 +  if(j!=6)
   1.572 +  failures++;
   1.573 +
   1.574 +  os.seekp(2);
   1.575 +    os<<"i";
   1.576 +  streamoff k = os.tellp();
   1.577 +
   1.578 +  if(k!=3)
   1.579 +  failures++;
   1.580 +  
   1.581 + os.flush();
   1.582 +  
   1.583 +   #if  STDCPP_OOM
   1.584 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.585 +  #endif 
   1.586 +  
   1.587 +   
   1.588 +  /*
   1.589 +  if(failures)
   1.590 +  return KErrGeneral;
   1.591 +  return KErrNone;
   1.592 +  */
   1.593 + 
   1.594 +  
   1.595 +   //#if STDCPP_OOM
   1.596 +//failures++;
   1.597 +// #endif
   1.598 + }
   1.599 + 
   1.600 + catch(bad_alloc&)
   1.601 +   {
   1.602 +   	//do nothing
   1.603 +    }
   1.604 +   catch(...)
   1.605 +   {
   1.606 +   	failures++;
   1.607 +   	
   1.608 +   }
   1.609 +   
   1.610 +	if( failures == 0 )
   1.611 +		return KErrNone;
   1.612 +  else  
   1.613 +		return KErrGeneral;
   1.614 +    }
   1.615 + 
   1.616 +// -----------------------------------------------------------------------------
   1.617 +// Ctiostreams:: istream
   1.618 +// Example test method function.
   1.619 +// (other items were commented in a header).
   1.620 +// -----------------------------------------------------------------------------
   1.621 +//
   1.622 +  TInt Ctiostreams::istreamL(CStifItemParser& aItem )
   1.623 +  {
   1.624 + 
   1.625 +int failures =0;
   1.626 +try
   1.627 +{
   1.628 +	
   1.629 +
   1.630 +int length;
   1.631 +//char * buffer;
   1.632 +char getl[8] ;
   1.633 + filebuf fb;
   1.634 + fb.open ("c:\\TestFramework\\docs\\istream.txt",ios::in);
   1.635 + cout<<"";
   1.636 + #if  STDCPP_OOM
   1.637 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.638 +  #endif 
   1.639 + istream is(&fb);
   1.640 + 
   1.641 + //needs to rewrite
   1.642 +
   1.643 +
   1.644 +  // get length of file:
   1.645 +  is.seekg (0, ios::end);
   1.646 +  length = is.tellg();
   1.647 +  is.seekg (0, ios::beg);
   1.648 +  
   1.649 +  
   1.650 +  
   1.651 +
   1.652 +
   1.653 +if(length != 7)
   1.654 +failures++;
   1.655 +
   1.656 + char ch = is.get();
   1.657 +  
   1.658 +   
   1.659 + if(is.gcount() != 1)
   1.660 + failures++;
   1.661 + 
   1.662 +  
   1.663 + if( ch != 'S')
   1.664 + failures++;
   1.665 + 
   1.666 + 
   1.667 +
   1.668 + 
   1.669 + 
   1.670 + 
   1.671 + 
   1.672 + char pk1 = is.peek();
   1.673 + 
   1.674 + if(pk1!= 'h')
   1.675 + failures++;
   1.676 + 
   1.677 + 
   1.678 + is.unget();
   1.679 + 
   1.680 + char pk2 = is.peek();
   1.681 + if(pk2!= 'S')
   1.682 + failures++;
   1.683 + 
   1.684 + is.get();
   1.685 + is.putback('K');
   1.686 + 
   1.687 + is.getline(getl,8,'\0');
   1.688 + 
   1.689 + if(getl == "Khaheen")
   1.690 + failures++;
   1.691 + 
   1.692 + if(is.gcount() != 7)
   1.693 + failures++;
   1.694 + 
   1.695 + 
   1.696 +  fb.close();
   1.697 +  /*if(failures)
   1.698 + 
   1.699 + 
   1.700 +  return KErrGeneral;
   1.701 +  return KErrNone;
   1.702 +  
   1.703 + */
   1.704 +   
   1.705 +   #if  STDCPP_OOM
   1.706 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.707 +  #endif 
   1.708 +   //#if STDCPP_OOM
   1.709 +//failures++;
   1.710 +// #endif
   1.711 +	  
   1.712 +  }
   1.713 +  
   1.714 +  catch(bad_alloc&)
   1.715 +   {
   1.716 +   	//do nothing
   1.717 +    }
   1.718 +   catch(...)
   1.719 +   {
   1.720 +   	failures++;
   1.721 +   	
   1.722 +   }
   1.723 +   
   1.724 +	if( failures == 0 )
   1.725 +		return KErrNone;
   1.726 +  else  
   1.727 +		return KErrGeneral;
   1.728 +    }
   1.729 +
   1.730 +// -----------------------------------------------------------------------------
   1.731 +// Ctiostreams:: istringstream
   1.732 +// Example test method function.
   1.733 +// (other items were commented in a header).
   1.734 +// -----------------------------------------------------------------------------
   1.735 +//  
   1.736 +  
   1.737 +   TInt Ctiostreams::istringstreamL(CStifItemParser& aItem )
   1.738 +   {
   1.739 +   	int n,val;
   1.740 + 	int failures =0;
   1.741 + 	try
   1.742 + 	{
   1.743 + 	string strvalues = "125 320 512 750 333";
   1.744 + 	cout<<"";	
   1.745 + 	#if  STDCPP_OOM
   1.746 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.747 +  #endif 
   1.748 +	
   1.749 +  	istringstream iss (strvalues,istringstream::in);
   1.750 +
   1.751 +if(iss.str()  != "125 320 512 750 333")
   1.752 +failures++;
   1.753 +
   1.754 +#if  STDCPP_OOM
   1.755 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.756 +  #endif 
   1.757 +  for (n=0; n<5; n++)
   1.758 +  {
   1.759 +    iss >> val;
   1.760 +     switch(n)
   1.761 +    {
   1.762 +    	case 0:
   1.763 +    	if(val!=125)
   1.764 +    	failures++;
   1.765 +    	break;
   1.766 +    	case 1:
   1.767 +    	if(val!=320)
   1.768 +    	failures++;
   1.769 +    	break;
   1.770 +    	case 2:
   1.771 +    	if(val!=512)
   1.772 +    	failures++;
   1.773 +    	break;
   1.774 +    	case 3:
   1.775 +    	if(val!=750)
   1.776 +    	failures++;
   1.777 +    	break;
   1.778 +    	
   1.779 +    	case 4:
   1.780 +    	if(val!=333)
   1.781 +    	failures++;
   1.782 +    	break;
   1.783 +       
   1.784 +    	    
   1.785 +    default:
   1.786 +    break;
   1.787 +    }
   1.788 +    
   1.789 +  }
   1.790 +  
   1.791 +   
   1.792 +   //#if STDCPP_OOM
   1.793 +//failures++;
   1.794 +// #endif
   1.795 +
   1.796 +/* if(failures)
   1.797 + return KErrGeneral;
   1.798 + else
   1.799 + return KErrNone;*/
   1.800 +   }
   1.801 +   
   1.802 +   catch(bad_alloc&)
   1.803 +   {
   1.804 +   	//do nothing
   1.805 +    }
   1.806 +   catch(...)
   1.807 +   {
   1.808 +   	failures++;
   1.809 +   	
   1.810 +   }
   1.811 +   
   1.812 +	if( failures == 0 )
   1.813 +		return KErrNone;
   1.814 +  else  
   1.815 +		return KErrGeneral;
   1.816 +    }
   1.817 +   
   1.818 +   
   1.819 +   
   1.820 +   
   1.821 +   
   1.822 +   
   1.823 +// -----------------------------------------------------------------------------
   1.824 +// Ctiostreams:: ostringstream,
   1.825 +// Example test method function.
   1.826 +// (other items were commented in a header).
   1.827 +// -----------------------------------------------------------------------------
   1.828 +//
   1.829 +   
   1.830 +   TInt Ctiostreams::ostringstreamL(CStifItemParser& aItem )
   1.831 +   {
   1.832 + 	int failures =0 ;
   1.833 + 	try
   1.834 + 	{
   1.835 + 		
   1.836 + 	
   1.837 + 	basic_string<char> i( "test" );
   1.838 + 	cout<<"";
   1.839 + 	#if  STDCPP_OOM
   1.840 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.841 +  #endif 
   1.842 +   ostringstream ss;
   1.843 +   
   1.844 +   ss.rdbuf( )->str( i );
   1.845 +   if(ss.str( ).compare("test") != 0)
   1.846 +   failures++; 
   1.847 +
   1.848 +   ss << "z";
   1.849 +   if(ss.str( ) .compare("zest")!=0)
   1.850 +   failures++;
   1.851 +      
   1.852 +   ss.rdbuf( )->str( "be" );
   1.853 +   if(ss.str( ).compare("be")!=0)
   1.854 +   failures++;
   1.855 +   
   1.856 +   #if  STDCPP_OOM
   1.857 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.858 +  #endif 
   1.859 +   /*
   1.860 +   if(failures)
   1.861 +   
   1.862 +	return KErrGeneral;
   1.863 +	else
   1.864 +	return KErrNone;
   1.865 +*/
   1.866 +
   1.867 +
   1.868 + 
   1.869 +   //#if STDCPP_OOM
   1.870 +//failures++;
   1.871 +// #endif
   1.872 +   }
   1.873 +   
   1.874 +   catch(bad_alloc&)
   1.875 +   {
   1.876 +   	//do nothing
   1.877 +    }
   1.878 +   catch(...)
   1.879 +   {
   1.880 +   	failures++;
   1.881 +   	
   1.882 +   }
   1.883 +   
   1.884 +	if( failures == 0 )
   1.885 +		return KErrNone;
   1.886 +  else  
   1.887 +		return KErrGeneral;
   1.888 +    }
   1.889 +   
   1.890 +    TInt Ctiostreams::ostreamiterators(CStifItemParser& aItem )
   1.891 +    {
   1.892 +    	
   1.893 +    
   1.894 +  //needs to rewrite
   1.895 +  //____________________
   1.896 +   
   1.897 +   int arr[4] = { 3,4,7,8 };
   1.898 +//   int total=0;
   1.899 +   deque<int> d(arr+0, arr+4);
   1.900 +   //
   1.901 +   // stream the whole vector and a sum to cout
   1.902 +   //
   1.903 +  
   1.904 +   copy(d.begin(),(d.end()-1),ostream_iterator<int,char>(cout,""));
   1.905 +  
   1.906 +  
   1.907 +  if( *(d.end()-1) == 8)
   1.908 +  return KErrNone;
   1.909 +  return KErrGeneral;
   1.910 +
   1.911 +
   1.912 + }
   1.913 +
   1.914 +    
   1.915 +    
   1.916 +// -----------------------------------------------------------------------------
   1.917 +// Ctiostreams:: fstream
   1.918 +// Example test method function.
   1.919 +// (other items were commented in a header).
   1.920 +// -----------------------------------------------------------------------------
   1.921 +//
   1.922 +    
   1.923 +    
   1.924 +    TInt Ctiostreams::fstreamL(CStifItemParser& aItem ) 
   1.925 +    {
   1.926 +   //  __UHEAP_MARK;
   1.927 +int failures =0;
   1.928 +try
   1.929 +{
   1.930 +cout<<"";	
   1.931 +#if  STDCPP_OOM
   1.932 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.933 +  #endif 
   1.934 +fstream filestr ("c:\\TestFramework\\docs\\fstream.txt", fstream::in | fstream::out);
   1.935 +
   1.936 +if(!filestr.is_open())
   1.937 +failures++;
   1.938 + 
   1.939 +filestr.close();
   1.940 +if(filestr.is_open())
   1.941 +failures++;
   1.942 +  
   1.943 + // __UHEAP_MARKEND;
   1.944 +  
   1.945 +  /*if(failures)
   1.946 +return KErrNone;
   1.947 +return KErrGeneral;
   1.948 +    */  
   1.949 + #if  STDCPP_OOM
   1.950 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
   1.951 +  #endif    
   1.952 +   //#if STDCPP_OOM
   1.953 +//failures++;
   1.954 +// #endif
   1.955 +    
   1.956 +    }
   1.957 +   catch(bad_alloc&)
   1.958 +   {
   1.959 +   	//do nothing
   1.960 +    }
   1.961 +   catch(...)
   1.962 +   {
   1.963 +   	failures++;
   1.964 +   	
   1.965 +   }
   1.966 +   
   1.967 +	if( failures == 0 )
   1.968 +		return KErrNone;
   1.969 +  else  
   1.970 +		return KErrGeneral;
   1.971 +    } 
   1.972 + 
   1.973 +// -----------------------------------------------------------------------------
   1.974 +// Ctiostreams:: istrstream
   1.975 +// Example test method function.
   1.976 +// (other items were commented in a header).
   1.977 +// -----------------------------------------------------------------------------
   1.978 +//   
   1.979 +    TInt Ctiostreams::istrstreamL(CStifItemParser& aItem ) 
   1.980 +    {
   1.981 +  //  __UHEAP_MARK;	
   1.982 +  int failures=0;
   1.983 +  try
   1.984 +  {
   1.985 +  	
   1.986 +  
   1.987 +    char* p = "This is first string";
   1.988 +    char* q = "This is second string";
   1.989 +    char* r = "";
   1.990 +    const char* s ="const char";
   1.991 +    streamsize  n =10;
   1.992 +    cout<<"";
   1.993 +    #if  STDCPP_OOM
   1.994 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
   1.995 +  #endif 
   1.996 +    istrstream first(p);
   1.997 +    istrstream second(q);
   1.998 +    istrstream third(r);
   1.999 +    
  1.1000 +    istrstream four(s);
  1.1001 +    
  1.1002 +    istrstream  five(p,n);
  1.1003 +    istrstream six(s,n);
  1.1004 + /*   if(first.str() == "This is first string")
  1.1005 +    if(second.str()!= " This is second string")
  1.1006 +    if(third.str() == "")
  1.1007 + //   __UHEAP_MARKEND;
  1.1008 +    
  1.1009 +    return KErrNone;
  1.1010 +    return KErrGeneral;
  1.1011 +   */ 
  1.1012 +       first.rdbuf();
  1.1013 +    second.rdbuf();
  1.1014 +    third.rdbuf();
  1.1015 +    
  1.1016 +     if(first.str() != "This is first string")
  1.1017 +    if(second.str()== " This is second string")
  1.1018 +    if(third.str() != "")
  1.1019 +    failures++;
  1.1020 +    
  1.1021 +    #if  STDCPP_OOM
  1.1022 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1023 +  #endif 
  1.1024 +  //#if STDCPP_OOM
  1.1025 +//failures++;
  1.1026 +// #endif
  1.1027 +     
  1.1028 +    }
  1.1029 +    
  1.1030 +    
  1.1031 +    catch(bad_alloc&)
  1.1032 +   {
  1.1033 +   	//do nothing
  1.1034 +    }
  1.1035 +   catch(...)
  1.1036 +   {
  1.1037 +   	failures++;
  1.1038 +   	
  1.1039 +   }
  1.1040 +   
  1.1041 +	if( failures == 0 )
  1.1042 +		return KErrNone;
  1.1043 +  else  
  1.1044 +		return KErrGeneral;
  1.1045 +    }
  1.1046 +    
  1.1047 +TInt Ctiostreams::strstreamL(CStifItemParser& aItem ) 
  1.1048 +      {
  1.1049 +    // __UHEAP_MARK; 	
  1.1050 +     
  1.1051 +  	int failures = 0;
  1.1052 +  	try
  1.1053 +  	{
  1.1054 +  	cout<<"";	
  1.1055 +  	#if  STDCPP_OOM
  1.1056 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1057 +  #endif 
  1.1058 +//  char* s;
  1.1059 +//   int n;
  1.1060 +//   ios_base::openmode mode;
  1.1061 +//  strstream ss3(s, n, mode);
  1.1062 +  	strstream ss1,ss2;
  1.1063 +  	 ss1 << "";
  1.1064 +  	 ss1.rdbuf();
  1.1065 +  	 if(ss1.rdbuf( )->pcount( ) != 0)
  1.1066 +  	 failures++;
  1.1067 +  	 
  1.1068 +  	 string str1= ss1.str();
  1.1069 +  	 if(str1.compare("")!=0)
  1.1070 +  	 failures++;
  1.1071 +  	 
  1.1072 +  	 ss2 << "strstream testcase";
  1.1073 +  	 ss2 << '\0';
  1.1074 +  	 if( ss2.rdbuf( )->pcount( ) != sizeof("strstream testcase\0")-1)
  1.1075 +  	 failures++;
  1.1076 +  	 
  1.1077 +  	 string str = ss2.str();
  1.1078 +  	 
  1.1079 +  	 if(str.compare("strstream testcase")!= 0)
  1.1080 +  	 failures++;
  1.1081 +  	 ss1.freeze();
  1.1082 +  	 //__UHEAP_MARKEND;
  1.1083 +  /*	 
  1.1084 +  	 if(failures)
  1.1085 +  	 return KErrGeneral;
  1.1086 +  	 else
  1.1087 +  	return KErrNone;
  1.1088 +  */
  1.1089 +  
  1.1090 +  
  1.1091 +  #if  STDCPP_OOM
  1.1092 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1093 +  #endif 
  1.1094 +  
  1.1095 +    //#if STDCPP_OOM
  1.1096 +//failures++;
  1.1097 +// #endif
  1.1098 +      }
  1.1099 +      
  1.1100 +      catch(bad_alloc&)
  1.1101 +   {
  1.1102 +   	//do nothing
  1.1103 +    }
  1.1104 +   catch(...)
  1.1105 +   {
  1.1106 +   	failures++;
  1.1107 +   	
  1.1108 +   }
  1.1109 +   
  1.1110 +	if( failures == 0 )
  1.1111 +		return KErrNone;
  1.1112 +  else  
  1.1113 +		return KErrGeneral;
  1.1114 +    }
  1.1115 +    
  1.1116 +    
  1.1117 +TInt Ctiostreams::ostrstreamL(CStifItemParser& aItem ) 
  1.1118 +      {
  1.1119 +      	
  1.1120 +     //__UHEAP_MARK;
  1.1121 +     int failures = 0;
  1.1122 +     try
  1.1123 +     {
  1.1124 +     cout<<"";	
  1.1125 +     #if  STDCPP_OOM
  1.1126 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1127 +  #endif 
  1.1128 +//  	char* s;
  1.1129 +//  	int n;
  1.1130 +//  	ios_base::openmode mode;
  1.1131 +//  	ostrstream  oss3( s, n, mode);
  1.1132 +  	ostrstream  oss1 ,oss2;
  1.1133 +  	string str;
  1.1134 +  	 oss1 << "";
  1.1135 +  	 oss1.rdbuf();
  1.1136 +  	 if(oss1.rdbuf( )->pcount( ) != 0)
  1.1137 +  	 failures++;
  1.1138 +  	 
  1.1139 +  	 oss2 << "ostrstream testcase";
  1.1140 +  	 oss2<<'\0';
  1.1141 +  	 str = oss2.str();
  1.1142 +  	 
  1.1143 +  	 if(str.compare("ostrstream testcase") !=0)
  1.1144 +  	 failures++;
  1.1145 +  	 
  1.1146 +   oss2.freeze();
  1.1147 +  	 
  1.1148 +  	 #if  STDCPP_OOM
  1.1149 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1150 +  #endif 
  1.1151 +  	
  1.1152 +  	// __UHEAP_MARKEND;
  1.1153 +  /*	 
  1.1154 +  	 if(failures)
  1.1155 +  	 return KErrGeneral;
  1.1156 +  	 else
  1.1157 +  	return KErrNone;
  1.1158 +  */
  1.1159 +  
  1.1160 +    //#if STDCPP_OOM
  1.1161 +//failures++;
  1.1162 +// #endif
  1.1163 +      }
  1.1164 +      
  1.1165 +      catch(bad_alloc&)
  1.1166 +   {
  1.1167 +   	//do nothing
  1.1168 +    }
  1.1169 +   catch(...)
  1.1170 +   {
  1.1171 +   	failures++;
  1.1172 +   	
  1.1173 +   }
  1.1174 +   
  1.1175 +	if( failures == 0 )
  1.1176 +		return KErrNone;
  1.1177 +  else  
  1.1178 +		return KErrGeneral;
  1.1179 +    }
  1.1180 +   
  1.1181 +
  1.1182 +
  1.1183 + TInt Ctiostreams::istreamiterators(CStifItemParser& aItem )
  1.1184 +    {
  1.1185 +    	
  1.1186 +   // __UHEAP_MARK;
  1.1187 +   // Typedefs for convenience.
  1.1188 +   int failures=0;
  1.1189 +   try
  1.1190 +   {
  1.1191 +   cout<<"";
  1.1192 +   	#if  STDCPP_OOM
  1.1193 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1194 +  #endif 
  1.1195 +   
  1.1196 +    typedef std::vector<int, std::allocator<int> >    Vector;
  1.1197 +
  1.1198 +    typedef std::istream_iterator<Vector::value_type,char, std::char_traits<char>, ptrdiff_t>        is_iter;
  1.1199 +
  1.1200 + #if  STDCPP_OOM
  1.1201 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1202 +  #endif 
  1.1203 +    Vector v;
  1.1204 +//__UHEAP_MARKEND;
  1.1205 + 
  1.1206 +    //#if STDCPP_OOM
  1.1207 +//failures++;
  1.1208 +// #endif
  1.1209 + 
  1.1210 +
  1.1211 +
  1.1212 + }
  1.1213 +
  1.1214 +
  1.1215 +catch(bad_alloc&)
  1.1216 +   {
  1.1217 +   	//do nothing
  1.1218 +    }
  1.1219 +   catch(...)
  1.1220 +   {
  1.1221 +   	failures++;
  1.1222 +   	
  1.1223 +   }
  1.1224 +   
  1.1225 +	if( failures == 0 )
  1.1226 +		return KErrNone;
  1.1227 +  else  
  1.1228 +		return KErrGeneral;
  1.1229 +    }
  1.1230 +   
  1.1231 +   
  1.1232 + TInt Ctiostreams::istreambufiterators(CStifItemParser& aItem )
  1.1233 +    {
  1.1234 +    	
  1.1235 +      
  1.1236 +   //   __UHEAP_MARK;
  1.1237 +       // create a temporary filename
  1.1238 +       
  1.1239 +       int failures=0;
  1.1240 +       try
  1.1241 +       {
  1.1242 +       	
  1.1243 +       
  1.1244 +    const char *fname = tmpnam (0);
  1.1245 +
  1.1246 +    if (!fname)
  1.1247 +        return 1;
  1.1248 +
  1.1249 +    // open the file is_iter.out for reading and writing
  1.1250 +    std::ofstream out (fname, std::ios::out | std::ios::in | 
  1.1251 +                              std::ios::trunc);
  1.1252 +
  1.1253 +    // output the example sentence into the file
  1.1254 +
  1.1255 +    // seek to the beginning of the file
  1.1256 +    out.seekp (0);
  1.1257 +    cout<<"";
  1.1258 +#if  STDCPP_OOM
  1.1259 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1260 +  #endif 
  1.1261 +    // construct an istreambuf_iterator pointing to
  1.1262 +    // the ofstream object underlying streambuffer
  1.1263 +    std::istreambuf_iterator<char, std::char_traits<char> >iter (out.rdbuf ());
  1.1264 +
  1.1265 +    // construct an end of stream iterator
  1.1266 +    const std::istreambuf_iterator<char,std::char_traits<char> > end;
  1.1267 +#if  STDCPP_OOM
  1.1268 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1269 +  #endif 
  1.1270 +    std::cout << std::endl;
  1.1271 +
  1.1272 +    // output the content of the file
  1.1273 +    while (!iter.equal (end)) {
  1.1274 +
  1.1275 +        // use both operator++ and operator*
  1.1276 +        std::cout << *iter++;
  1.1277 +    }
  1.1278 +
  1.1279 +    std::cout << std::endl; 
  1.1280 +
  1.1281 +    // remove temporary file
  1.1282 +    remove (fname);
  1.1283 +//__UHEAP_MARKEND;
  1.1284 + 
  1.1285 + //#if STDCPP_OOM
  1.1286 +//failures++;
  1.1287 +// #endif
  1.1288 +
  1.1289 + }
  1.1290 +
  1.1291 +catch(bad_alloc&)
  1.1292 +   {
  1.1293 +   	//do nothing
  1.1294 +    }
  1.1295 +   catch(...)
  1.1296 +   {
  1.1297 +   	failures++;
  1.1298 +   	
  1.1299 +   }
  1.1300 +   
  1.1301 +	if( failures == 0 )
  1.1302 +		return KErrNone;
  1.1303 +  else  
  1.1304 +		return KErrGeneral;
  1.1305 +    }
  1.1306 +    
  1.1307 +    
  1.1308 +    
  1.1309 + TInt Ctiostreams::strstreambufL(CStifItemParser& aItem )
  1.1310 + 
  1.1311 + 
  1.1312 + {
  1.1313 +// 	__UHEAP_MARK;
  1.1314 + 	
  1.1315 + int failures =0;
  1.1316 + try
  1.1317 + {
  1.1318 + 	
  1.1319 + cout<<"";
  1.1320 +
  1.1321 +  	#if  STDCPP_OOM
  1.1322 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1323 +  #endif 
  1.1324 +  
  1.1325 +  signed char* get = NULL;
  1.1326 +  streamsize n=10;
  1.1327 +  signed char* put = NULL;
  1.1328 +   unsigned char* uget = NULL;
  1.1329 +   unsigned char* uput = NULL;
  1.1330 +  const char* cget = NULL;
  1.1331 +  const signed char* csget = NULL;
  1.1332 +  
  1.1333 +  const unsigned char* cucget = NULL;
  1.1334 +  
  1.1335 +  
  1.1336 +  typedef void* (*__alloc_fn)(size_t);
  1.1337 +  typedef void (*__free_fn)(void*);
  1.1338 + 
  1.1339 +//  __alloc_fn  alloc_f;
  1.1340 + 
  1.1341 +//  __free_fn free_f;
  1.1342 +  
  1.1343 +  	//overloaded
  1.1344 +  	strstreambuf  buf1(get, n,put);
  1.1345 +  	
  1.1346 +  	//overloaded
  1.1347 +  	
  1.1348 +  	strstreambuf buf2(uget,n,uput);
  1.1349 +  	
  1.1350 +  	  	//overloaded
  1.1351 +  	strstreambuf buf3(cget,n);
  1.1352 +  	//onverloaded
  1.1353 +  	strstreambuf buf4(csget,n);
  1.1354 +  	//overloaded
  1.1355 +  	strstreambuf buf5(cucget,n);
  1.1356 +  	
  1.1357 +  	
  1.1358 +//  	strstreambuf buf6( alloc_f, free_f);
  1.1359 +  	  	strstreambuf buf7(n);
  1.1360 +
  1.1361 +  	strstreambuf  buf;
  1.1362 +  string str;
  1.1363 + int i = buf.sputn("strstreambuf testcase", sizeof("strstreambuf testcase")-1);
  1.1364 + 
  1.1365 +if((buf.pcount())!= i) 
  1.1366 +failures++;
  1.1367 + 
  1.1368 + buf.freeze();
  1.1369 +//if(buf.str() != "strstreambuf testcase")   //fails
  1.1370 +//failures++;
  1.1371 +
  1.1372 +#if  STDCPP_OOM
  1.1373 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1374 +  #endif 
  1.1375 +
  1.1376 +//__UHEAP_MARKEND; 
  1.1377 +/*if(failures)
  1.1378 +return KErrGeneral;
  1.1379 +else
  1.1380 + return KErrNone;
  1.1381 +  */
  1.1382 +  
  1.1383 +  //#if STDCPP_OOM
  1.1384 +//failures++;
  1.1385 +// #endif
  1.1386 + 
  1.1387 + }
  1.1388 + catch(bad_alloc&)
  1.1389 +   {
  1.1390 +   	//do nothing
  1.1391 +    }
  1.1392 +   catch(...)
  1.1393 +   {
  1.1394 +   	failures++;
  1.1395 +   	
  1.1396 +   }
  1.1397 +   
  1.1398 +	if( failures == 0 )
  1.1399 +		return KErrNone;
  1.1400 +  else  
  1.1401 +		return KErrGeneral;
  1.1402 +    }
  1.1403 +    
  1.1404 +    
  1.1405 +    
  1.1406 +
  1.1407 + TInt Ctiostreams::freezeL(CStifItemParser& aItem )
  1.1408 + {
  1.1409 + 
  1.1410 + int failures=0;
  1.1411 + try
  1.1412 + {
  1.1413 + 	
  1.1414 +  strstream  x;
  1.1415 +int failures =0;
  1.1416 +    x << "test1";
  1.1417 +   
  1.1418 +if(!x.good())
  1.1419 +failures++;    
  1.1420 +cout<<"";
  1.1421 + 
  1.1422 +  #if  STDCPP_OOM
  1.1423 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1424 +  #endif  
  1.1425 +   
  1.1426 +  x.rdbuf()->freeze();
  1.1427 + #if  STDCPP_OOM
  1.1428 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1429 +  #endif 
  1.1430 +if(!x.good())
  1.1431 +failures++;
  1.1432 +
  1.1433 +    // Stream is bad now, wrote on frozen stream
  1.1434 +    x << "test1.5";
  1.1435 +    
  1.1436 +//  report(x);
  1.1437 +if(!x.good())
  1.1438 +failures++;
  1.1439 +    // Unfreeze stream, but it is still bad
  1.1440 +    x.rdbuf()->freeze(false);
  1.1441 + if(!x.good())
  1.1442 +failures++;
  1.1443 +
  1.1444 +    // Clear stream
  1.1445 +    x.clear();
  1.1446 + 
  1.1447 +if(!x.good())
  1.1448 +failures++;
  1.1449 +
  1.1450 +
  1.1451 +    x << "test3";
  1.1452 +
  1.1453 +
  1.1454 +
  1.1455 +
  1.1456 +    // Clean up.  Failure to unfreeze stream will cause a
  1.1457 +    // memory leak.
  1.1458 +    x.rdbuf()->freeze(false);
  1.1459 +    /*
  1.1460 +if(failures)
  1.1461 +return KErrGeneral;
  1.1462 +else
  1.1463 +return KErrNone;
  1.1464 +
  1.1465 +*/
  1.1466 +
  1.1467 + //#if STDCPP_OOM
  1.1468 +//failures++;
  1.1469 +// #endif
  1.1470 +  }
  1.1471 +  
  1.1472 +  
  1.1473 +  
  1.1474 +  catch(bad_alloc&)
  1.1475 +   {
  1.1476 +   	//do nothing
  1.1477 +    }
  1.1478 +   catch(...)
  1.1479 +   {
  1.1480 +   	failures++;
  1.1481 +   	
  1.1482 +   }
  1.1483 +   
  1.1484 +	if( failures == 0 )
  1.1485 +		return KErrNone;
  1.1486 +  else  
  1.1487 +		return KErrGeneral;
  1.1488 +    }
  1.1489 + 
  1.1490 +
  1.1491 + TInt Ctiostreams::fposL(CStifItemParser& aItem )
  1.1492 + {
  1.1493 + int failures=0;
  1.1494 + try
  1.1495 + {
  1.1496 + 	
  1.1497 + 
  1.1498 +// streamoff s;
  1.1499 +   ifstream file( "c:\\TestFramework\\docs\\fpos_state.txt" );
  1.1500 +  cout<<"";
  1.1501 +    #if  STDCPP_OOM
  1.1502 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1503 +  #endif
  1.1504 +   fpos<mbstate_t> f = file.tellg( );
  1.1505 +   char ch;
  1.1506 +   while ( !file.eof( ) )
  1.1507 +      file.get( ch );
  1.1508 +  
  1.1509 +  f.state();
  1.1510 +    cout<<"";
  1.1511 +    #if  STDCPP_OOM
  1.1512 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1513 +  #endif
  1.1514 +   //s = f;
  1.1515 +  // if(f.state( ))
  1.1516 +  // failures++;
  1.1517 +  // f.state( 9 );
  1.1518 + //  if( f.state( ))
  1.1519 + //  failures++;
  1.1520 +   /*if(failures)
  1.1521 +   return KErrGeneral;
  1.1522 +   return KErrNone;*/
  1.1523 +   
  1.1524 +   //#if STDCPP_OOM
  1.1525 +//failures++;
  1.1526 +// #endif
  1.1527 + }
  1.1528 +
  1.1529 + catch(bad_alloc&)
  1.1530 +   {
  1.1531 +   	//do nothing
  1.1532 +    }
  1.1533 +   catch(...)
  1.1534 +   {
  1.1535 +   	failures++;
  1.1536 +   	
  1.1537 +   }
  1.1538 +   
  1.1539 +	if( failures == 0 )
  1.1540 +		return KErrNone;
  1.1541 +  else  
  1.1542 +		return KErrGeneral;
  1.1543 +    }
  1.1544 + 
  1.1545 + 
  1.1546 + 
  1.1547 + 
  1.1548 +// -----------------------------------------------------------------------------
  1.1549 +// Cstdcpp_filebuf::filebufL
  1.1550 +// Example test method function.
  1.1551 +// (other items were commented in a header).
  1.1552 +// -----------------------------------------------------------------------------
  1.1553 +//
  1.1554 +TInt Ctiostreams::filebufL( CStifItemParser& aItem )
  1.1555 +    {
  1.1556 +   int failures=0;
  1.1557 +try
  1.1558 +{
  1.1559 +	
  1.1560 +
  1.1561 +
  1.1562 +    ifstream is;
  1.1563 +    cout<<"";
  1.1564 +    #if  STDCPP_OOM
  1.1565 +User::__DbgSetAllocFail(FALSE,RHeap::EDeterministic,1);
  1.1566 +  #endif 
  1.1567 +  filebuf * fb;
  1.1568 +
  1.1569 +  fb = is.rdbuf();
  1.1570 +  fb->open ("c:\\TestFramework\\docs\\filebuf.txt",ios::in);
  1.1571 +
  1.1572 +   if(!fb->is_open())
  1.1573 +   failures++;
  1.1574 +   
  1.1575 +
  1.1576 +  fb->close();
  1.1577 +if(fb->is_open())
  1.1578 +failures++;
  1.1579 +
  1.1580 +
  1.1581 +#if  STDCPP_OOM
  1.1582 +User::__DbgSetAllocFail(FALSE,RHeap::ENone,1);
  1.1583 +  #endif 
  1.1584 +/*
  1.1585 +if(failures)
  1.1586 +return KErrGeneral;
  1.1587 +return KErrNone;
  1.1588 + */
  1.1589 + 
  1.1590 +  //#if STDCPP_OOM
  1.1591 +//failures++;
  1.1592 +// #endif
  1.1593 + 
  1.1594 +    }
  1.1595 +    
  1.1596 +    catch(bad_alloc&)
  1.1597 +   {
  1.1598 +   	//do nothing
  1.1599 +    }
  1.1600 +   catch(...)
  1.1601 +   {
  1.1602 +   	failures++;
  1.1603 +   	
  1.1604 +   }
  1.1605 +   
  1.1606 +	if( failures == 0 )
  1.1607 +		return KErrNone;
  1.1608 +  else  
  1.1609 +		return KErrGeneral;
  1.1610 +    }
  1.1611 + 
  1.1612 + 
  1.1613 +TInt Ctiostreams::seekpL( CStifItemParser& aItem )
  1.1614 +    { 
  1.1615 +     
  1.1616 +      ostringstream oss2;
  1.1617 +
  1.1618 +		  oss2<<"Do me a favor";    
  1.1619 +      long pos2 = oss2.tellp(); //   13
  1.1620 +	       
  1.1621 +      oss2 << "pp";
  1.1622 + 	    pos2 = oss2.tellp();  //   15
  1.1623 +      oss2.seekp(pos2 - 2);
  1.1624 +      pos2 = oss2.tellp();  //    13
  1.1625 +      string temp = "ss";
  1.1626 +      oss2.write(temp.c_str(), temp.size());
  1.1627 +      pos2 = oss2.tellp();  //    15
  1.1628 +      oss2.seekp(pos2 - 2);
  1.1629 +      pos2 = oss2.tellp();  //    13
  1.1630 +      oss2 << "ss";
  1.1631 +      pos2 = oss2.tellp();  //    15
  1.1632 +      oss2.seekp(pos2 - 2);
  1.1633 +      pos2 = oss2.tellp();  //    13
  1.1634 +      oss2 << "ss";  
  1.1635 +
  1.1636 +      pos2 = oss2.tellp();  
  1.1637 +
  1.1638 +	    oss2.seekp(pos2 - 2);
  1.1639 +	    pos2 = oss2.tellp();  
  1.1640 +	    oss2 << "pp";
  1.1641 +	    pos2 = oss2.tellp();   //15
  1.1642 +	    
  1.1643 +	    oss2.seekp(pos2 - 5);
  1.1644 +	    pos2 = oss2.tellp();  
  1.1645 +	    oss2 << "pppp";
  1.1646 +	    pos2 = oss2.tellp();   //14
  1.1647 +	    oss2.seekp(pos2 - 3);
  1.1648 +	    pos2 = oss2.tellp();  
  1.1649 +	    oss2 << "ppp";
  1.1650 +	    pos2 = oss2.tellp();   //14
  1.1651 +	    oss2 << "pppppp";
  1.1652 +	    pos2 = oss2.tellp();   //20
  1.1653 +
  1.1654 +    
  1.1655 +	    if( pos2 == 20 )
  1.1656 +		   return KErrNone;
  1.1657 +      else  
  1.1658 +		   return KErrGeneral;
  1.1659 +	  }        
  1.1660 +    
  1.1661 +    
  1.1662 + 
  1.1663 +//  End of File