]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/num_put/put/char/2.cc
1 // 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001-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/>.
20 // 22.2.2.2.1 num_put members
24 #include <testsuite_hooks.h>
29 typedef ostreambuf_iterator
<char> iterator_type
;
32 locale loc_c
= locale::classic();
34 // sanity check the data is correct.
41 unsigned long ul1
= 1294967294;
42 unsigned long ul2
= 0;
44 // cache the num_put facet
47 const num_put
<char>& np
= use_facet
<num_put
<char> >(oss
.getloc());
50 // bool, more twisted examples
53 oss
.setf(ios_base::right
, ios_base::adjustfield
);
54 np
.put(oss
.rdbuf(), oss
, '+', b0
);
56 VERIFY( result1
== "+++++++++++++++++++0" );
60 oss
.setf(ios_base::left
, ios_base::adjustfield
);
61 oss
.setf(ios_base::boolalpha
);
62 np
.put(oss
.rdbuf(), oss
, '+', b1
);
64 VERIFY( result2
== "true++++++++++++++++" );
66 // unsigned long, in a locale that does not group
70 np
.put(oss
.rdbuf(), oss
, '+', ul1
);
72 VERIFY( result1
== "1294967294" );
77 oss
.setf(ios_base::left
, ios_base::adjustfield
);
78 np
.put(oss
.rdbuf(), oss
, '+', ul2
);
80 VERIFY( result1
== "0+++++++++++++++++++" );