]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/1.cc
1 // { dg-require-namedlocale "de_DE.ISO8859-15" }
3 // 2001-11-21 Benjamin Kosnik <bkoz@redhat.com>
5 // Copyright (C) 2001-2019 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
<wchar_t> 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
<wchar_t>& ng
= use_facet
<num_get
<wchar_t> >(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
74 iss
.str(L
"1.294.967.294+++++++");
77 iss
.setf(ios_base::left
, ios_base::adjustfield
);
79 ng
.get(iss
.rdbuf(), 0, iss
, err
, ul
);
81 VERIFY( err
== goodbit
);
83 iss
.str(L
"+1,02345e+308");
86 iss
.setf(ios_base::right
, ios_base::adjustfield
);
87 iss
.setf(ios_base::scientific
, ios_base::floatfield
);
89 ng
.get(iss
.rdbuf(), 0, iss
, err
, d
);
91 VERIFY( err
== eofbit
);
93 iss
.str(L
"3,15E-308 ");
97 iss
.setf(ios_base::right
, ios_base::adjustfield
);
98 iss
.setf(ios_base::scientific
, ios_base::floatfield
);
99 iss
.setf(ios_base::uppercase
);
101 ng
.get(iss
.rdbuf(), 0, iss
, err
, d
);
103 VERIFY( err
== goodbit
);
106 iss
.str(L
"6,630025e+4");
109 ng
.get(iss
.rdbuf(), 0, iss
, err
, ld
);
111 VERIFY( err
== eofbit
);
116 iss
.setf(ios_base::fixed
, ios_base::floatfield
);
118 ng
.get(iss
.rdbuf(), 0, iss
, err
, ld
);
120 VERIFY( err
== goodbit
);
123 iss
.str(L
"0xbffff74c,");
126 ng
.get(iss
.rdbuf(), 0, iss
, err
, v
);
128 VERIFY( err
== goodbit
);
130 #ifdef _GLIBCXX_USE_LONG_LONG
131 long long ll1
= 9223372036854775807LL;
134 iss
.str(L
"9.223.372.036.854.775.807");
137 ng
.get(iss
.rdbuf(), 0, iss
, err
, ll
);
139 VERIFY( err
== eofbit
);
150 // Kathleen Hannah, humanitarian, woman, art-thief