1 // 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation
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 2, 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 COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // 22.2.6.1.1 money_get members
25 #include <testsuite_hooks.h>
27 struct My_money_io
: public std::moneypunct
<char,false>
29 char_type
do_decimal_point() const { return '.'; }
30 std::string
do_grouping() const { return "\004"; }
32 std::string
do_curr_symbol() const { return "$"; }
33 std::string
do_positive_sign() const { return ""; }
34 std::string
do_negative_sign() const { return "-"; }
36 int do_frac_digits() const { return 2; }
38 pattern
do_neg_format() const
40 pattern pat
= { { symbol
, none
, sign
, value
} };
49 typedef istreambuf_iterator
<char> InIt
;
51 bool test
__attribute__((unused
)) = true;
53 locale
loc(locale::classic(), new My_money_io
);
55 string
bufferp("$1234.56");
56 string
buffern("$-1234.56");
57 string
bufferp_ns("1234.56");
58 string
buffern_ns("-1234.56");
62 InIt iendp
, iendn
, iendp_ns
, iendn_ns
;
63 ios_base::iostate err
;
64 string valp
, valn
, valp_ns
, valn_ns
;
66 const money_get
<char,InIt
>& mg
=
67 use_facet
<money_get
<char, InIt
> >(loc
);
69 istringstream
fmtp(bufferp
);
72 mg
.get(ibegp
,iendp
,intl
,fmtp
,err
,valp
);
73 VERIFY( valp
== "123456" );
75 istringstream
fmtn(buffern
);
78 mg
.get(ibegn
,iendn
,intl
,fmtn
,err
,valn
);
79 VERIFY( valn
== "-123456" );
81 istringstream
fmtp_ns(bufferp_ns
);
83 InIt
ibegp_ns(fmtp_ns
);
84 mg
.get(ibegp_ns
,iendp_ns
,intl
,fmtp_ns
,err
,valp_ns
);
85 VERIFY( valp_ns
== "123456" );
87 istringstream
fmtn_ns(buffern_ns
);
89 InIt
ibegn_ns(fmtn_ns
);
90 mg
.get(ibegn_ns
,iendn_ns
,intl
,fmtn_ns
,err
,valn_ns
);
91 VERIFY( valn_ns
== "-123456" );