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_istream/] [ignore/] [char/] [3.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 2004-06-20  Paolo Carlini  <pcarlini@suse.de>
2
 
3
// Copyright (C) 2004 Free Software Foundation
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 2, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING.  If not, write to the Free
18
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
// USA.
20
 
21
// 27.6.1.3 unformatted input functions
22
// @require@ %-*.tst %-*.txt
23
// @diff@ %-*.tst %-*.txt
24
 
25
#include <istream>
26
#include <fstream>
27
#include <limits>
28
#include <testsuite_hooks.h>
29
 
30
// istream& ignore(streamsize n)
31
void
32
test01()
33
{
34
  using namespace std;
35
  bool test __attribute__((unused)) = true;
36
 
37
  const char filename[] ="istream_unformatted-1.txt";
38
  ios_base::iostate state1, state2;
39
 
40
  ifstream ifstrm;
41
  ifstrm.open(filename);
42
 
43
  state1 = ifstrm.rdstate();
44
  VERIFY( state1 == ios_base::goodbit );
45
  VERIFY( ifstrm.peek() == '1' );
46
  state2 = ifstrm.rdstate();
47
  VERIFY( state1 == state2 );
48
 
49
  state1 = ifstrm.rdstate();
50
  ifstrm.ignore(1);
51
  VERIFY( ifstrm.gcount() == 1 );
52
  state2 = ifstrm.rdstate();
53
  VERIFY( state1 == state2 );
54
  VERIFY( ifstrm.peek() == '2' );
55
 
56
  state1 = ifstrm.rdstate();
57
  ifstrm.ignore(10);
58
  VERIFY( ifstrm.gcount() == 10 );
59
  state2 = ifstrm.rdstate();
60
  VERIFY( state1 == state2 );
61
  VERIFY( ifstrm.peek() == '1' );
62
 
63
  state1 = ifstrm.rdstate();
64
  ifstrm.ignore(100);
65
  VERIFY( ifstrm.gcount() == 100 );
66
  state2 = ifstrm.rdstate();
67
  VERIFY( state1 == state2 );
68
  VERIFY( ifstrm.peek() == '2' );
69
 
70
  state1 = ifstrm.rdstate();
71
  ifstrm.ignore(1000);
72
  VERIFY( ifstrm.gcount() == 1000 );
73
  state2 = ifstrm.rdstate();
74
  VERIFY( state1 == state2 );
75
  VERIFY( ifstrm.peek() == '1' );
76
 
77
  state1 = ifstrm.rdstate();
78
  ifstrm.ignore(10000);
79
  VERIFY( ifstrm.gcount() == 10000 );
80
  state2 = ifstrm.rdstate();
81
  VERIFY( state1 == state2 );
82
  VERIFY( ifstrm.peek() == '2' );
83
 
84
  state1 = ifstrm.rdstate();
85
  ifstrm.ignore(numeric_limits<streamsize>::max());
86
  VERIFY( ifstrm.gcount() == 5389 );
87
  state2 = ifstrm.rdstate();
88
  VERIFY( state1 != state2 );
89
  VERIFY( state2 == ios_base::eofbit );
90
}
91
 
92
int
93
main()
94
{
95
  test01();
96
  return 0;
97
}

powered by: WebSVN 2.1.0

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