1 // { dg-require-namedlocale "" }
3 // 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation
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 2, 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 COPYING. If not, write to the Free
20 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
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 iterator_type os_it01 = np.put(os_it00, oss, L'+', b1);
67 VERIFY( result1 == L"1" );
68 // VERIFY( os_it00 != os_it01 );
71 np.put(oss.rdbuf(), oss, L'+', b0);
73 VERIFY( result2 == L"0" );
75 // ... and one that does
80 oss.setf(ios_base::left, ios_base::adjustfield);
81 np.put(oss.rdbuf(), oss, L'+', ul1);
83 VERIFY( result1 == L"1.294.967.294+++++++" );
89 oss.setf(ios_base::left, ios_base::adjustfield);
90 np.put(oss.rdbuf(), oss, L'+', d1);
92 VERIFY( result1 == L"1,79769e+308++++++++" );
97 oss.setf(ios_base::right, ios_base::adjustfield);
98 np.put(oss.rdbuf(), oss, L'+', d2);
100 VERIFY( result1 == L"++++++++2,22507e-308" );
105 oss.setf(ios_base::right, ios_base::adjustfield);
106 oss.setf(ios_base::scientific, ios_base::floatfield);
107 np.put(oss.rdbuf(), oss, L'+', d2);
109 VERIFY( result2 == L"+++++++2,225074e-308" );
115 oss.setf(ios_base::right, ios_base::adjustfield);
116 oss.setf(ios_base::scientific, ios_base::floatfield);
117 oss.setf(ios_base::uppercase);
118 np.put(oss.rdbuf(), oss, L'+', d2);
120 VERIFY( result1 == L"+++2,2250738585E-308" );
125 np.put(oss.rdbuf(), oss, L'+', ld1);
127 VERIFY( result1 == L"1,7976931349E+308" );
132 oss.setf(ios_base::fixed, ios_base::floatfield);
133 np.put(oss.rdbuf(), oss, L'+', ld2);
135 VERIFY( result1 == L"0" );
140 np.put(oss.rdbuf(), oss, L'+', cv);
142 // No grouping characters.
143 VERIFY( !char_traits<wchar_t>::find(result1.c_str(),
145 numpunct_de.decimal_point()) );
146 // Should contain an 'x'.
147 VERIFY( result1.find(L'x') == 1 );
149 #ifdef _GLIBCXX_USE_LONG_LONG
150 long long ll1 = 9223372036854775807LL;
154 np.put(oss.rdbuf(), oss, L'+', ll1);
156 VERIFY( result1 == L"9.223.372.036.854.775.807" );