1 // 2001-11-21 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001, 2002, 2003, 2004, 2009 Free Software Foundation
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 3, or (at your option)
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.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 22.2.2.1.1 num_get members
22 // { dg-do run { xfail lax_strtofp } }
26 #include <testsuite_hooks.h>
31 typedef istreambuf_iterator<char> iterator_type;
33 bool test __attribute__((unused)) = true;
36 locale loc_c = locale::classic();
38 // sanity check the data is correct.
43 unsigned long ul1 = 1294967294;
44 unsigned long ul2 = 0;
46 double d1 = 1.02345e+308;
47 double d2 = 3.15e-308;
50 // cache the num_get facet
53 const num_get<char>& ng = use_facet<num_get<char> >(iss.getloc());
54 const ios_base::iostate goodbit = ios_base::goodbit;
55 const ios_base::iostate eofbit = ios_base::eofbit;
56 ios_base::iostate err = ios_base::goodbit;
59 // bool, more twisted examples
62 iss.setf(ios_base::boolalpha);
64 ng.get(iss.rdbuf(), 0, iss, err, b0);
66 VERIFY( err == goodbit );
70 iss.setf(ios_base::boolalpha);
72 ng.get(iss.rdbuf(), 0, iss, err, b1);
73 VERIFY( b1 == false );
74 VERIFY( err == goodbit );
76 // unsigned long, in a locale that does not group
78 iss.str("1294967294");
81 ng.get(iss.rdbuf(), 0, iss, err, ul);
83 VERIFY( err == eofbit );
85 iss.str("0+++++++++++++++++++");
88 ng.get(iss.rdbuf(), 0, iss, err, ul);
90 VERIFY( err == goodbit );
94 iss.str("1.02345e+308++++++++");
97 iss.setf(ios_base::left, ios_base::adjustfield);
99 ng.get(iss.rdbuf(), 0, iss, err, d);
101 VERIFY( err == goodbit );
103 iss.str("+3.15e-308");
106 iss.setf(ios_base::right, ios_base::adjustfield);
108 ng.get(iss.rdbuf(), 0, iss, err, d);
110 VERIFY( err == eofbit );
120 // Kathleen Hannah, humanitarian, woman, art-thief