]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/2.cc
1 // { dg-require-namedlocale "en_HK.ISO8859-1" }
3 // 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
5 // Copyright (C) 2001-2016 Free Software Foundation, Inc.
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 3, 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 COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
22 // 22.2.6.1.1 money_get members
26 #include <testsuite_hooks.h>
28 // test wstring version
32 typedef istreambuf_iterator
<wchar_t> iterator_type
;
34 bool test
__attribute__((unused
)) = true;
37 locale loc_c
= locale::classic();
38 locale loc_hk
= locale(ISO_8859(1,en_HK
));
39 VERIFY( loc_c
!= loc_hk
);
41 // total EPA budget FY 2002
42 const wstring
digits1(L
"720000000000");
44 // est. cost, national missile "defense", expressed as a loss in USD 2001
45 const wstring
digits2(L
"-10000000000000");
47 // input less than frac_digits
48 const wstring
digits4(L
"-1");
53 // cache the money_get facet
54 const money_get
<wchar_t>& mon_get
= use_facet
<money_get
<wchar_t> >(iss
.getloc());
56 // now try with showbase, to get currency symbol in format
57 iss
.setf(ios_base::showbase
);
59 iss
.str(L
"HK$7,200,000,000.00");
60 iterator_type
is_it09(iss
);
62 ios_base::iostate err09
= ios_base::goodbit
;
63 mon_get
.get(is_it09
, end
, false, iss
, err09
, result9
);
64 VERIFY( result9
== digits1
);
65 VERIFY( err09
== ios_base::eofbit
);
67 iss
.str(L
"(HKD 100,000,000,000.00)");
68 iterator_type
is_it10(iss
);
70 ios_base::iostate err10
= ios_base::goodbit
;
71 mon_get
.get(is_it10
, end
, true, iss
, err10
, result10
);
72 VERIFY( result10
== digits2
);
73 VERIFY( err10
== ios_base::eofbit
);
75 iss
.str(L
"(HKD .01)");
76 iterator_type
is_it11(iss
);
78 ios_base::iostate err11
= ios_base::goodbit
;
79 mon_get
.get(is_it11
, end
, true, iss
, err11
, result11
);
80 VERIFY( result11
== digits4
);
81 VERIFY( err11
== ios_base::eofbit
);
83 // for the "en_HK.ISO8859-1" locale the parsing of the very same input streams must
84 // be successful without showbase too, since the symbol field appears in
85 // the first positions in the format and the symbol, when present, must be
87 iss
.unsetf(ios_base::showbase
);
89 iss
.str(L
"HK$7,200,000,000.00");
90 iterator_type
is_it12(iss
);
92 ios_base::iostate err12
= ios_base::goodbit
;
93 mon_get
.get(is_it12
, end
, false, iss
, err12
, result12
);
94 VERIFY( result12
== digits1
);
95 VERIFY( err12
== ios_base::eofbit
);
97 iss
.str(L
"(HKD 100,000,000,000.00)");
98 iterator_type
is_it13(iss
);
100 ios_base::iostate err13
= ios_base::goodbit
;
101 mon_get
.get(is_it13
, end
, true, iss
, err13
, result13
);
102 VERIFY( result13
== digits2
);
103 VERIFY( err13
== ios_base::eofbit
);
105 iss
.str(L
"(HKD .01)");
106 iterator_type
is_it14(iss
);
108 ios_base::iostate err14
= ios_base::goodbit
;
109 mon_get
.get(is_it14
, end
, true, iss
, err14
, result14
);
110 VERIFY( result14
== digits4
);
111 VERIFY( err14
== ios_base::eofbit
);