1 // 2001-08-27 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001-2013 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.2.1 money_put members
24 #include <testsuite_hooks.h>
29 bool test
__attribute__((unused
)) = true;
31 // Check money_put works with other iterators besides streambuf
32 // output iterators. (As long as output_iterator requirements are met.)
33 typedef string::iterator iter_type
;
34 typedef money_put
<char, iter_type
> mon_put_type
;
35 const ios_base::iostate goodbit
= ios_base::goodbit
;
36 ios_base::iostate err
= goodbit
;
37 const locale loc_c
= locale::classic();
38 // woman, art, thief (stole the blues)
39 const string
str("1943 Janis Joplin");
40 const long double ld
= 1943.0;
41 const string
x(str
.size(), 'x'); // have to have allocated string!
45 oss
.imbue(locale(loc_c
, new mon_put_type
));
47 // Iterator advanced, state, output.
48 const mon_put_type
& mp
= use_facet
<mon_put_type
>(oss
.getloc());
52 iter_type ret1
= mp
.put(res
.begin(), false, oss
, ' ', str
);
53 string
sanity1(res
.begin(), ret1
);
54 VERIFY( err
== goodbit
);
55 VERIFY( res
== "1943xxxxxxxxxxxxx" );
56 VERIFY( sanity1
== "1943" );
60 iter_type ret2
= mp
.put(res
.begin(), false, oss
, ' ', ld
);
61 string
sanity2(res
.begin(), ret2
);
62 VERIFY( err
== goodbit
);
63 VERIFY( res
== "1943xxxxxxxxxxxxx" );
64 VERIFY( sanity2
== "1943" );