]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/manipulators/basefield/wchar_t/1.cc
1 // Copyright (C) 2004-2024 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
22 #include <testsuite_hooks.h>
24 struct MyNP
: std::numpunct
<wchar_t>
26 std::string
do_grouping() const;
27 wchar_t do_thousands_sep() const;
31 MyNP::do_grouping() const
38 MyNP::do_thousands_sep() const
43 const wchar_t lit
[] = L
"0123 456\n"
53 L
"|0x000012 345 678|\n"
54 L
"|0x12 345 6780000|\n"
55 L
"|00000x12 345 678|\n"
56 L
"|0x000012 345 678|\n";
58 std::wostringstream oss
;
59 oss
.imbue(std::locale(std::locale(), new MyNP
));
62 oss
<< std::oct
<< std::showbase
;
63 oss
<< 0123456l << std::endl
;
65 oss
<< L
":" << std::setw(11);
66 oss
<< 01234567l << L
":" << std::endl
;
68 oss
<< L
":" << std::setw(11) << std::left
;
69 oss
<< 0123456l << L
":" << std::endl
;
71 oss
<< L
":" << std::setw(11) << std::right
;
72 oss
<< 012345l << L
":" << std::endl
;
74 oss
<< L
":" << std::setw(11) << std::internal
;
75 oss
<< 01234l << L
":" << std::endl
;
77 oss
<< L
":" << std::setw(11);
78 oss
<< 123456789l << L
":" << std::endl
;
80 oss
<< L
":" << std::setw(11) << std::left
;
81 oss
<< 1234567l << L
":" << std::endl
;
83 oss
<< L
":" << std::setw(11) << std::right
;
84 oss
<< 123456l << L
":" << std::endl
;
86 oss
<< L
":" << std::setw(11) << std::internal
;
87 oss
<< 123l << L
":" << std::endl
;
90 oss
<< std::hex
<< std::setfill(L
'0');
91 oss
<< 0x12345678l
<< std::endl
;
93 oss
<< L
"|" << std::setw(16);
94 oss
<< 0x12345678l
<< L
"|" << std::endl
;
96 oss
<< L
"|" << std::setw(16) << std::left
;
97 oss
<< 0x12345678l
<< L
"|" << std::endl
;
99 oss
<< L
"|" << std::setw(16) << std::right
;
100 oss
<< 0x12345678l
<< L
"|" << std::endl
;
102 oss
<< L
"|" << std::setw(16) << std::internal
;
103 oss
<< 0x12345678l
<< L
"|" << std::endl
;
105 VERIFY( oss
.good() );
106 VERIFY( oss
.str() == lit
);