1 // 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001-2013 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 22.2.6.1.1 money_get members
24 #include <testsuite_hooks.h>
26 struct My_money_io : public std::moneypunct<wchar_t,false>
28 char_type do_decimal_point() const { return '.'; }
29 std::string do_grouping() const { return "\004"; }
31 std::wstring do_curr_symbol() const { return L"$"; }
32 std::wstring do_positive_sign() const { return L""; }
33 std::wstring do_negative_sign() const { return L"-"; }
35 int do_frac_digits() const { return 2; }
37 pattern do_neg_format() const
39 pattern pat = { { symbol, none, sign, value } };
48 typedef istreambuf_iterator<wchar_t> InIt;
50 bool test __attribute__((unused)) = true;
52 locale loc(locale::classic(), new My_money_io);
54 wstring bufferp(L"$1234.56");
55 wstring buffern(L"$-1234.56");
56 wstring bufferp_ns(L"1234.56");
57 wstring buffern_ns(L"-1234.56");
61 InIt iendp, iendn, iendp_ns, iendn_ns;
62 ios_base::iostate err;
63 wstring valp, valn, valp_ns, valn_ns;
65 const money_get<wchar_t,InIt>& mg = use_facet<money_get<wchar_t, InIt> >(loc);
66 wistringstream fmtp(bufferp);
69 mg.get(ibegp,iendp,intl,fmtp,err,valp);
70 VERIFY( valp == L"123456" );
72 wistringstream fmtn(buffern);
75 mg.get(ibegn,iendn,intl,fmtn,err,valn);
76 VERIFY( valn == L"-123456" );
78 wistringstream fmtp_ns(bufferp_ns);
80 InIt ibegp_ns(fmtp_ns);
81 mg.get(ibegp_ns,iendp_ns,intl,fmtp_ns,err,valp_ns);
82 VERIFY( valp_ns == L"123456" );
84 wistringstream fmtn_ns(buffern_ns);
86 InIt ibegn_ns(fmtn_ns);
87 mg.get(ibegn_ns,iendn_ns,intl,fmtn_ns,err,valn_ns);
88 VERIFY( valn_ns == L"-123456" );