]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/money_get/get/char/1.cc
1 // { dg-require-namedlocale "de_DE.ISO8859-15" }
3 // 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
5 // Copyright (C) 2001-2021 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 string version
32 typedef istreambuf_iterator
<char> iterator_type
;
35 locale loc_c
= locale::classic();
36 locale loc_de
= locale(ISO_8859(15,de_DE
));
37 VERIFY( loc_c
!= loc_de
);
39 // sanity check the data is correct.
42 // total EPA budget FY 2002
43 const string
digits1("720000000000");
48 // cache the money_get facet
49 const money_get
<char>& mon_get
= use_facet
<money_get
<char> >(iss
.getloc());
51 iss
.str("7.200.000.000,00 ");
52 iterator_type
is_it01(iss
);
54 ios_base::iostate err01
= ios_base::goodbit
;
55 mon_get
.get(is_it01
, end
, true, iss
, err01
, result1
); // xxx
56 VERIFY( result1
== digits1
);
57 VERIFY( err01
== ios_base::eofbit
);
59 iss
.str("7.200.000.000,00 ");
60 iterator_type
is_it02(iss
);
62 ios_base::iostate err02
= ios_base::goodbit
;
63 mon_get
.get(is_it02
, end
, true, iss
, err02
, result2
);
64 VERIFY( result2
== digits1
);
65 VERIFY( err02
== ios_base::eofbit
);
67 iss
.str("7.200.000.000,00 a");
68 iterator_type
is_it03(iss
);
70 ios_base::iostate err03
= ios_base::goodbit
;
71 mon_get
.get(is_it03
, end
, true, iss
, err03
, result3
);
72 VERIFY( result3
== digits1
);
73 VERIFY( err03
== ios_base::goodbit
);
76 iterator_type
is_it04(iss
);
78 ios_base::iostate err04
= ios_base::goodbit
;
79 mon_get
.get(is_it04
, end
, true, iss
, err04
, result4
);
80 VERIFY( result4
== empty
);
81 VERIFY( err04
== (ios_base::failbit
| ios_base::eofbit
) );
83 iss
.str("working for enlightenment and peace in a mad world");
84 iterator_type
is_it05(iss
);
86 ios_base::iostate err05
= ios_base::goodbit
;
87 mon_get
.get(is_it05
, end
, true, iss
, err05
, result5
);
88 VERIFY( result5
== empty
);
89 VERIFY( err05
== ios_base::failbit
);
91 // now try with showbase, to get currency symbol in format
92 iss
.setf(ios_base::showbase
);
94 iss
.str("7.200.000.000,00 EUR ");
95 iterator_type
is_it06(iss
);
97 ios_base::iostate err06
= ios_base::goodbit
;
98 mon_get
.get(is_it06
, end
, true, iss
, err06
, result6
);
99 VERIFY( result6
== digits1
);
100 VERIFY( err06
== ios_base::eofbit
);
102 iss
.str("7.200.000.000,00 EUR "); // Extra space.
103 iterator_type
is_it07(iss
);
105 ios_base::iostate err07
= ios_base::goodbit
;
106 mon_get
.get(is_it07
, end
, true, iss
, err07
, result7
);
107 VERIFY( result7
== digits1
);
108 VERIFY( err07
== ios_base::goodbit
);
110 iss
.str("7.200.000.000,00 \244");
111 iterator_type
is_it08(iss
);
113 ios_base::iostate err08
= ios_base::goodbit
;
114 mon_get
.get(is_it08
, end
, false, iss
, err08
, result8
);
115 VERIFY( result8
== digits1
);
116 VERIFY( err08
== ios_base::eofbit
);