]>
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-2019 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
;
35 locale loc_c
= locale::classic();
36 locale loc_hk
= locale(ISO_8859(1,en_HK
));
37 VERIFY( loc_c
!= loc_hk
);
39 // total EPA budget FY 2002
40 const wstring
digits1(L
"720000000000");
42 // est. cost, national missile "defense", expressed as a loss in USD 2001
43 const wstring
digits2(L
"-10000000000000");
45 // input less than frac_digits
46 const wstring
digits4(L
"-1");
51 // cache the money_get facet
52 const money_get
<wchar_t>& mon_get
= use_facet
<money_get
<wchar_t> >(iss
.getloc());
54 // now try with showbase, to get currency symbol in format
55 iss
.setf(ios_base::showbase
);
57 iss
.str(L
"HK$7,200,000,000.00");
58 iterator_type
is_it09(iss
);
60 ios_base::iostate err09
= ios_base::goodbit
;
61 mon_get
.get(is_it09
, end
, false, iss
, err09
, result9
);
62 VERIFY( result9
== digits1
);
63 VERIFY( err09
== ios_base::eofbit
);
65 iss
.str(L
"(HKD 100,000,000,000.00)");
66 iterator_type
is_it10(iss
);
68 ios_base::iostate err10
= ios_base::goodbit
;
69 mon_get
.get(is_it10
, end
, true, iss
, err10
, result10
);
70 VERIFY( result10
== digits2
);
71 VERIFY( err10
== ios_base::eofbit
);
73 iss
.str(L
"(HKD .01)");
74 iterator_type
is_it11(iss
);
76 ios_base::iostate err11
= ios_base::goodbit
;
77 mon_get
.get(is_it11
, end
, true, iss
, err11
, result11
);
78 VERIFY( result11
== digits4
);
79 VERIFY( err11
== ios_base::eofbit
);
81 // for the "en_HK.ISO8859-1" locale the parsing of the very same input streams must
82 // be successful without showbase too, since the symbol field appears in
83 // the first positions in the format and the symbol, when present, must be
85 iss
.unsetf(ios_base::showbase
);
87 iss
.str(L
"HK$7,200,000,000.00");
88 iterator_type
is_it12(iss
);
90 ios_base::iostate err12
= ios_base::goodbit
;
91 mon_get
.get(is_it12
, end
, false, iss
, err12
, result12
);
92 VERIFY( result12
== digits1
);
93 VERIFY( err12
== ios_base::eofbit
);
95 iss
.str(L
"(HKD 100,000,000,000.00)");
96 iterator_type
is_it13(iss
);
98 ios_base::iostate err13
= ios_base::goodbit
;
99 mon_get
.get(is_it13
, end
, true, iss
, err13
, result13
);
100 VERIFY( result13
== digits2
);
101 VERIFY( err13
== ios_base::eofbit
);
103 iss
.str(L
"(HKD .01)");
104 iterator_type
is_it14(iss
);
106 ios_base::iostate err14
= ios_base::goodbit
;
107 mon_get
.get(is_it14
, end
, true, iss
, err14
, result14
);
108 VERIFY( result14
== digits4
);
109 VERIFY( err14
== ios_base::eofbit
);