]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/money_get/get/char/9.cc
1 // 2003-05-27 Brendan Kehoe <brendan@zen.org>
3 // Copyright (C) 2003-2022 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/>.
21 // The number of digits required after the decimal point (if any) is exactly
22 // the value returned by frac_digits().
27 class dublin
: public std::moneypunct
<char> {
29 int do_frac_digits() const { return 3; }
34 std::istringstream liffey
;
37 std::locale
eire(std::locale::classic(), new dublin
);
40 const std::money_get
<char>& greed
41 = std::use_facet
<std::money_get
<char> >(liffey
.getloc());
43 typedef std::istreambuf_iterator
<char> iterator_type
;
46 std::ios_base::iostate err01
= std::ios_base::goodbit
;
50 // Feed it 1 digit too many, which should fail.
51 liffey
.str("12.3456");
52 greed
.get(liffey
, end
, false, liffey
, err01
, coins
);
53 if (! (err01
& std::ios_base::failbit
))
56 err01
= std::ios_base::goodbit
;
58 // Feed it exactly what it wants, which should succeed.
60 greed
.get(liffey
, end
, false, liffey
, err01
, coins
);
61 if ( err01
& std::ios_base::failbit
)
64 err01
= std::ios_base::goodbit
;
66 // Feed it 1 digit too few, which should fail.
68 greed
.get(liffey
, end
, false, liffey
, err01
, coins
);
69 if (! ( err01
& std::ios_base::failbit
))
72 err01
= std::ios_base::goodbit
;
74 // Feed it only a decimal-point, which should fail.
76 greed
.get(liffey
, end
, false, liffey
, err01
, coins
);
77 if (! (err01
& std::ios_base::failbit
))
80 err01
= std::ios_base::goodbit
;
82 // Feed it no decimal-point at all, which should succeed.
84 greed
.get(liffey
, end
, false, liffey
, err01
, coins
);
85 if ( err01
& std::ios_base::failbit
)