]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/money_get/get/char/22131.cc
1 // 2005-06-28 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2005-2016 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
<char, false>
28 std::string
do_grouping() const { return "\1"; }
29 char_type
do_thousands_sep() const { return '#'; }
31 pattern
do_neg_format() const
33 pattern pat
= { { symbol
, none
, sign
, value
} };
42 typedef istreambuf_iterator
<char> InIt
;
44 bool test
__attribute__((unused
)) = true;
46 locale
loc(locale::classic(), new My_money_io
);
48 string
buffer1("00#0#1");
49 string
buffer2("000##1");
54 ios_base::iostate err1
, err2
;
57 const money_get
<char,InIt
>& mg
=
58 use_facet
<money_get
<char, InIt
> >(loc
);
60 istringstream
fmt1(buffer1
);
63 err1
= ios_base::goodbit
;
64 mg
.get(ibeg1
, iend1
, intl
, fmt1
, err1
, val1
);
65 VERIFY( err1
== (ios_base::eofbit
| ios_base::failbit
) );
66 VERIFY( val1
== "1" );
68 istringstream
fmt2(buffer2
);
71 err2
= ios_base::goodbit
;
72 mg
.get(ibeg2
, iend2
, intl
, fmt2
, err2
, val2
);
73 VERIFY( err2
== ios_base::failbit
);
74 VERIFY( *ibeg2
== '#' );