1 // 2003-12-22 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 // Free Software Foundation
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // 22.2.2.1.1 num_get members
25 #include <testsuite_hooks.h>
27 struct Punct1
: std::numpunct
<wchar_t>
29 std::string
do_grouping() const { return "\1"; }
30 wchar_t do_thousands_sep() const { return L
'+'; }
31 wchar_t do_decimal_point() const { return L
'x'; }
34 struct Punct2
: std::numpunct
<wchar_t>
36 std::string
do_grouping() const { return "\1"; }
37 wchar_t do_thousands_sep() const { return L
'X'; }
38 wchar_t do_decimal_point() const { return L
'-'; }
41 // http://gcc.gnu.org/ml/libstdc++/2003-12/msg00201.html
45 typedef istreambuf_iterator
<wchar_t> iterator_type
;
47 bool test
__attribute__((unused
)) = true;
49 wistringstream iss1
, iss2
;
50 iss1
.imbue(locale(iss1
.getloc(), new Punct1
));
51 iss2
.imbue(locale(iss2
.getloc(), new Punct2
));
52 const num_get
<wchar_t>& ng1
= use_facet
<num_get
<wchar_t> >(iss1
.getloc());
53 const num_get
<wchar_t>& ng2
= use_facet
<num_get
<wchar_t> >(iss2
.getloc());
55 ios_base::iostate err
= ios_base::goodbit
;
68 err
= ios_base::goodbit
;
69 end
= ng1
.get(iss1
.rdbuf(), 0, iss1
, err
, l
);
70 VERIFY( err
== ios_base::failbit
);
71 VERIFY( *end
== L
'+' );
75 err
= ios_base::goodbit
;
76 end
= ng1
.get(iss1
.rdbuf(), 0, iss1
, err
, l
);
77 VERIFY( err
== ios_base::goodbit
);
78 VERIFY( *end
== L
'x' );
83 iss1
.unsetf(ios::basefield
);
84 err
= ios_base::goodbit
;
85 end
= ng1
.get(iss1
.rdbuf(), 0, iss1
, err
, l
);
86 VERIFY( err
== ios_base::eofbit
);
91 err
= ios_base::goodbit
;
92 end
= ng1
.get(iss1
.rdbuf(), 0, iss1
, err
, l
);
93 VERIFY( err
== ios_base::goodbit
);
94 VERIFY( *end
== L
'x' );
99 err
= ios_base::goodbit
;
100 end
= ng1
.get(iss1
.rdbuf(), 0, iss1
, err
, d
);
101 VERIFY( err
== ios_base::failbit
);
102 VERIFY( *end
== L
'+' );
106 err
= ios_base::goodbit
;
107 end
= ng1
.get(iss1
.rdbuf(), 0, iss1
, err
, d
);
108 VERIFY( err
== ios_base::eofbit
);
112 err
= ios_base::goodbit
;
113 end
= ng2
.get(iss2
.rdbuf(), 0, iss2
, err
, l
);
114 VERIFY( err
== ios_base::goodbit
);
115 VERIFY( *end
== L
'-' );
120 err
= ios_base::goodbit
;
121 end
= ng2
.get(iss2
.rdbuf(), 0, iss2
, err
, l
);
122 VERIFY( err
== ios_base::failbit
);
123 VERIFY( *end
== L
'-' );
127 iss2
.unsetf(ios::basefield
);
128 err
= ios_base::goodbit
;
129 end
= ng2
.get(iss2
.rdbuf(), 0, iss2
, err
, l
);
130 VERIFY( err
== ios_base::failbit
);
131 VERIFY( *end
== L
'X' );
136 err
= ios_base::goodbit
;
137 end
= ng2
.get(iss2
.rdbuf(), 0, iss2
, err
, l
);
138 VERIFY( err
== ios_base::goodbit
);
139 VERIFY( *end
== L
'8' );
144 err
= ios_base::goodbit
;
145 end
= ng2
.get(iss2
.rdbuf(), 0, iss2
, err
, d
);
146 VERIFY( err
== (ios_base::eofbit
| ios_base::failbit
) );
151 err
= ios_base::goodbit
;
152 end
= ng2
.get(iss2
.rdbuf(), 0, iss2
, err
, d
);
153 VERIFY( err
== ios_base::eofbit
);