1 // { dg-require-namedlocale "" }
3 // 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
6 // Free Software Foundation
8 // This file is part of the GNU ISO C++ Library. This library is free
9 // software; you can redistribute it and/or modify it under the
10 // terms of the GNU General Public License as published by the
11 // Free Software Foundation; either version 3, or (at your option)
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License along
20 // with this library; see the file COPYING3. If not see
21 // <http://www.gnu.org/licenses/>.
23 // 22.2.2.2.1 num_put members
27 #include <testsuite_hooks.h>
32 typedef ostreambuf_iterator<wchar_t> iterator_type;
34 bool test __attribute__((unused)) = true;
37 locale loc_c = locale::classic();
38 locale loc_de = locale("de_DE");
39 VERIFY( loc_c != loc_de );
41 // cache the numpunct facets
42 const numpunct<wchar_t>& numpunct_de = use_facet<numpunct<wchar_t> >(loc_de);
44 // sanity check the data is correct.
51 unsigned long ul1 = 1294967294;
52 double d1 = 1.7976931348623157e+308;
53 double d2 = 2.2250738585072014e-308;
54 long double ld1 = 1.7976931348623157e+308;
55 long double ld2 = 2.2250738585072014e-308;
56 const void* cv = &ld1;
58 // cache the num_put facet
61 const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
64 iterator_type os_it00 = oss.rdbuf();
65 np.put(os_it00, oss, L'+', b1);
67 VERIFY( result1 == L"1" );
70 np.put(oss.rdbuf(), oss, L'+', b0);
72 VERIFY( result2 == L"0" );
74 // ... and one that does
79 oss.setf(ios_base::left, ios_base::adjustfield);
80 np.put(oss.rdbuf(), oss, L'+', ul1);
82 VERIFY( result1 == L"1.294.967.294+++++++" );
88 oss.setf(ios_base::left, ios_base::adjustfield);
89 np.put(oss.rdbuf(), oss, L'+', d1);
91 VERIFY( result1 == L"1,79769e+308++++++++" );
96 oss.setf(ios_base::right, ios_base::adjustfield);
97 np.put(oss.rdbuf(), oss, L'+', d2);
99 VERIFY( result1 == L"++++++++2,22507e-308" );
104 oss.setf(ios_base::right, ios_base::adjustfield);
105 oss.setf(ios_base::scientific, ios_base::floatfield);
106 np.put(oss.rdbuf(), oss, L'+', d2);
108 VERIFY( result2 == L"+++++++2,225074e-308" );
114 oss.setf(ios_base::right, ios_base::adjustfield);
115 oss.setf(ios_base::scientific, ios_base::floatfield);
116 oss.setf(ios_base::uppercase);
117 np.put(oss.rdbuf(), oss, L'+', d2);
119 VERIFY( result1 == L"+++2,2250738585E-308" );
124 np.put(oss.rdbuf(), oss, L'+', ld1);
126 VERIFY( result1 == L"1,7976931349E+308" );
131 oss.setf(ios_base::fixed, ios_base::floatfield);
132 np.put(oss.rdbuf(), oss, L'+', ld2);
134 VERIFY( result1 == L"0" );
139 np.put(oss.rdbuf(), oss, L'+', cv);
141 // No grouping characters.
142 VERIFY( !char_traits<wchar_t>::find(result1.c_str(),
144 numpunct_de.decimal_point()) );
145 // Should contain an 'x'.
146 VERIFY( result1.find(L'x') == 1 );
148 #ifdef _GLIBCXX_USE_LONG_LONG
149 long long ll1 = 9223372036854775807LL;
153 np.put(oss.rdbuf(), oss, L'+', ll1);
155 VERIFY( result1 == L"9.223.372.036.854.775.807" );