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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_ostream/] [seekp/] [wchar_t/] [2346-fstream.cc] - Blame information for rev 742

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// Copyright (C) 2005, 2006, 2007, 2009 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 3, 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 COPYING3.  If not see
16
// <http://www.gnu.org/licenses/>.
17
 
18
// { dg-require-fileio "" }
19
 
20
// 27.6.2.4  basic_ostream seek members  [lib.ostream.seeks]
21
// @require@ %-*.tst %-*.txt
22
// @diff@ %-*.tst %-*.txt
23
 
24
#include <ostream>
25
#include <istream>
26
#include <fstream>
27
#include <cstdlib>
28
#include <testsuite_hooks.h>
29
 
30
const wchar_t* s = L" lootpack, peanut butter wolf, rob swift, madlib, quasimoto";
31
const int times = 10;
32
 
33
void write_rewind(std::wiostream& stream)
34
{
35
  bool test __attribute__((unused)) = true;
36
 
37
  for (int j = 0; j < times; j++)
38
    {
39
      std::streampos begin = stream.tellp();
40
 
41
      for (int i = 0; i < times; ++i)
42
        stream << j << L'-' << i << s << L'\n';
43
 
44
      stream.seekp(begin);
45
    }
46
  VERIFY( stream.good() );
47
}
48
 
49
void check_contents(std::wiostream& stream)
50
{
51
  bool test __attribute__((unused)) = true;
52
 
53
  stream.clear();
54
  stream.seekg(0, std::wios::beg);
55
  int i = 0;
56
  int loop = times * times + 2;
57
  while (i < loop)
58
    {
59
      stream.ignore(80, L'\n');
60
      if (stream.good())
61
        ++i;
62
      else
63
        break;
64
    }
65
  VERIFY( i == times );
66
}
67
 
68
// fstream
69
// libstdc++/2346
70
void test02()
71
{
72
  std::wfstream ofstrm;
73
  ofstrm.open("wistream_seeks-3.txt", std::wios::out);
74
  if (!ofstrm)
75
    std::abort();
76
  write_rewind(ofstrm);
77
  ofstrm.close();
78
 
79
  std::wfstream ifstrm;
80
  ifstrm.open("wistream_seeks-3.txt", std::wios::in);
81
  check_contents(ifstrm);
82
  ifstrm.close();
83
}
84
 
85
int main()
86
{
87
  test02();
88
  return 0;
89
}

powered by: WebSVN 2.1.0

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