]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / money_get / get / wchar_t / 1.cc
CommitLineData
4216708a 1// { dg-require-namedlocale "de_DE.ISO8859-15" }
f63a8495 2
5f8d36fe
BK
3// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
4
a5544970 5// Copyright (C) 2001-2019 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 wstring version
29void test01()
30{
31 using namespace std;
5f8d36fe
BK
32 typedef istreambuf_iterator<wchar_t> 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 wstring empty;
41
42 // total EPA budget FY 2002
43 const wstring digits1(L"720000000000");
44
5f8d36fe
BK
45 iterator_type end;
46 wistringstream iss;
47 iss.imbue(loc_de);
48 // cache the money_get facet
49 const money_get<wchar_t>& mon_get = use_facet<money_get<wchar_t> >(iss.getloc());
50
5f8d36fe
BK
51 iss.str(L"7.200.000.000,00 ");
52 iterator_type is_it01(iss);
53 wstring result1;
54 ios_base::iostate err01 = ios_base::goodbit;
55 mon_get.get(is_it01, end, true, iss, err01, result1);
56 VERIFY( result1 == digits1 );
57 VERIFY( err01 == ios_base::eofbit );
58
59 iss.str(L"7.200.000.000,00 ");
60 iterator_type is_it02(iss);
61 wstring 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(L"7.200.000.000,00 a");
68 iterator_type is_it03(iss);
69 wstring 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(L"");
76 iterator_type is_it04(iss);
77 wstring 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(L"working for enlightenment and peace in a mad world");
84 iterator_type is_it05(iss);
85 wstring 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(L"7.200.000.000,00 EUR ");
95 iterator_type is_it06(iss);
96 wstring 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(L"7.200.000.000,00 EUR "); // Extra space.
103 iterator_type is_it07(iss);
104 wstring 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(L"7.200.000.000,00 \x20ac");
111 iterator_type is_it08(iss);
112 wstring 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
119int main()
120{
121 test01();
122 return 0;
123}