1 // Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 2, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING. If not, write to the Free
16 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // 27.6.1.2.2 arithmetic extractors
24 #include <testsuite_hooks.h>
27 class test_numpunct1
: public numpunct
<wchar_t>
32 { return string(1, '\003'); }
38 // manufactured locale, grouping is turned on
39 bool test
__attribute__((unused
)) = true;
40 unsigned int h4
= 0, h3
= 0, h2
= 0;
42 const std::wstring
s1(L
"205,199 23,445.25 1,024,365 123,22,24");
43 std::wistringstream
is(s1
);
44 is
.imbue(std::locale(std::locale(), new std::test_numpunct1
));
48 VERIFY( h4
== 205199 );
53 VERIFY( f1
== 23445.25 );
58 VERIFY( h3
== 1024365 );
63 VERIFY( h2
== 1232224 );
64 VERIFY( static_cast<bool>(is
.rdstate() & std::ios_base::failbit
) );
65 VERIFY( static_cast<bool>(is
.rdstate() & std::ios_base::eofbit
) );
67 // Stress tests for explicit errors in grouping corner cases. The
68 // validity of these tests and results have been hammered out in
69 // private email between bkoz and ncm between Jan 25 and Jan 27, 2000.
70 // Thanks nate -- benjamin
71 const std::wstring
s2(L
",111 4,,4 0.25,345 5..25 156,, 1,000000 1000000 1234,567");
74 const wchar_t c_control
= L
'?';
75 wchar_t c
= c_control
;
81 VERIFY( static_cast<bool>(is
.rdstate() & std::ios_base::failbit
) );
90 VERIFY( static_cast<bool>(is
.rdstate() & std::ios_base::failbit
) );
118 VERIFY( static_cast<bool>(is
.rdstate() & std::ios_base::failbit
) );
121 VERIFY( c
== L
',' ); // second one
125 VERIFY( h2
== 1000000 );
126 VERIFY( static_cast<bool>(is
.rdstate() & std::ios_base::failbit
) );
131 VERIFY( h2
== 1000000 );
136 VERIFY( h2
== 1234567 );
137 VERIFY( static_cast<bool>(is
.rdstate() & std::ios_base::failbit
) );
138 VERIFY( static_cast<bool>(is
.rdstate() & std::ios_base::eofbit
) );