1 // { dg-require-namedlocale "de_DE.ISO8859-15" }
3 // 2001-11-21 Benjamin Kosnik <bkoz@redhat.com>
5 // Copyright (C) 2001-2024 Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
22 // 22.2.2.1.1 num_get members
26 #include <testsuite_hooks.h>
31 typedef istreambuf_iterator
<char> iterator_type
;
34 locale loc_c
= locale::classic();
35 locale loc_de
= locale(ISO_8859(15,de_DE
));
36 VERIFY( loc_c
!= loc_de
);
38 // sanity check the data is correct.
43 unsigned long ul1
= 1294967294;
45 double d1
= 1.02345e+308;
46 double d2
= 3.15e-308;
48 long double ld1
= 6.630025e+4;
52 // cache the num_get facet
55 const num_get
<char>& ng
= use_facet
<num_get
<char> >(iss
.getloc());
56 const ios_base::iostate goodbit
= ios_base::goodbit
;
57 const ios_base::iostate eofbit
= ios_base::eofbit
;
58 ios_base::iostate err
= ios_base::goodbit
;
62 iterator_type os_it00
= iss
.rdbuf();
63 ng
.get(os_it00
, 0, iss
, err
, b1
);
65 VERIFY( err
& ios_base::eofbit
);
69 ng
.get(iss
.rdbuf(), 0, iss
, err
, b0
);
70 VERIFY( b0
== false );
71 VERIFY( err
& eofbit
);
73 // ... and one that does
75 iss
.str("1.294.967.294+++++++");
78 iss
.setf(ios_base::left
, ios_base::adjustfield
);
80 ng
.get(iss
.rdbuf(), 0, iss
, err
, ul
);
82 VERIFY( err
== goodbit
);
84 iss
.str("+1,02345e+308");
87 iss
.setf(ios_base::right
, ios_base::adjustfield
);
88 iss
.setf(ios_base::scientific
, ios_base::floatfield
);
90 ng
.get(iss
.rdbuf(), 0, iss
, err
, d
);
92 VERIFY( err
== eofbit
);
94 iss
.str("3,15E-308 ");
98 iss
.setf(ios_base::right
, ios_base::adjustfield
);
99 iss
.setf(ios_base::scientific
, ios_base::floatfield
);
100 iss
.setf(ios_base::uppercase
);
102 ng
.get(iss
.rdbuf(), 0, iss
, err
, d
);
104 VERIFY( err
== goodbit
);
107 iss
.str("6,630025e+4");
110 ng
.get(iss
.rdbuf(), 0, iss
, err
, ld
);
112 VERIFY( err
== eofbit
);
117 iss
.setf(ios_base::fixed
, ios_base::floatfield
);
119 ng
.get(iss
.rdbuf(), 0, iss
, err
, ld
);
121 VERIFY( err
== goodbit
);
124 iss
.str("0xbffff74c,");
127 ng
.get(iss
.rdbuf(), 0, iss
, err
, v
);
129 VERIFY( err
== goodbit
);
131 #ifdef _GLIBCXX_USE_LONG_LONG
132 long long ll1
= 9223372036854775807LL;
135 iss
.str("9.223.372.036.854.775.807");
138 ng
.get(iss
.rdbuf(), 0, iss
, err
, ll
);
140 VERIFY( err
== eofbit
);
151 // Kathleen Hannah, humanitarian, woman, art-thief