1 // 2003-05-27 Brendan Kehoe <brendan@zen.org>
3 // Copyright (C) 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,
22 // The number of digits required after the decimal point (if any) is exactly
23 // the value returned by frac_digits().
28 class dublin
: public std::moneypunct
<wchar_t> {
30 int do_frac_digits() const { return 3; }
35 std::wistringstream liffey
;
38 std::locale
eire(std::locale::classic(), new dublin
);
41 const std::money_get
<wchar_t>& greed
42 = std::use_facet
<std::money_get
<wchar_t> >(liffey
.getloc());
44 typedef std::istreambuf_iterator
<wchar_t> iterator_type
;
45 iterator_type
is(liffey
);
48 std::ios_base::iostate err01
= std::ios_base::goodbit
;
52 // Feed it 1 digit too many, which should fail.
53 liffey
.str(L
"12.3456");
54 greed
.get(is
, end
, false, liffey
, err01
, coins
);
55 if (! (err01
& std::ios_base::failbit
))
58 err01
= std::ios_base::goodbit
;
60 // Feed it exactly what it wants, which should succeed.
61 liffey
.str(L
"12.345");
62 greed
.get(is
, end
, false, liffey
, err01
, coins
);
63 if ( err01
& std::ios_base::failbit
)
66 err01
= std::ios_base::goodbit
;
68 // Feed it 1 digit too few, which should fail.
70 greed
.get(is
, end
, false, liffey
, err01
, coins
);
71 if (! ( err01
& std::ios_base::failbit
))
74 err01
= std::ios_base::goodbit
;
76 // Feed it only a decimal-point, which should fail.
78 greed
.get(is
, end
, false, liffey
, err01
, coins
);
79 if (! (err01
& std::ios_base::failbit
))
82 err01
= std::ios_base::goodbit
;
84 // Feed it no decimal-point at all, which should succeed.
86 greed
.get(is
, end
, false, liffey
, err01
, coins
);
87 if ( err01
& std::ios_base::failbit
)