os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/fstream_test.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <string>
sl@0
    17
#if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
sl@0
    18
#  include <fstream>
sl@0
    19
#  include <iostream>
sl@0
    20
#  include <iomanip>
sl@0
    21
#  include <sstream>
sl@0
    22
#  include <vector>
sl@0
    23
#  include <memory>
sl@0
    24
#include <e32std.h>
sl@0
    25
sl@0
    26
#  include "full_streambuf.h"
sl@0
    27
#  include "cppunit/cppunit_proxy.h"
sl@0
    28
sl@0
    29
#  if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
sl@0
    30
using namespace std;
sl@0
    31
#  endif
sl@0
    32
sl@0
    33
//The macro value gives approximately the generated file
sl@0
    34
//size in Go
sl@0
    35
//#define CHECK_BIG_FILE 4
sl@0
    36
sl@0
    37
#  if !defined (STLPORT) || !defined (_STLP_NO_CUSTOM_IO) && !defined (_STLP_NO_MEMBER_TEMPLATES) && \
sl@0
    38
                            !((defined (_STLP_MSVC) && (_STLP_MSVC < 1300)) || \
sl@0
    39
                              (defined (__GNUC__) && (__GNUC__ < 3)) || \
sl@0
    40
                              (defined (__SUNPRO_CC)) || \
sl@0
    41
                              (defined (__DMC__) && defined (_DLL)))
sl@0
    42
#    define DO_CUSTOM_FACET_TEST
sl@0
    43
#  endif
sl@0
    44
sl@0
    45
//
sl@0
    46
// TestCase class
sl@0
    47
//
sl@0
    48
class FstreamTest : public CPPUNIT_NS::TestCase
sl@0
    49
{
sl@0
    50
  CPPUNIT_TEST_SUITE(FstreamTest);
sl@0
    51
  CPPUNIT_TEST(output);
sl@0
    52
  CPPUNIT_TEST(input);
sl@0
    53
  CPPUNIT_TEST(input_char);
sl@0
    54
  CPPUNIT_TEST(io);
sl@0
    55
  CPPUNIT_TEST(err);
sl@0
    56
  CPPUNIT_TEST(tellg);
sl@0
    57
  CPPUNIT_TEST(buf);
sl@0
    58
  CPPUNIT_TEST(rdbuf);
sl@0
    59
#if !defined (STLPORT) || !defined (_STLP_WIN32)
sl@0
    60
  CPPUNIT_TEST(offset);
sl@0
    61
#endif
sl@0
    62
#  if defined (__DMC__)
sl@0
    63
  CPPUNIT_IGNORE;
sl@0
    64
#  endif
sl@0
    65
  CPPUNIT_TEST(streambuf_output);
sl@0
    66
  CPPUNIT_STOP_IGNORE;
sl@0
    67
  CPPUNIT_TEST(win32_file_format);
sl@0
    68
#  if defined (CHECK_BIG_FILE)
sl@0
    69
  CPPUNIT_TEST(big_file);
sl@0
    70
#  endif
sl@0
    71
#  if !defined (DO_CUSTOM_FACET_TEST)
sl@0
    72
  CPPUNIT_IGNORE;
sl@0
    73
#endif
sl@0
    74
  CPPUNIT_TEST(custom_facet);
sl@0
    75
  CPPUNIT_TEST(fstream_cov1);
sl@0
    76
  CPPUNIT_TEST(fstream_cov2);
sl@0
    77
  CPPUNIT_TEST(fstream_cov3);
sl@0
    78
  CPPUNIT_TEST(fstream_cov4);
sl@0
    79
  CPPUNIT_TEST(fstream_cov5);
sl@0
    80
  CPPUNIT_TEST_SUITE_END();
sl@0
    81
sl@0
    82
  protected:
sl@0
    83
    void output();
sl@0
    84
    void input();
sl@0
    85
    void input_char();
sl@0
    86
    void io();
sl@0
    87
    void err();
sl@0
    88
    void tellg();
sl@0
    89
    void buf();
sl@0
    90
    void rdbuf();
sl@0
    91
    void streambuf_output();
sl@0
    92
    void win32_file_format();
sl@0
    93
    void custom_facet();
sl@0
    94
    void fstream_cov1();
sl@0
    95
    void fstream_cov2();
sl@0
    96
    void fstream_cov3();
sl@0
    97
    void fstream_cov4();
sl@0
    98
    void fstream_cov5();
sl@0
    99
#  if !defined (STLPORT) || !defined (_STLP_WIN32)
sl@0
   100
    void offset();
sl@0
   101
#  endif
sl@0
   102
#  if defined (CHECK_BIG_FILE)
sl@0
   103
    void big_file();
sl@0
   104
#  endif
sl@0
   105
};
sl@0
   106
sl@0
   107
CPPUNIT_TEST_SUITE_REGISTRATION(FstreamTest);
sl@0
   108
sl@0
   109
//
sl@0
   110
// tests implementation
sl@0
   111
//
sl@0
   112
void FstreamTest::output()
sl@0
   113
{
sl@0
   114
  ofstream f( "c:\\private\\test_file.txt" );
sl@0
   115
sl@0
   116
  f << 1 << '\n' << 2.0 << '\n' << "abcd\n" << "ghk lm\n" << "abcd ef";
sl@0
   117
  CPPUNIT_ASSERT (f.good());
sl@0
   118
  // CPPUNIT_ASSERT( s.str() == "1\n2\nabcd\nghk lm\nabcd ef" );
sl@0
   119
}
sl@0
   120
sl@0
   121
void FstreamTest::input()
sl@0
   122
{
sl@0
   123
  ifstream f( "c:\\private\\test_file.txt" );
sl@0
   124
  int i = 0;
sl@0
   125
  f >> i;
sl@0
   126
  CPPUNIT_ASSERT( f.good() );
sl@0
   127
  CPPUNIT_ASSERT( i == 1 );
sl@0
   128
  double d = 0.0;
sl@0
   129
  f >> d;
sl@0
   130
  CPPUNIT_ASSERT( f.good() );
sl@0
   131
  CPPUNIT_ASSERT( d == 2.0 );
sl@0
   132
  string str;
sl@0
   133
  f >> str;
sl@0
   134
  CPPUNIT_ASSERT( f.good() );
sl@0
   135
  CPPUNIT_ASSERT( str == "abcd" );
sl@0
   136
  char c;
sl@0
   137
  f.get(c); // extract newline, that not extracted by operator >>
sl@0
   138
  CPPUNIT_ASSERT( f.good() );
sl@0
   139
  CPPUNIT_ASSERT( c == '\n' );
sl@0
   140
  getline( f, str );
sl@0
   141
  CPPUNIT_ASSERT( f.good() );
sl@0
   142
  CPPUNIT_ASSERT( str == "ghk lm" );
sl@0
   143
  getline( f, str );
sl@0
   144
  CPPUNIT_ASSERT( f.eof() );
sl@0
   145
  CPPUNIT_ASSERT( str == "abcd ef" );
sl@0
   146
}
sl@0
   147
sl@0
   148
void FstreamTest::input_char()
sl@0
   149
{
sl@0
   150
  char buf[16] = { 0, '1', '2', '3' };
sl@0
   151
  ifstream s( "c:\\private\\test_file.txt" );
sl@0
   152
  s >> buf;
sl@0
   153
sl@0
   154
  CPPUNIT_ASSERT( buf[0] == '1' );
sl@0
   155
  CPPUNIT_ASSERT( buf[1] == 0 );
sl@0
   156
  CPPUNIT_ASSERT( buf[2] == '2' );
sl@0
   157
}
sl@0
   158
sl@0
   159
void FstreamTest::io()
sl@0
   160
{
sl@0
   161
  basic_fstream<char,char_traits<char> > f( "c:\\private\\test_file.txt", ios_base::in | ios_base::out | ios_base::trunc );
sl@0
   162
sl@0
   163
  CPPUNIT_ASSERT( f.is_open() );
sl@0
   164
sl@0
   165
  f << 1 << '\n' << 2.0 << '\n' << "abcd\n" << "ghk lm\n" << "abcd ef";
sl@0
   166
sl@0
   167
  // f.flush();
sl@0
   168
  f.seekg( 0, ios_base::beg );
sl@0
   169
sl@0
   170
  int i = 0;
sl@0
   171
  f >> i;
sl@0
   172
  CPPUNIT_ASSERT( f.good() );
sl@0
   173
  CPPUNIT_ASSERT( i == 1 );
sl@0
   174
  double d = 0.0;
sl@0
   175
  f >> d;
sl@0
   176
  CPPUNIT_ASSERT( d == 2.0 );
sl@0
   177
  string s;
sl@0
   178
  f >> s;
sl@0
   179
  CPPUNIT_ASSERT( f.good() );
sl@0
   180
  CPPUNIT_ASSERT( s == "abcd" );
sl@0
   181
  char c;
sl@0
   182
  f.get(c); // extract newline, that not extracted by operator >>
sl@0
   183
  CPPUNIT_ASSERT( f.good() );
sl@0
   184
  CPPUNIT_ASSERT( c == '\n' );
sl@0
   185
  getline( f, s );
sl@0
   186
  CPPUNIT_ASSERT( f.good() );
sl@0
   187
  CPPUNIT_ASSERT( s == "ghk lm" );
sl@0
   188
  getline( f, s );
sl@0
   189
  CPPUNIT_ASSERT( !f.fail() );
sl@0
   190
  CPPUNIT_ASSERT( s == "abcd ef" );
sl@0
   191
  CPPUNIT_ASSERT( f.eof() );
sl@0
   192
}
sl@0
   193
sl@0
   194
void FstreamTest::err()
sl@0
   195
{
sl@0
   196
  basic_fstream<char,char_traits<char> > f( "c:\\private\\test_file.txt", ios_base::in | ios_base::out | ios_base::trunc );
sl@0
   197
sl@0
   198
  CPPUNIT_ASSERT( f.is_open() );
sl@0
   199
sl@0
   200
  int i = 9;
sl@0
   201
  f << i;
sl@0
   202
  CPPUNIT_ASSERT( f.good() );
sl@0
   203
  i = 0;
sl@0
   204
  f.seekg( 0, ios_base::beg );
sl@0
   205
  f >> i;
sl@0
   206
  CPPUNIT_ASSERT( !f.fail() );
sl@0
   207
  CPPUNIT_ASSERT( i == 9 );
sl@0
   208
  f >> i;
sl@0
   209
  CPPUNIT_ASSERT( f.fail() );
sl@0
   210
  CPPUNIT_ASSERT( f.eof() );
sl@0
   211
  CPPUNIT_ASSERT( i == 9 );
sl@0
   212
}
sl@0
   213
sl@0
   214
void FstreamTest::tellg()
sl@0
   215
{
sl@0
   216
  {
sl@0
   217
    // bogus ios_base::binary is for Wins
sl@0
   218
    ofstream of("c:\\private\\test_file.txt", ios_base::out | ios_base::binary | ios_base::trunc);
sl@0
   219
    CPPUNIT_ASSERT( of.is_open() );
sl@0
   220
sl@0
   221
    for (int i = 0; i < 50; ++i) {
sl@0
   222
      of << "line " << setiosflags(ios_base::right) << setfill('0') << setw(2) << i << "\n";
sl@0
   223
      CPPUNIT_ASSERT( !of.fail() );
sl@0
   224
    }
sl@0
   225
    of.close();
sl@0
   226
  }
sl@0
   227
sl@0
   228
  {
sl@0
   229
    // bogus ios_base::binary is for Wins
sl@0
   230
    ifstream is("c:\\private\\test_file.txt", ios_base::in | ios_base::binary);
sl@0
   231
    CPPUNIT_ASSERT( is.is_open() );
sl@0
   232
    char buf[64];
sl@0
   233
sl@0
   234
    // CPPUNIT_ASSERT( is.tellg() == 0 );
sl@0
   235
    streampos p = 0;
sl@0
   236
    for (int i = 0; i < 50; ++i) {
sl@0
   237
      CPPUNIT_ASSERT( is.tellg() == p );
sl@0
   238
      is.read( buf, 8 );
sl@0
   239
      CPPUNIT_ASSERT( !is.fail() );
sl@0
   240
      p += 8;
sl@0
   241
    }
sl@0
   242
  }
sl@0
   243
sl@0
   244
  {
sl@0
   245
    // bogus ios_base::binary is for Wins
sl@0
   246
    ifstream is("c:\\private\\test_file.txt", ios_base::in | ios_base::binary);
sl@0
   247
    CPPUNIT_ASSERT( is.is_open() );
sl@0
   248
sl@0
   249
    streampos p = 0;
sl@0
   250
    for (int i = 0; i < 50; ++i) {
sl@0
   251
      CPPUNIT_ASSERT( !is.fail() );
sl@0
   252
      is.tellg();
sl@0
   253
      CPPUNIT_ASSERT( is.tellg() == p );
sl@0
   254
      p += 8;
sl@0
   255
      is.seekg( p, ios_base::beg  );
sl@0
   256
      CPPUNIT_ASSERT( !is.fail() );
sl@0
   257
    }
sl@0
   258
  }
sl@0
   259
sl@0
   260
  {
sl@0
   261
    // bogus ios_base::binary is for Wins
sl@0
   262
    ifstream is("c:\\private\\test_file.txt", ios_base::in | ios_base::binary);
sl@0
   263
    CPPUNIT_ASSERT( is.is_open() );
sl@0
   264
sl@0
   265
    streampos p = 0;
sl@0
   266
    for (int i = 0; i < 50; ++i) {
sl@0
   267
      CPPUNIT_ASSERT( is.tellg() == p );
sl@0
   268
      p += 8;
sl@0
   269
      is.seekg( 8, ios_base::cur );
sl@0
   270
      CPPUNIT_ASSERT( !is.fail() );
sl@0
   271
    }
sl@0
   272
  }
sl@0
   273
}
sl@0
   274
sl@0
   275
void FstreamTest::buf()
sl@0
   276
{
sl@0
   277
  fstream ss( "c:\\private\\test_file.txt", ios_base::in | ios_base::out | ios_base::binary | ios_base::trunc );
sl@0
   278
sl@0
   279
  ss << "1234567\n89\n";
sl@0
   280
  ss.seekg( 0, ios_base::beg );
sl@0
   281
  char buf[10];
sl@0
   282
  buf[7] = 'x';
sl@0
   283
  ss.get( buf, 10 );
sl@0
   284
  CPPUNIT_ASSERT( !ss.fail() );
sl@0
   285
  CPPUNIT_ASSERT( buf[0] == '1' );
sl@0
   286
  CPPUNIT_ASSERT( buf[1] == '2' );
sl@0
   287
  CPPUNIT_ASSERT( buf[2] == '3' );
sl@0
   288
  CPPUNIT_ASSERT( buf[3] == '4' );
sl@0
   289
  CPPUNIT_ASSERT( buf[4] == '5' );
sl@0
   290
  CPPUNIT_ASSERT( buf[5] == '6' );
sl@0
   291
  CPPUNIT_ASSERT( buf[6] == '7' ); // 27.6.1.3 paragraph 10, paragraph 7
sl@0
   292
  CPPUNIT_ASSERT( buf[7] == 0 ); // 27.6.1.3 paragraph 8
sl@0
   293
  char c;
sl@0
   294
  ss.get(c);
sl@0
   295
  CPPUNIT_ASSERT( !ss.fail() );
sl@0
   296
  CPPUNIT_ASSERT( c == '\n' ); // 27.6.1.3 paragraph 10, paragraph 7
sl@0
   297
  ss.get(c);
sl@0
   298
  CPPUNIT_ASSERT( !ss.fail() );
sl@0
   299
  CPPUNIT_ASSERT( c == '8' );
sl@0
   300
}
sl@0
   301
sl@0
   302
void FstreamTest::rdbuf()
sl@0
   303
{
sl@0
   304
  fstream ss( "c:\\private\\test_file.txt", ios_base::in | ios_base::out | ios_base::binary | ios_base::trunc );
sl@0
   305
sl@0
   306
  ss << "1234567\n89\n";
sl@0
   307
  ss.seekg( 0, ios_base::beg );
sl@0
   308
sl@0
   309
  ostringstream os;
sl@0
   310
  ss.get( *os.rdbuf(), '\n' );
sl@0
   311
  CPPUNIT_ASSERT( !ss.fail() );
sl@0
   312
  char c;
sl@0
   313
  ss.get(c);
sl@0
   314
  CPPUNIT_ASSERT( !ss.fail() );
sl@0
   315
  CPPUNIT_ASSERT( c == '\n' ); // 27.6.1.3 paragraph 12
sl@0
   316
  CPPUNIT_ASSERT( os.str() == "1234567" );
sl@0
   317
}
sl@0
   318
sl@0
   319
void FstreamTest::streambuf_output()
sl@0
   320
{
sl@0
   321
  {
sl@0
   322
    ofstream ofstr("c:\\private\\test_file.txt", ios_base::binary);
sl@0
   323
    if (!ofstr)
sl@0
   324
      //No test if we cannot create the file
sl@0
   325
      return;
sl@0
   326
    ofstr << "01234567890123456789";
sl@0
   327
    CPPUNIT_ASSERT( ofstr );
sl@0
   328
  }
sl@0
   329
sl@0
   330
  {
sl@0
   331
    ifstream in("c:\\private\\test_file.txt", ios_base::binary);
sl@0
   332
    CPPUNIT_ASSERT( in );
sl@0
   333
sl@0
   334
    auto_ptr<full_streambuf> pfull_buf(new full_streambuf(10));
sl@0
   335
    ostream out(pfull_buf.get());
sl@0
   336
    CPPUNIT_ASSERT( out );
sl@0
   337
sl@0
   338
    out << in.rdbuf();
sl@0
   339
    CPPUNIT_ASSERT( out );
sl@0
   340
    CPPUNIT_ASSERT( in );
sl@0
   341
    CPPUNIT_ASSERT( pfull_buf->str() == "0123456789" );
sl@0
   342
sl@0
   343
    out << in.rdbuf();
sl@0
   344
    CPPUNIT_ASSERT( out.fail() );
sl@0
   345
    CPPUNIT_ASSERT( in );
sl@0
   346
sl@0
   347
    ostringstream ostr;
sl@0
   348
    ostr << in.rdbuf();
sl@0
   349
    CPPUNIT_ASSERT( ostr );
sl@0
   350
    CPPUNIT_ASSERT( in );
sl@0
   351
    CPPUNIT_ASSERT( ostr.str() == "0123456789" );
sl@0
   352
  }
sl@0
   353
sl@0
   354
#  if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
sl@0
   355
  {
sl@0
   356
    //If the output stream buffer throws:
sl@0
   357
    ifstream in("c:\\private\\test_file.txt", ios_base::binary);
sl@0
   358
    CPPUNIT_ASSERT( in );
sl@0
   359
sl@0
   360
    auto_ptr<full_streambuf> pfull_buf(new full_streambuf(10, true));
sl@0
   361
    ostream out(pfull_buf.get());
sl@0
   362
    CPPUNIT_ASSERT( out );
sl@0
   363
sl@0
   364
    out << in.rdbuf();
sl@0
   365
    CPPUNIT_ASSERT( out.bad() );
sl@0
   366
    CPPUNIT_ASSERT( in );
sl@0
   367
    //out is bad we have no guaranty on what has been extracted:
sl@0
   368
    //CPPUNIT_ASSERT( pfull_buf->str() == "0123456789" );
sl@0
   369
sl@0
   370
    out.clear();
sl@0
   371
    out << in.rdbuf();
sl@0
   372
    CPPUNIT_ASSERT( out.fail() && out.bad() );
sl@0
   373
    CPPUNIT_ASSERT( in );
sl@0
   374
sl@0
   375
    ostringstream ostr;
sl@0
   376
    ostr << in.rdbuf();
sl@0
   377
    CPPUNIT_ASSERT( ostr );
sl@0
   378
    CPPUNIT_ASSERT( in );
sl@0
   379
    CPPUNIT_ASSERT( ostr.str() == "0123456789" );
sl@0
   380
  }
sl@0
   381
#  endif
sl@0
   382
}
sl@0
   383
sl@0
   384
void FstreamTest::win32_file_format()
sl@0
   385
{
sl@0
   386
  const char* file_name = "c:\\private\\win32_file_format.tmp";
sl@0
   387
  const size_t nb_lines = 2049;
sl@0
   388
  {
sl@0
   389
    ofstream out(file_name);
sl@0
   390
    CPPUNIT_ASSERT( out.good() );
sl@0
   391
    out << 'a';
sl@0
   392
    for (size_t i = 0; i < nb_lines - 1; ++i) {
sl@0
   393
      out << '\n';
sl@0
   394
    }
sl@0
   395
    out << '\r';
sl@0
   396
    CPPUNIT_ASSERT( out.good() );
sl@0
   397
  }
sl@0
   398
  {
sl@0
   399
    ifstream in(file_name);
sl@0
   400
    CPPUNIT_ASSERT( in.good() );
sl@0
   401
    string line, last_line;
sl@0
   402
    size_t nb_read_lines = 0;
sl@0
   403
    while (getline(in, line)) {
sl@0
   404
      ++nb_read_lines;
sl@0
   405
      last_line = line;
sl@0
   406
    }
sl@0
   407
    CPPUNIT_ASSERT( in.eof() );
sl@0
   408
    CPPUNIT_ASSERT( nb_read_lines == nb_lines );
sl@0
   409
    CPPUNIT_ASSERT( !last_line.empty() && (last_line[0] == '\r') );
sl@0
   410
  }
sl@0
   411
}
sl@0
   412
sl@0
   413
#if defined (DO_CUSTOM_FACET_TEST)
sl@0
   414
struct my_state {
sl@0
   415
  char dummy;
sl@0
   416
};
sl@0
   417
sl@0
   418
struct my_traits : public char_traits<char> {
sl@0
   419
  typedef my_state state_type;
sl@0
   420
  typedef fpos<state_type> pos_type;
sl@0
   421
};
sl@0
   422
sl@0
   423
class my_codecvt
sl@0
   424
#  if defined (STLPORT)
sl@0
   425
  : public codecvt<char, char, my_state> {
sl@0
   426
sl@0
   427
#  else
sl@0
   428
  : public locale::facet, public codecvt_base {
sl@0
   429
  //STLport grant the same default implementation, other Standard libs implementation
sl@0
   430
  //do not necessarily do the same:
sl@0
   431
  public:
sl@0
   432
    typedef char intern_type;
sl@0
   433
    typedef char extern_type;
sl@0
   434
    typedef my_state state_type;
sl@0
   435
sl@0
   436
    explicit my_codecvt(size_t __refs = 0) : locale::facet(__refs) {}
sl@0
   437
    result out(state_type&,
sl@0
   438
               const intern_type*  __from,
sl@0
   439
               const intern_type*,
sl@0
   440
               const intern_type*& __from_next,
sl@0
   441
               extern_type*        __to,
sl@0
   442
               extern_type*,
sl@0
   443
               extern_type*&       __to_next) const
sl@0
   444
    { __from_next = __from; __to_next   = __to; return noconv; }
sl@0
   445
sl@0
   446
    result in (state_type&,
sl@0
   447
               const extern_type*  __from,
sl@0
   448
               const extern_type*,
sl@0
   449
               const extern_type*& __from_next,
sl@0
   450
               intern_type*        __to,
sl@0
   451
               intern_type*,
sl@0
   452
               intern_type*&       __to_next) const
sl@0
   453
    { __from_next = __from; __to_next = __to; return noconv; }
sl@0
   454
sl@0
   455
    result unshift(state_type&,
sl@0
   456
                   extern_type* __to,
sl@0
   457
                   extern_type*,
sl@0
   458
                   extern_type*& __to_next) const
sl@0
   459
    { __to_next = __to; return noconv; }
sl@0
   460
sl@0
   461
    int encoding() const throw()
sl@0
   462
    { return 1; }
sl@0
   463
sl@0
   464
    bool always_noconv() const throw()
sl@0
   465
    { return true; }
sl@0
   466
sl@0
   467
    int length(const state_type&,
sl@0
   468
                  const extern_type* __from,
sl@0
   469
                  const extern_type* __end,
sl@0
   470
                  size_t __max) const
sl@0
   471
    { return (int)min(static_cast<size_t>(__end - __from), __max); }
sl@0
   472
sl@0
   473
    int max_length() const throw()
sl@0
   474
    { return 1; }
sl@0
   475
sl@0
   476
    static locale::id id;
sl@0
   477
#  endif
sl@0
   478
	
sl@0
   479
};
sl@0
   480
sl@0
   481
#  if !defined (STLPORT)
sl@0
   482
locale::id my_codecvt::id;
sl@0
   483
#  else
sl@0
   484
#    if defined (__BORLANDC__)
sl@0
   485
template <>
sl@0
   486
locale::id codecvt<char, char, my_state>::id;
sl@0
   487
#    endif
sl@0
   488
#  endif
sl@0
   489
#endif
sl@0
   490
sl@0
   491
#if defined (__SYMBIAN32__WSD__)
sl@0
   492
locale::id& codecvt<char, char, my_state>::GetFacetLocaleId()
sl@0
   493
{
sl@0
   494
	static locale::id aId = {41};
sl@0
   495
	return aId;
sl@0
   496
}
sl@0
   497
#endif
sl@0
   498
sl@0
   499
void FstreamTest::custom_facet()
sl@0
   500
{
sl@0
   501
#if defined (DO_CUSTOM_FACET_TEST) && !defined (__SYMBIAN32__) 
sl@0
   502
sl@0
   503
  const char* fileName = "c:\\private\\test_file.txt";
sl@0
   504
  //File preparation:
sl@0
   505
  {
sl@0
   506
    ofstream ofstr(fileName, ios_base::binary);
sl@0
   507
    ofstr << "0123456789";
sl@0
   508
    CPPUNIT_ASSERT( ofstr );
sl@0
   509
  }
sl@0
   510
sl@0
   511
  {
sl@0
   512
    typedef basic_ifstream<char, my_traits> my_ifstream;
sl@0
   513
    typedef basic_string<char, my_traits> my_string;
sl@0
   514
sl@0
   515
    my_ifstream ifstr(fileName);
sl@0
   516
    CPPUNIT_ASSERT( ifstr );
sl@0
   517
sl@0
   518
#  if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
sl@0
   519
    ifstr.imbue(locale::classic());
sl@0
   520
    CPPUNIT_ASSERT( ifstr.fail() && !ifstr.bad() );
sl@0
   521
    ifstr.clear();
sl@0
   522
#  endif
sl@0
   523
    locale my_loc(locale::classic(), new my_codecvt());
sl@0
   524
    ifstr.imbue(my_loc);
sl@0
   525
    CPPUNIT_ASSERT( ifstr.good() );
sl@0
   526
    /*
sl@0
   527
    my_string res;
sl@0
   528
    ifstr >> res;
sl@0
   529
    CPPUNIT_ASSERT( !ifstr.fail() );
sl@0
   530
    CPPUNIT_ASSERT( !ifstr.bad() );
sl@0
   531
    CPPUNIT_ASSERT( ifstr.eof() );
sl@0
   532
    CPPUNIT_ASSERT( res == "0123456789" );
sl@0
   533
    */
sl@0
   534
  }
sl@0
   535
#endif
sl@0
   536
}
sl@0
   537
sl@0
   538
#  if defined (CHECK_BIG_FILE)
sl@0
   539
void FstreamTest::big_file()
sl@0
   540
{
sl@0
   541
  vector<pair<streamsize, streamoff> > file_pos;
sl@0
   542
sl@0
   543
  //Big file creation:
sl@0
   544
  {
sl@0
   545
    ofstream out("big_file.txt");
sl@0
   546
    CPPUNIT_ASSERT( out );
sl@0
   547
sl@0
   548
    //We are going to generate a file with the following schema for the content:
sl@0
   549
    //0(1019 times)0000  //1023 characters + 1 charater for \n (for some platforms it will be a 1 ko line)
sl@0
   550
    //0(1019 times)0001
sl@0
   551
    //...
sl@0
   552
    //0(1019 times)1234
sl@0
   553
    //...
sl@0
   554
sl@0
   555
    //Generation of the number of loop:
sl@0
   556
    streamoff nb = 1;
sl@0
   557
    for (int i = 0; i < 20; ++i) {
sl@0
   558
      //This assertion check that the streamoff can at least represent the necessary integers values
sl@0
   559
      //for this test:
sl@0
   560
      CPPUNIT_ASSERT( (nb << 1) > nb );
sl@0
   561
      nb <<= 1;
sl@0
   562
    }
sl@0
   563
    CPPUNIT_ASSERT( nb * CHECK_BIG_FILE >= nb );
sl@0
   564
    nb *= CHECK_BIG_FILE;
sl@0
   565
sl@0
   566
    //Preparation of the ouput stream state:
sl@0
   567
    out << setiosflags(ios_base::right) << setfill('*');
sl@0
   568
    for (streamoff index = 0; index < nb; ++index) {
sl@0
   569
      if (index % 1024 == 0) {
sl@0
   570
        file_pos.push_back(make_pair(out.tellp(), index));
sl@0
   571
        CPPUNIT_ASSERT( file_pos.back().first != streamsize(-1) );
sl@0
   572
        if (file_pos.size() > 1) {
sl@0
   573
          CPPUNIT_ASSERT( file_pos[file_pos.size() - 1].first > file_pos[file_pos.size() - 2].first );
sl@0
   574
        }
sl@0
   575
      }
sl@0
   576
      out << setw(1023) << index << '\n';
sl@0
   577
    }
sl@0
   578
  }
sl@0
   579
sl@0
   580
  {
sl@0
   581
    ifstream in("big_file.txt");
sl@0
   582
    CPPUNIT_ASSERT( in );
sl@0
   583
sl@0
   584
    string line;
sl@0
   585
    vector<pair<streamsize, streamsize> >::const_iterator pit(file_pos.begin()),
sl@0
   586
                                                          pitEnd(file_pos.end());
sl@0
   587
    for (; pit != pitEnd; ++pit) {
sl@0
   588
      in.seekg((*pit).first);
sl@0
   589
      CPPUNIT_ASSERT( in );
sl@0
   590
      in >> line;
sl@0
   591
      size_t lastStarPos = line.rfind('*');
sl@0
   592
      CPPUNIT_ASSERT( atoi(line.substr(lastStarPos + 1).c_str()) == (*pit).second );
sl@0
   593
    }
sl@0
   594
  }
sl@0
   595
sl@0
   596
  /*
sl@0
   597
  The following test has been used to check that STLport do not generate
sl@0
   598
  an infinite loop when the file size is larger than the streamsize and
sl@0
   599
  streamoff representation (32 bits or 64 bits).
sl@0
   600
  {
sl@0
   601
    ifstream in("big_file.txt");
sl@0
   602
    CPPUNIT_ASSERT( in );
sl@0
   603
    char tmp[4096];
sl@0
   604
    streamsize nb_reads = 0;
sl@0
   605
    while ((!in.eof()) && in.good()){
sl@0
   606
      in.read(tmp, 4096);
sl@0
   607
      nb_reads += in.gcount();
sl@0
   608
    }
sl@0
   609
  }
sl@0
   610
  */
sl@0
   611
}
sl@0
   612
#  endif
sl@0
   613
sl@0
   614
#  if !defined (STLPORT) || !defined (_STLP_WIN32)
sl@0
   615
void FstreamTest::offset()
sl@0
   616
{
sl@0
   617
#    if (defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE)) && !defined(_STLP_USE_DEFAULT_FILE_OFFSET)
sl@0
   618
  CPPUNIT_CHECK( sizeof(streamoff) == 8 );
sl@0
   619
#    else
sl@0
   620
  CPPUNIT_CHECK( sizeof(streamoff) == sizeof(off_t) );
sl@0
   621
#    endif
sl@0
   622
}
sl@0
   623
#  endif
sl@0
   624
sl@0
   625
#endif
sl@0
   626
void FstreamTest::fstream_cov1()
sl@0
   627
	{
sl@0
   628
	__UHEAP_MARK;
sl@0
   629
		{
sl@0
   630
		ofstream ofs;
sl@0
   631
		int x = 0;
sl@0
   632
		char buf[12];
sl@0
   633
		if (!ofs.bad())
sl@0
   634
		    {
sl@0
   635
		    ofs.open("c:\\test_cpp.txt",ios::out);
sl@0
   636
		    ofs << "example";
sl@0
   637
		    x = 1;    
sl@0
   638
		    ofs.close();
sl@0
   639
		    }
sl@0
   640
		CPPUNIT_ASSERT( x == 1 );
sl@0
   641
		
sl@0
   642
		ifstream ifs;
sl@0
   643
		x = 0;
sl@0
   644
		if (!ifs.bad())
sl@0
   645
		    {
sl@0
   646
		    ifs.open("c:\\test_cpp.txt",ios::in);
sl@0
   647
		    ifs >> buf; 
sl@0
   648
		    x = 1;    
sl@0
   649
		    ifs.close();
sl@0
   650
		    }
sl@0
   651
		CPPUNIT_ASSERT( x == 1 );
sl@0
   652
		CPPUNIT_ASSERT( !strcmp(buf,"example"));
sl@0
   653
		}
sl@0
   654
		{
sl@0
   655
		fstream fs;
sl@0
   656
		int x = 0;
sl@0
   657
sl@0
   658
		if (!fs.bad())
sl@0
   659
		    {
sl@0
   660
		    fs.open("c:\\test_cpp1.txt",ios::out);
sl@0
   661
		    fs << "example";
sl@0
   662
		    x = 1;    
sl@0
   663
		    fs.close();
sl@0
   664
		    }
sl@0
   665
		CPPUNIT_ASSERT( x == 1 );
sl@0
   666
		}
sl@0
   667
		__UHEAP_MARKEND;
sl@0
   668
	}
sl@0
   669
void FstreamTest::fstream_cov2()
sl@0
   670
	{
sl@0
   671
	__UHEAP_MARK;
sl@0
   672
		{/*
sl@0
   673
		ofstream ofs;
sl@0
   674
		int x = 0;
sl@0
   675
		char buf[12];
sl@0
   676
		if (!ofs.bad())
sl@0
   677
		    {
sl@0
   678
		    ofs.open("c:\\test_cpp.txt",ios::out,(long)0666);
sl@0
   679
		    ofs << "example";
sl@0
   680
		    x = 1;    
sl@0
   681
		    ofs.close();
sl@0
   682
		    }
sl@0
   683
		CPPUNIT_ASSERT( x == 1 );
sl@0
   684
		
sl@0
   685
		ifstream ifs;
sl@0
   686
		x = 0;
sl@0
   687
		if (!ifs.bad())
sl@0
   688
		    {
sl@0
   689
		    ifs.open("c:\\test_cpp.txt",ios::in,0666);
sl@0
   690
		    ifs >> buf; 
sl@0
   691
		    x = 1;    
sl@0
   692
		    ifs.close();
sl@0
   693
		    }
sl@0
   694
		CPPUNIT_ASSERT( x == 1 );
sl@0
   695
		CPPUNIT_ASSERT( !strcmp(buf,"example"));*/
sl@0
   696
		}
sl@0
   697
		{/*
sl@0
   698
		fstream fs;
sl@0
   699
		int x = 0;
sl@0
   700
		char buf[12];
sl@0
   701
		if (!fs.bad())
sl@0
   702
		    {
sl@0
   703
		    fs.open("c:\\test_cpp.txt",ios::in | ios::out,(long)0666);
sl@0
   704
		    fs << "example";
sl@0
   705
		    fs >> buf; 
sl@0
   706
		    x = 1;    
sl@0
   707
		    fs.close();
sl@0
   708
		    }
sl@0
   709
		CPPUNIT_ASSERT( x == 1 );
sl@0
   710
		CPPUNIT_ASSERT( !strcmp(buf,"example"));*/
sl@0
   711
		}
sl@0
   712
		__UHEAP_MARKEND;
sl@0
   713
	}
sl@0
   714
void FstreamTest::fstream_cov3()
sl@0
   715
	{
sl@0
   716
	__UHEAP_MARK;
sl@0
   717
		{
sl@0
   718
		long pos;
sl@0
   719
		char buf[20];
sl@0
   720
		ofstream outfile;
sl@0
   721
		outfile.open ("c:\\test_cpp12.txt");
sl@0
   722
		outfile.write ("Thisisanapple",14);
sl@0
   723
		pos=outfile.tellp();
sl@0
   724
		outfile.seekp (pos-7);
sl@0
   725
		outfile.write ("sam",3);
sl@0
   726
  		outfile.flush();
sl@0
   727
		outfile.close();
sl@0
   728
	
sl@0
   729
		ifstream ifs;
sl@0
   730
		if (!ifs.bad())
sl@0
   731
		    {
sl@0
   732
		    ifs.open("c:\\test_cpp12.txt",ios::in);
sl@0
   733
		    ifs >> buf; 
sl@0
   734
		    ifs.close();
sl@0
   735
		    }
sl@0
   736
		
sl@0
   737
		CPPUNIT_ASSERT( !strcmp(buf,"Thisisasample"));
sl@0
   738
		}
sl@0
   739
		{
sl@0
   740
		long pos;
sl@0
   741
		ofstream outfile;
sl@0
   742
		outfile.open ("c:\\test_cpp12.txt");
sl@0
   743
		outfile.write ("Thisisanapple",14);
sl@0
   744
		pos=outfile.tellp();
sl@0
   745
		// seekp beyond the file
sl@0
   746
		outfile.seekp (pos - (pos + 1) );
sl@0
   747
		CPPUNIT_ASSERT( ios::failbit );
sl@0
   748
  		outfile.flush();
sl@0
   749
		outfile.close();			
sl@0
   750
		}
sl@0
   751
		{
sl@0
   752
		ofstream ofs;
sl@0
   753
		int x = 0;
sl@0
   754
		if (!ofs.bad())
sl@0
   755
		    {
sl@0
   756
		    ofs.open("c:\\test_cpp.txt",ios::out);
sl@0
   757
		    ofs << "testing";
sl@0
   758
		    x = 1;    
sl@0
   759
		    ofs.close();
sl@0
   760
		    }
sl@0
   761
		CPPUNIT_ASSERT( x == 1 );
sl@0
   762
		ifstream myfile( "c:\\test_cpp.txt", ios::in );
sl@0
   763
sl@0
   764
		myfile.rdbuf( )->stossc( );
sl@0
   765
		char i = myfile.rdbuf( )->sgetc( );
sl@0
   766
		CPPUNIT_ASSERT( i == 'e' );
sl@0
   767
		}
sl@0
   768
		{
sl@0
   769
		ofstream ofs;
sl@0
   770
		int x = 0;
sl@0
   771
		if (!ofs.bad())
sl@0
   772
		    {
sl@0
   773
		    ofs.open("c:\\test_cpp.txt",ios::out);
sl@0
   774
		    ofs << "testing";
sl@0
   775
		    x = 1;    
sl@0
   776
		    ofs.close();
sl@0
   777
		    }
sl@0
   778
		CPPUNIT_ASSERT( x == 1 );
sl@0
   779
		ifstream myfile( "c:\\test_cpp.txt", ios::in );
sl@0
   780
sl@0
   781
		int i;
sl@0
   782
		i = myfile.rdbuf( )->sbumpc( );
sl@0
   783
		CPPUNIT_ASSERT( (char)i == 't' );
sl@0
   784
		i = myfile.rdbuf( )->sbumpc( );
sl@0
   785
		CPPUNIT_ASSERT( (char)i == 'e' );
sl@0
   786
		i = myfile.rdbuf( )->sungetc( );
sl@0
   787
		CPPUNIT_ASSERT( (char)i == 'e' );
sl@0
   788
		i = myfile.rdbuf( )->sungetc( ); 
sl@0
   789
		CPPUNIT_ASSERT( (char)i == 't' );
sl@0
   790
		i = myfile.rdbuf( )->sbumpc( );
sl@0
   791
		CPPUNIT_ASSERT( (char)i == 't' );
sl@0
   792
		i = myfile.rdbuf( )->sbumpc( );
sl@0
   793
		i = myfile.rdbuf( )->sbumpc( );
sl@0
   794
		i = myfile.rdbuf( )->sbumpc( );
sl@0
   795
		i = myfile.rdbuf( )->sbumpc( );
sl@0
   796
		i = myfile.rdbuf( )->sbumpc( );
sl@0
   797
		i = myfile.rdbuf( )->sbumpc( );
sl@0
   798
		i = myfile.rdbuf( )->sbumpc( );
sl@0
   799
		i = myfile.rdbuf( )->sbumpc( );
sl@0
   800
		//CPPUNIT_ASSERT(myfile.eof());
sl@0
   801
		}
sl@0
   802
		__UHEAP_MARKEND;
sl@0
   803
	}
sl@0
   804
void FstreamTest::fstream_cov4()
sl@0
   805
	{
sl@0
   806
	__UHEAP_MARK;
sl@0
   807
		{
sl@0
   808
		ofstream ofs;
sl@0
   809
		int x = 0;
sl@0
   810
		if (!ofs.bad())
sl@0
   811
		    {
sl@0
   812
		    ofs.open("c:\\test_cpp.txt",ios::out);
sl@0
   813
		    ofs << "testing";
sl@0
   814
		    x = 1;    
sl@0
   815
		    ofs.close();
sl@0
   816
		    }
sl@0
   817
		CPPUNIT_ASSERT( x == 1 );
sl@0
   818
		ifstream myfile( "c:\\test_cpp.txt", ios::in );
sl@0
   819
sl@0
   820
		int i;
sl@0
   821
		i = myfile.rdbuf( )->snextc( );
sl@0
   822
		CPPUNIT_ASSERT( (char)i == 'e' );
sl@0
   823
		}
sl@0
   824
		{
sl@0
   825
		ofstream ofs;
sl@0
   826
		int x = 0;
sl@0
   827
		char c[10];
sl@0
   828
		if (!ofs.bad())
sl@0
   829
		    {
sl@0
   830
		    ofs.open("c:\\test_cpp.txt",ios::out);
sl@0
   831
		    ofs << "testing";
sl@0
   832
		    x = 1;    
sl@0
   833
		    ofs.close();
sl@0
   834
		    }
sl@0
   835
		CPPUNIT_ASSERT( x == 1 );
sl@0
   836
		ifstream myfile( "c:\\test_cpp.txt", ios::in );
sl@0
   837
sl@0
   838
		int i;
sl@0
   839
		i = myfile.rdbuf( )->in_avail( );
sl@0
   840
		CPPUNIT_ASSERT( i == 7 );
sl@0
   841
		myfile.readsome(&c[0],5);
sl@0
   842
		c[5]='\0';
sl@0
   843
		CPPUNIT_ASSERT( !strcmp(c,"testi") );
sl@0
   844
		}
sl@0
   845
		{
sl@0
   846
		ofstream ofs;
sl@0
   847
		char c;
sl@0
   848
		if (!ofs.bad())
sl@0
   849
		    {
sl@0
   850
		    ofs.open("c:\\test_cpp.txt",ios::out);
sl@0
   851
		    ofs << "9876543210";
sl@0
   852
		    ofs.close();
sl@0
   853
		    }
sl@0
   854
		int pos1;
sl@0
   855
		ifstream file;
sl@0
   856
sl@0
   857
		file.open( "c:\\test_cpp.txt" );
sl@0
   858
		if (!file.good())
sl@0
   859
			CPPUNIT_ASSERT( 0 );
sl@0
   860
		file.seekg( 0 );   // Goes to a zero-based position in the file
sl@0
   861
		pos1 = file.tellg( );
sl@0
   862
		CPPUNIT_ASSERT( pos1 == 0 );
sl@0
   863
		file.get( c);
sl@0
   864
		CPPUNIT_ASSERT( c == '9' );
sl@0
   865
		CPPUNIT_ASSERT( (int)file.tellg( ) == 1 );
sl@0
   866
		pos1 += 1;
sl@0
   867
 	    file.get( c );
sl@0
   868
 	    CPPUNIT_ASSERT( c == '8' );
sl@0
   869
		CPPUNIT_ASSERT( (int)file.tellg( ) == 2 );
sl@0
   870
 	    pos1 -= 1;
sl@0
   871
 	    file.seekg( pos1 );
sl@0
   872
 	    file.get( c );
sl@0
   873
 	    CPPUNIT_ASSERT( c == '9' );
sl@0
   874
		CPPUNIT_ASSERT( (int)file.tellg( ) == 1 );
sl@0
   875
 	    file.seekg( pos1+2 );
sl@0
   876
	    file.get( c );
sl@0
   877
	    CPPUNIT_ASSERT( c == '7' );
sl@0
   878
		CPPUNIT_ASSERT( (int)file.tellg( ) == 3 );
sl@0
   879
		}
sl@0
   880
		__UHEAP_MARKEND;
sl@0
   881
	}
sl@0
   882
void FstreamTest::fstream_cov5()
sl@0
   883
	{
sl@0
   884
	__UHEAP_MARK;
sl@0
   885
		{
sl@0
   886
		ofstream ofs;
sl@0
   887
		int x = 0;
sl@0
   888
		char c;
sl@0
   889
		if (!ofs.bad())
sl@0
   890
		    {
sl@0
   891
		    ofs.open("c:\\test_cpp.txt",ios::out);
sl@0
   892
		    ofs << "0123456789";
sl@0
   893
		    x = 1;    
sl@0
   894
		    ofs.close();
sl@0
   895
		    }
sl@0
   896
		CPPUNIT_ASSERT( x == 1 );
sl@0
   897
		ifstream file;
sl@0
   898
		file.open( "c:\\test_cpp.txt" );
sl@0
   899
		file.seekg(2);
sl@0
   900
		file >> c;
sl@0
   901
	    CPPUNIT_ASSERT( c == '2' );
sl@0
   902
	    file.seekg( 0,ios_base::beg);
sl@0
   903
	    file >> c;
sl@0
   904
		CPPUNIT_ASSERT( c == '0' );
sl@0
   905
		file.seekg( -1, ios_base::end );
sl@0
   906
	    file >> c;
sl@0
   907
        CPPUNIT_ASSERT( c == '9' );
sl@0
   908
		}
sl@0
   909
		{
sl@0
   910
		ofstream ofs;
sl@0
   911
		int x = 0;
sl@0
   912
sl@0
   913
		if (!ofs.bad())
sl@0
   914
		    {
sl@0
   915
		    ofs.open("c:\\test_cpp.txt",ios::out);
sl@0
   916
		    ofs << "example";
sl@0
   917
		    x = 1;    
sl@0
   918
		    ofs.close();
sl@0
   919
		    }
sl@0
   920
		CPPUNIT_ASSERT( x == 1 );
sl@0
   921
		
sl@0
   922
		ifstream ifs;
sl@0
   923
		x = 0;
sl@0
   924
		if (!ifs.bad())
sl@0
   925
		    {
sl@0
   926
		    ifs.open("c:\\test_cpp.txt");
sl@0
   927
		    ostringstream os;
sl@0
   928
		    ifs.get( *os.rdbuf());
sl@0
   929
		    x = 1;    
sl@0
   930
		    ifs.close();
sl@0
   931
		    }
sl@0
   932
		CPPUNIT_ASSERT( x == 1 );
sl@0
   933
		}
sl@0
   934
		{
sl@0
   935
		ofstream ofs;
sl@0
   936
		int x = 0;
sl@0
   937
sl@0
   938
		if (!ofs.bad())
sl@0
   939
		    {
sl@0
   940
		    ofs.open("c:\\test_cpp.txt",ios::out);
sl@0
   941
		    ofs << "testing";
sl@0
   942
		    x = 1;    
sl@0
   943
		    ofs.close();
sl@0
   944
		    }
sl@0
   945
		CPPUNIT_ASSERT( x == 1 );
sl@0
   946
		
sl@0
   947
		ifstream myfile("c:\\test_cpp.txt", ios::in);
sl@0
   948
	    char a[15];
sl@0
   949
sl@0
   950
	    streamsize i = myfile.rdbuf()->sgetn(a, 3);  
sl@0
   951
	    CPPUNIT_ASSERT( i == 3 );
sl@0
   952
	    a[i] = myfile.widen('\0');
sl@0
   953
	    CPPUNIT_ASSERT( !strcmp(a,"tes") );
sl@0
   954
		}
sl@0
   955
		{
sl@0
   956
		ofstream ofs;
sl@0
   957
		int x = 0;
sl@0
   958
		char buf[20];
sl@0
   959
		if (!ofs.bad())
sl@0
   960
		    {
sl@0
   961
		    ofs.open("c:\\test_cpp.txt",ios::out);
sl@0
   962
		    ofs << "stdndardcpp";
sl@0
   963
		    x = 1;
sl@0
   964
		    ofs.seekp(2);
sl@0
   965
		    ofs << "a";
sl@0
   966
		    ofs.seekp(0,ios::end);
sl@0
   967
		    ofs << "onpips";
sl@0
   968
		    ofs.close();
sl@0
   969
		    }
sl@0
   970
		CPPUNIT_ASSERT( x == 1 );
sl@0
   971
		ifstream ifs;
sl@0
   972
		if (!ifs.bad())
sl@0
   973
		    {
sl@0
   974
		    ifs.open("c:\\test_cpp.txt",ios::in);
sl@0
   975
		    ifs >> buf; 
sl@0
   976
		    ifs.close();
sl@0
   977
		    }
sl@0
   978
		
sl@0
   979
		CPPUNIT_ASSERT( !strcmp(buf,"standardcpponpips"));
sl@0
   980
		}
sl@0
   981
		__UHEAP_MARKEND;
sl@0
   982
	}