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_arithmetic/] [wchar_t/] [10.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// Copyright (C) 2004 Free Software Foundation, Inc.
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.1.2.2 arithmetic extractors
20
 
21
#include <istream>
22
#include <sstream>
23
#include <locale>
24
#include <testsuite_hooks.h>
25
 
26
bool test10()
27
{
28
  std::wstring str_01(L"0 00 000 +0 +0 -0");
29
  std::wstringbuf isbuf_01(str_01);
30
  std::wistream is_01(&isbuf_01);
31
 
32
  bool test __attribute__((unused)) = true;
33
 
34
  int n = 365;
35
  is_01 >> n;
36
  VERIFY( n == 0 );
37
  n = 364;
38
  is_01 >> n;
39
  VERIFY( n == 0 );
40
  n = 363;
41
  is_01 >> n;
42
  VERIFY( n == 0 );
43
  n = 362;
44
  is_01 >> n;
45
  VERIFY( n == 0 );
46
  n = 361;
47
  is_01 >> n;
48
  VERIFY( n == 0 );
49
  n = 360;
50
  is_01 >> n;
51
  VERIFY( n == 0 );
52
  VERIFY( is_01.rdstate() == std::ios_base::eofbit );
53
 
54
  std::wstring str_02(L"0x32 0X33 033 33");
55
  std::wstringbuf isbuf_02(str_02);
56
  std::wistream is_02(&isbuf_02);
57
  is_02.unsetf(std::ios_base::basefield);
58
  is_02 >> n;
59
  VERIFY( n == 50 );
60
  is_02 >> n;
61
  VERIFY( n == 51 );
62
  is_02 >> n;
63
  VERIFY( n == 27 );
64
  is_02 >> n;
65
  VERIFY( n == 33 );
66
  VERIFY( is_02.rdstate() == std::ios_base::eofbit );
67
 
68
  std::wstringbuf isbuf_03(str_02);
69
  std::wistream is_03(&isbuf_03);
70
  wchar_t c;
71
  int m;
72
 
73
  is_03 >> std::dec >> n >> c >> m;
74
  VERIFY( n == 0 );
75
  VERIFY( c == L'x' );
76
  VERIFY( m == 32 );
77
 
78
  is_03 >> std::oct >> m >> c >> n;
79
  VERIFY( m == 0 );
80
  VERIFY( c == L'X' );
81
  VERIFY( n == 27 );
82
 
83
  is_03 >> std::dec >> m >> n;
84
  VERIFY( m == 33 );
85
  VERIFY( n == 33 );
86
  VERIFY( is_03.rdstate() == std::ios_base::eofbit );
87
 
88
  std::wstring str_04(L"3. 4.5E+2a5E-3 .6E1");
89
  std::wstringbuf isbuf_04(str_04);
90
  std::wistream is_04(&isbuf_04);
91
 
92
  double f;
93
  is_04 >> f;
94
  VERIFY( f == 3.0 );
95
  is_04 >> f;
96
  VERIFY( f == 450.0 );
97
  is_04.ignore();
98
  is_04 >> f;
99
  VERIFY( f == 0.005 );
100
  is_04 >> f;
101
  VERIFY( f == 6 );
102
  VERIFY( is_03.rdstate() == std::ios_base::eofbit );
103
 
104
  std::wstring str_05(L"0E20 5Ea E16");
105
  std::wstringbuf isbuf_05(str_05);
106
  std::wistream is_05(&isbuf_05);
107
 
108
  is_05 >> f;
109
  VERIFY( f == 0 );
110
  is_05 >> f;
111
  VERIFY( f == 5.0 );
112
  VERIFY( is_05.rdstate() == std::ios_base::goodbit );
113
  is_05.clear();
114
  is_05 >> c;
115
  VERIFY( c == L'a' );
116
  is_05 >> f;
117
  VERIFY( f == 5.0 );
118
  VERIFY( is_05.rdstate() == std::ios_base::failbit );
119
  is_05.clear();
120
  is_05.ignore();
121
  is_05 >> n;
122
  VERIFY( n == 16 );
123
  return test;
124
}
125
 
126
int main()
127
{
128
  test10();
129
  return 0;
130
}

powered by: WebSVN 2.1.0

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