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/] [extractors_character/] [char/] [2.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 1999-07-26 bkoz
2
 
3
// Copyright (C) 1999, 2003 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.2.3 character extractors
22
 
23
#include <istream>
24
#include <sstream>
25
#include <testsuite_hooks.h>
26
 
27
void test02()
28
{
29
  typedef std::ios::traits_type ctraits_type;
30
 
31
  bool test __attribute__((unused)) = true;
32
  std::string str_01;
33
  const std::string str_02("or coltrane playing tunji with jimmy garrison");
34
  const std::string str_03("coltrane");
35
 
36
  std::stringbuf isbuf_01(std::ios_base::in);
37
  std::stringbuf isbuf_02(str_02, std::ios_base::in);
38
  std::istream is_01(NULL);
39
  std::istream is_02(&isbuf_02);
40
  std::ios_base::iostate state1, state2, statefail;
41
  statefail = std::ios_base::failbit;
42
 
43
  // template<_CharT, _Traits>
44
  //  basic_istream& operator>>(istream&, _CharT&)
45
  char c1 = 'c', c2 = 'c';
46
  state1 = is_01.rdstate();
47
  is_01 >> c1;
48
  state2 = is_01.rdstate();
49
  VERIFY( state1 != state2 );
50
  VERIFY( c1 == c2 );
51
  VERIFY( static_cast<bool>(state2 & statefail) );
52
 
53
  state1 = is_02.rdstate();
54
  is_02 >> c1;
55
  state2 = is_02.rdstate();
56
  VERIFY( state1 == state2 );
57
  VERIFY( c1 == 'o' );
58
  is_02 >> c1;
59
  is_02 >> c1;
60
  VERIFY( c1 == 'c' );
61
  VERIFY( !static_cast<bool>(state2 & statefail) );
62
 
63
  // template<_CharT, _Traits>
64
  //  basic_istream& operator>>(istream&, unsigned char&)
65
  unsigned char uc1 = 'c';
66
  state1 = is_02.rdstate();
67
  is_02 >> uc1;
68
  state2 = is_02.rdstate();
69
  VERIFY( state1 == state2 );
70
  VERIFY( uc1 == 'o' );
71
  is_02 >> uc1;
72
  is_02 >> uc1;
73
  VERIFY( uc1 == 't' );
74
 
75
  // template<_CharT, _Traits>
76
  //  basic_istream& operator>>(istream&, signed char&)
77
  signed char sc1 = 'c';
78
  state1 = is_02.rdstate();
79
  is_02 >> sc1;
80
  state2 = is_02.rdstate();
81
  VERIFY( state1 == state2 );
82
  VERIFY( sc1 == 'r' );
83
  is_02 >> sc1;
84
  is_02 >> sc1;
85
  VERIFY( sc1 == 'n' );
86
}
87
 
88
int main()
89
{
90
  test02();
91
  return 0;
92
}

powered by: WebSVN 2.1.0

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