]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/9.cc
1 // 2003-05-27 Brendan Kehoe <brendan@zen.org>
3 // Copyright (C) 2003, 2004, 2009 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 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
<wchar_t> {
29 int do_frac_digits() const { return 3; }
34 std::wistringstream liffey
;
37 std::locale
eire(std::locale::classic(), new dublin
);
40 const std::money_get
<wchar_t>& greed
41 = std::use_facet
<std::money_get
<wchar_t> >(liffey
.getloc());
43 typedef std::istreambuf_iterator
<wchar_t> iterator_type
;
44 iterator_type
is(liffey
);
47 std::ios_base::iostate err01
= std::ios_base::goodbit
;
51 // Feed it 1 digit too many, which should fail.
52 liffey
.str(L
"12.3456");
53 greed
.get(is
, end
, false, liffey
, err01
, coins
);
54 if (! (err01
& std::ios_base::failbit
))
57 err01
= std::ios_base::goodbit
;
59 // Feed it exactly what it wants, which should succeed.
60 liffey
.str(L
"12.345");
61 greed
.get(is
, end
, false, liffey
, err01
, coins
);
62 if ( err01
& std::ios_base::failbit
)
65 err01
= std::ios_base::goodbit
;
67 // Feed it 1 digit too few, which should fail.
69 greed
.get(is
, end
, false, liffey
, err01
, coins
);
70 if (! ( err01
& std::ios_base::failbit
))
73 err01
= std::ios_base::goodbit
;
75 // Feed it only a decimal-point, which should fail.
77 greed
.get(is
, end
, false, liffey
, err01
, coins
);
78 if (! (err01
& std::ios_base::failbit
))
81 err01
= std::ios_base::goodbit
;
83 // Feed it no decimal-point at all, which should succeed.
85 greed
.get(is
, end
, false, liffey
, err01
, coins
);
86 if ( err01
& std::ios_base::failbit
)