]>
Commit | Line | Data |
---|---|---|
4216708a | 1 | // { dg-require-namedlocale "de_DE.ISO8859-15" } |
f63a8495 | 2 | |
5f8d36fe BK |
3 | // 2001-09-12 Benjamin Kosnik <bkoz@redhat.com> |
4 | ||
83ffe9cd | 5 | // Copyright (C) 2001-2023 Free Software Foundation, Inc. |
5f8d36fe BK |
6 | // |
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 | |
748086b7 | 10 | // Free Software Foundation; either version 3, or (at your option) |
5f8d36fe BK |
11 | // any later version. |
12 | ||
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. | |
17 | ||
18 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
19 | // with this library; see the file COPYING3. If not see |
20 | // <http://www.gnu.org/licenses/>. | |
5f8d36fe BK |
21 | |
22 | // 22.2.6.1.1 money_get members | |
23 | ||
24 | #include <locale> | |
25 | #include <sstream> | |
26 | #include <testsuite_hooks.h> | |
27 | ||
28 | // test string version | |
29 | void test01() | |
30 | { | |
31 | using namespace std; | |
5f8d36fe BK |
32 | typedef istreambuf_iterator<char> iterator_type; |
33 | ||
5f8d36fe BK |
34 | // basic construction |
35 | locale loc_c = locale::classic(); | |
4216708a | 36 | locale loc_de = locale(ISO_8859(15,de_DE)); |
5f8d36fe | 37 | VERIFY( loc_c != loc_de ); |
5f8d36fe | 38 | |
5f8d36fe BK |
39 | // sanity check the data is correct. |
40 | const string empty; | |
41 | ||
42 | // total EPA budget FY 2002 | |
43 | const string digits1("720000000000"); | |
44 | ||
5f8d36fe BK |
45 | iterator_type end; |
46 | istringstream iss; | |
47 | iss.imbue(loc_de); | |
48 | // cache the money_get facet | |
49 | const money_get<char>& mon_get = use_facet<money_get<char> >(iss.getloc()); | |
50 | ||
5f8d36fe BK |
51 | iss.str("7.200.000.000,00 "); |
52 | iterator_type is_it01(iss); | |
53 | string result1; | |
54 | ios_base::iostate err01 = ios_base::goodbit; | |
26c691a8 | 55 | mon_get.get(is_it01, end, true, iss, err01, result1); // xxx |
5f8d36fe BK |
56 | VERIFY( result1 == digits1 ); |
57 | VERIFY( err01 == ios_base::eofbit ); | |
58 | ||
59 | iss.str("7.200.000.000,00 "); | |
60 | iterator_type is_it02(iss); | |
61 | string result2; | |
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 ); | |
66 | ||
67 | iss.str("7.200.000.000,00 a"); | |
68 | iterator_type is_it03(iss); | |
69 | string result3; | |
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 ); | |
74 | ||
75 | iss.str(""); | |
76 | iterator_type is_it04(iss); | |
77 | string result4; | |
78 | ios_base::iostate err04 = ios_base::goodbit; | |
79 | mon_get.get(is_it04, end, true, iss, err04, result4); | |
80 | VERIFY( result4 == empty ); | |
1b451306 | 81 | VERIFY( err04 == (ios_base::failbit | ios_base::eofbit) ); |
5f8d36fe BK |
82 | |
83 | iss.str("working for enlightenment and peace in a mad world"); | |
84 | iterator_type is_it05(iss); | |
85 | string result5; | |
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 ); | |
90 | ||
91 | // now try with showbase, to get currency symbol in format | |
92 | iss.setf(ios_base::showbase); | |
93 | ||
94 | iss.str("7.200.000.000,00 EUR "); | |
95 | iterator_type is_it06(iss); | |
96 | string result6; | |
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 ); | |
101 | ||
102 | iss.str("7.200.000.000,00 EUR "); // Extra space. | |
103 | iterator_type is_it07(iss); | |
104 | string result7; | |
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 ); | |
109 | ||
110 | iss.str("7.200.000.000,00 \244"); | |
111 | iterator_type is_it08(iss); | |
112 | string result8; | |
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 ); | |
117 | } | |
118 | ||
119 | int main() | |
120 | { | |
3d838e28 | 121 | test01(); |
5f8d36fe BK |
122 | return 0; |
123 | } |