OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_ostream/] [seekp/] [wchar_t/] [2346-sstream.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// Copyright (C) 2005 Free Software Foundation
2
//
3
// This file is part of the GNU ISO C++ Library.  This library is free
4
// software; you can redistribute it and/or modify it under the
5
// terms of the GNU General Public License as published by the
6
// Free Software Foundation; either version 2, or (at your option)
7
// any later version.
8
 
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
 
14
// You should have received a copy of the GNU General Public License along
15
// with this library; see the file COPYING.  If not, write to the Free
16
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
// USA.
18
 
19
// 27.6.2.4  basic_ostream seek members  [lib.ostream.seeks]
20
 
21
#include <ostream>
22
#include <istream>
23
#include <sstream>
24
#include <testsuite_hooks.h>
25
 
26
const wchar_t* s = L" lootpack, peanut butter wolf, rob swift, madlib, quasimoto";
27
const int times = 10;
28
 
29
void write_rewind(std::wiostream& stream)
30
{
31
  bool test __attribute__((unused)) = true;
32
 
33
  for (int j = 0; j < times; j++)
34
    {
35
      std::streampos begin = stream.tellp();
36
 
37
      for (int i = 0; i < times; ++i)
38
        stream << j << L'-' << i << s << L'\n';
39
 
40
      stream.seekp(begin);
41
    }
42
  VERIFY( stream.good() );
43
}
44
 
45
void check_contents(std::wiostream& stream)
46
{
47
  bool test __attribute__((unused)) = true;
48
 
49
  stream.clear();
50
  stream.seekg(0, std::wios::beg);
51
  int i = 0;
52
  int loop = times * times + 2;
53
  while (i < loop)
54
    {
55
      stream.ignore(80, L'\n');
56
      if (stream.good())
57
        ++i;
58
      else
59
        break;
60
    }
61
  VERIFY( i == times );
62
}
63
 
64
// stringstream
65
// libstdc++/2346
66
// N.B. The original testcase was broken, using tellg/seekg in write_rewind.
67
void test03()
68
{
69
  std::wstringstream sstrm;
70
 
71
  write_rewind(sstrm);
72
  check_contents(sstrm);
73
}
74
 
75
int main()
76
{
77
  test03();
78
  return 0;
79
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.