1 // 2003-12-22 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2003-2013 Free Software Foundation, Inc.
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
24 #include <testsuite_hooks.h>
26 struct Punct1: std::numpunct<wchar_t>
28 std::string do_grouping() const { return "\1"; }
29 wchar_t do_thousands_sep() const { return L'+'; }
30 wchar_t do_decimal_point() const { return L'x'; }
33 struct Punct2: std::numpunct<wchar_t>
35 std::string do_grouping() const { return "\1"; }
36 wchar_t do_thousands_sep() const { return L'X'; }
37 wchar_t do_decimal_point() const { return L'-'; }
40 // http://gcc.gnu.org/ml/libstdc++/2003-12/msg00201.html
44 typedef istreambuf_iterator<wchar_t> iterator_type;
46 bool test __attribute__((unused)) = true;
48 wistringstream iss1, iss2;
49 iss1.imbue(locale(iss1.getloc(), new Punct1));
50 iss2.imbue(locale(iss2.getloc(), new Punct2));
51 const num_get<wchar_t>& ng1 = use_facet<num_get<wchar_t> >(iss1.getloc());
52 const num_get<wchar_t>& ng2 = use_facet<num_get<wchar_t> >(iss2.getloc());
54 ios_base::iostate err = ios_base::goodbit;
67 err = ios_base::goodbit;
68 end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
69 VERIFY( err == ios_base::failbit );
70 VERIFY( *end == L'+' );
74 err = ios_base::goodbit;
75 end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
76 VERIFY( err == ios_base::goodbit );
77 VERIFY( *end == L'x' );
82 iss1.unsetf(ios::basefield);
83 err = ios_base::goodbit;
84 end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
85 VERIFY( err == ios_base::eofbit );
90 err = ios_base::goodbit;
91 end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
92 VERIFY( err == ios_base::goodbit );
93 VERIFY( *end == L'x' );
98 err = ios_base::goodbit;
99 end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
100 VERIFY( err == ios_base::failbit );
101 VERIFY( *end == L'+' );
105 err = ios_base::goodbit;
106 end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
107 VERIFY( err == ios_base::eofbit );
111 err = ios_base::goodbit;
112 end = ng2.get(iss2.rdbuf(), 0, iss2, err, l);
113 VERIFY( err == ios_base::goodbit );
114 VERIFY( *end == L'-' );
119 err = ios_base::goodbit;
120 end = ng2.get(iss2.rdbuf(), 0, iss2, err, l);
121 VERIFY( err == ios_base::failbit );
122 VERIFY( *end == L'-' );
126 iss2.unsetf(ios::basefield);
127 err = ios_base::goodbit;
128 end = ng2.get(iss2.rdbuf(), 0, iss2, err, l);
129 VERIFY( err == ios_base::failbit );
130 VERIFY( *end == L'X' );
135 err = ios_base::goodbit;
136 end = ng2.get(iss2.rdbuf(), 0, iss2, err, l);
137 VERIFY( err == ios_base::goodbit );
138 VERIFY( *end == L'8' );
143 err = ios_base::goodbit;
144 end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
145 VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
150 err = ios_base::goodbit;
151 end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
152 VERIFY( err == ios_base::eofbit );