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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [22_locale/] [num_get/] [get/] [wchar_t/] [22131.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 2005-06-28  Paolo Carlini  <pcarlini@suse.de>
2
 
3
// Copyright (C) 2005 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
// 22.2.2.1.1  num_get members
22
 
23
#include <locale>
24
#include <sstream>
25
#include <testsuite_hooks.h>
26
 
27
struct Punct: std::numpunct<wchar_t>
28
{
29
  std::string do_grouping() const { return "\1"; }
30
  wchar_t do_thousands_sep() const { return L'#'; }
31
};
32
 
33
// libstdc++/22131
34
void test01()
35
{
36
  using namespace std;
37
  typedef istreambuf_iterator<wchar_t> iterator_type;
38
 
39
  bool test __attribute__((unused)) = true;
40
 
41
  wistringstream iss1, iss2;
42
  iss1.imbue(locale(iss1.getloc(), new Punct));
43
  const num_get<wchar_t>& ng1 = use_facet<num_get<wchar_t> >(iss1.getloc());
44
 
45
  ios_base::iostate err = ios_base::goodbit;
46
  iterator_type end;
47
  long l = 0l;
48
  long l1 = 1l;
49
  long l2 = 2l;
50
  long l3 = 3l;
51
  double d = 0.0;
52
  double d1 = 1.0;
53
  double d2 = 2.0;
54
 
55
  iss1.str(L"00#0#1");
56
  err = ios_base::goodbit;
57
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
58
  VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
59
  VERIFY( l == l1 );
60
 
61
  iss1.str(L"000##2");
62
  iss1.clear();
63
  err = ios_base::goodbit;
64
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
65
  VERIFY( err == ios_base::failbit );
66
  VERIFY( *end == L'#' );
67
  VERIFY( l == l1 );
68
 
69
  iss1.str(L"0#0#0#2");
70
  iss1.clear();
71
  err = ios_base::goodbit;
72
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
73
  VERIFY( err == ios_base::eofbit );
74
  VERIFY( l == l2 );
75
 
76
  iss1.str(L"00#0#1");
77
  iss1.clear();
78
  err = ios_base::goodbit;
79
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
80
  VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
81
  VERIFY( d == d1 );
82
 
83
  iss1.str(L"000##2");
84
  iss1.clear();
85
  err = ios_base::goodbit;
86
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
87
  VERIFY( err == ios_base::failbit );
88
  VERIFY( *end == L'#' );
89
  VERIFY( d == d1 );
90
 
91
  iss1.str(L"0#0#0#2");
92
  iss1.clear();
93
  err = ios_base::goodbit;
94
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
95
  VERIFY( err == ios_base::eofbit );
96
  VERIFY( d == d2 );
97
 
98
  iss1.str(L"0#0");
99
  iss1.clear();
100
  iss1.unsetf(ios::basefield);
101
  err = ios_base::goodbit;
102
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
103
  VERIFY( err == ios_base::failbit );
104
  VERIFY( *end == L'#' );
105
  VERIFY( l == l2 );
106
 
107
  iss1.str(L"00#0#3");
108
  iss1.clear();
109
  err = ios_base::goodbit;
110
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
111
  VERIFY( err == ios_base::eofbit );
112
  VERIFY( l == l3 );
113
 
114
  iss1.str(L"00#02");
115
  iss1.clear();
116
  err = ios_base::goodbit;
117
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
118
  VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
119
  VERIFY( l == l2 );
120
}
121
 
122
int main()
123
{
124
  test01();
125
  return 0;
126
}

powered by: WebSVN 2.1.0

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