1 // { dg-require-namedlocale "" }
3 // 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation
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 2, 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 COPYING. If not, write to the Free
20 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 // 22.2.6.1.1 money_get members
27 #include <testsuite_hooks.h>
29 // test wstring version
33 typedef istreambuf_iterator
<wchar_t> iterator_type
;
35 bool test
__attribute__((unused
)) = true;
38 locale loc_c
= locale::classic();
39 locale loc_hk
= locale("en_HK");
40 VERIFY( loc_c
!= loc_hk
);
42 // total EPA budget FY 2002
43 const wstring
digits1(L
"720000000000");
45 // est. cost, national missile "defense", expressed as a loss in USD 2001
46 const wstring
digits2(L
"-10000000000000");
48 // input less than frac_digits
49 const wstring
digits4(L
"-1");
54 // cache the money_get facet
55 const money_get
<wchar_t>& mon_get
= use_facet
<money_get
<wchar_t> >(iss
.getloc());
57 // now try with showbase, to get currency symbol in format
58 iss
.setf(ios_base::showbase
);
60 iss
.str(L
"HK$7,200,000,000.00");
61 iterator_type
is_it09(iss
);
63 ios_base::iostate err09
= ios_base::goodbit
;
64 mon_get
.get(is_it09
, end
, false, iss
, err09
, result9
);
65 VERIFY( result9
== digits1
);
66 VERIFY( err09
== ios_base::eofbit
);
68 iss
.str(L
"(HKD 100,000,000,000.00)");
69 iterator_type
is_it10(iss
);
71 ios_base::iostate err10
= ios_base::goodbit
;
72 mon_get
.get(is_it10
, end
, true, iss
, err10
, result10
);
73 VERIFY( result10
== digits2
);
74 VERIFY( err10
== ios_base::eofbit
);
76 iss
.str(L
"(HKD .01)");
77 iterator_type
is_it11(iss
);
79 ios_base::iostate err11
= ios_base::goodbit
;
80 mon_get
.get(is_it11
, end
, true, iss
, err11
, result11
);
81 VERIFY( result11
== digits4
);
82 VERIFY( err11
== ios_base::eofbit
);
84 // for the "en_HK" locale the parsing of the very same input streams must
85 // be successful without showbase too, since the symbol field appears in
86 // the first positions in the format and the symbol, when present, must be
88 iss
.unsetf(ios_base::showbase
);
90 iss
.str(L
"HK$7,200,000,000.00");
91 iterator_type
is_it12(iss
);
93 ios_base::iostate err12
= ios_base::goodbit
;
94 mon_get
.get(is_it12
, end
, false, iss
, err12
, result12
);
95 VERIFY( result12
== digits1
);
96 VERIFY( err12
== ios_base::eofbit
);
98 iss
.str(L
"(HKD 100,000,000,000.00)");
99 iterator_type
is_it13(iss
);
101 ios_base::iostate err13
= ios_base::goodbit
;
102 mon_get
.get(is_it13
, end
, true, iss
, err13
, result13
);
103 VERIFY( result13
== digits2
);
104 VERIFY( err13
== ios_base::eofbit
);
106 iss
.str(L
"(HKD .01)");
107 iterator_type
is_it14(iss
);
109 ios_base::iostate err14
= ios_base::goodbit
;
110 mon_get
.get(is_it14
, end
, true, iss
, err14
, result14
);
111 VERIFY( result14
== digits4
);
112 VERIFY( err14
== ios_base::eofbit
);