1 // { dg-require-namedlocale "" }
3 // 2001-08-27 Benjamin Kosnik <bkoz@redhat.com>
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation
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 2, 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 COPYING. If not, write to the Free
20 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
23 // 22.2.6.2.1 money_put members
27 #include <testsuite_hooks.h>
29 // test wstring version
33 typedef ostreambuf_iterator<wchar_t> iterator_type;
35 bool test __attribute__((unused)) = true;
38 locale loc_c = locale::classic();
39 locale loc_hk = locale("en_HK");
40 VERIFY( loc_c != loc_hk );
42 // sanity check the data is correct.
45 // total EPA budget FY 2002
46 const wstring digits1(L"720000000000");
48 // est. cost, national missile "defense", expressed as a loss in USD 2001
49 const wstring digits2(L"-10000000000000");
52 const wstring digits3(L"-A");
54 // input less than frac_digits
55 const wstring digits4(L"-1");
57 // cache the money_put facet
60 const money_put<wchar_t>& mon_put =
61 use_facet<money_put<wchar_t> >(oss.getloc());
63 // now try with showbase, to get currency symbol in format
64 oss.setf(ios_base::showbase);
66 // test sign of more than one digit, say hong kong.
68 iterator_type os_it05 = mon_put.put(oss.rdbuf(), false, oss, L' ', digits1);
69 wstring result5 = oss.str();
70 VERIFY( result5 == L"HK$7,200,000,000.00" );
73 iterator_type os_it06 = mon_put.put(oss.rdbuf(), true, oss, L' ', digits2);
74 wstring result6 = oss.str();
75 VERIFY( result6 == L"(HKD 100,000,000,000.00)" );
77 // test one-digit formats without zero padding
80 const money_put<wchar_t>& mon_put2 =
81 use_facet<money_put<wchar_t> >(oss.getloc());
82 iterator_type os_it07 = mon_put2.put(oss.rdbuf(), true, oss, L' ', digits4);
83 wstring result7 = oss.str();
84 VERIFY( result7 == L"1" );
86 // test one-digit formats with zero padding, zero frac widths
89 const money_put<wchar_t>& mon_put3 =
90 use_facet<money_put<wchar_t> >(oss.getloc());
91 iterator_type os_it08 = mon_put3.put(oss.rdbuf(), true, oss, L' ', digits4);
92 wstring result8 = oss.str();
93 VERIFY( result8 == L"(HKD .01)" );
95 oss.unsetf(ios_base::showbase);
99 iterator_type os_it09 = mon_put.put(oss.rdbuf(), true, oss, L' ', digits3);
100 wstring result9 = oss.str();
101 VERIFY( result9 == L"" );