]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/1.cc
94a5fcb60694c4fa99d701ec69c01662286a2fc3
1 // { dg-require-namedlocale "de_DE.ISO8859-15" }
3 // 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
5 // Copyright (C) 2001-2024 Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
22 // 22.2.2.2.1 num_put members
26 #include <testsuite_hooks.h>
31 typedef ostreambuf_iterator
<wchar_t> iterator_type
;
34 locale loc_c
= locale::classic();
35 locale loc_de
= locale(ISO_8859(15,de_DE
));
36 VERIFY( loc_c
!= loc_de
);
38 // cache the numpunct facets
39 const numpunct
<wchar_t>& numpunct_de
= use_facet
<numpunct
<wchar_t> >(loc_de
);
41 // sanity check the data is correct.
48 unsigned long ul1
= 1294967294;
49 double d1
= 1.7976931348623157e+308;
50 double d2
= 2.2250738585072014e-308;
51 long double ld1
= 1.7976931348623157e+308;
52 long double ld2
= 2.2250738585072014e-308;
53 const void* cv
= &ld1
;
55 // cache the num_put facet
58 const num_put
<wchar_t>& np
= use_facet
<num_put
<wchar_t> >(oss
.getloc());
61 iterator_type os_it00
= oss
.rdbuf();
62 np
.put(os_it00
, oss
, L
'+', b1
);
64 VERIFY( result1
== L
"1" );
67 np
.put(oss
.rdbuf(), oss
, L
'+', b0
);
69 VERIFY( result2
== L
"0" );
71 // ... and one that does
76 oss
.setf(ios_base::left
, ios_base::adjustfield
);
77 np
.put(oss
.rdbuf(), oss
, L
'+', ul1
);
79 VERIFY( result1
== L
"1.294.967.294+++++++" );
85 oss
.setf(ios_base::left
, ios_base::adjustfield
);
86 np
.put(oss
.rdbuf(), oss
, L
'+', d1
);
88 VERIFY( result1
== L
"1,79769e+308++++++++" );
93 oss
.setf(ios_base::right
, ios_base::adjustfield
);
94 np
.put(oss
.rdbuf(), oss
, L
'+', d2
);
96 VERIFY( result1
== L
"++++++++2,22507e-308" );
101 oss
.setf(ios_base::right
, ios_base::adjustfield
);
102 oss
.setf(ios_base::scientific
, ios_base::floatfield
);
103 np
.put(oss
.rdbuf(), oss
, L
'+', d2
);
105 VERIFY( result2
== L
"+++++++2,225074e-308" );
111 oss
.setf(ios_base::right
, ios_base::adjustfield
);
112 oss
.setf(ios_base::scientific
, ios_base::floatfield
);
113 oss
.setf(ios_base::uppercase
);
114 np
.put(oss
.rdbuf(), oss
, L
'+', d2
);
116 VERIFY( result1
== L
"+++2,2250738585E-308" );
121 np
.put(oss
.rdbuf(), oss
, L
'+', ld1
);
123 VERIFY( result1
== L
"1,7976931349E+308" );
128 oss
.setf(ios_base::fixed
, ios_base::floatfield
);
129 np
.put(oss
.rdbuf(), oss
, L
'+', ld2
);
131 VERIFY( result1
== L
"0" );
136 np
.put(oss
.rdbuf(), oss
, L
'+', cv
);
138 // No grouping characters.
139 VERIFY( !char_traits
<wchar_t>::find(result1
.c_str(),
141 numpunct_de
.decimal_point()) );
142 // Should contain an 'x'.
143 VERIFY( result1
.find(L
'x') == 1 );
145 #ifdef _GLIBCXX_USE_LONG_LONG
146 long long ll1
= 9223372036854775807LL;
150 np
.put(oss
.rdbuf(), oss
, L
'+', ll1
);
152 VERIFY( result1
== L
"9.223.372.036.854.775.807" );