]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/manipulators/basefield/char/1.cc
1 // 981027 ncm work with libstdc++v3
3 // Copyright (C) 1997-2021 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/>.
24 #include <testsuite_hooks.h>
26 struct MyNP
: std::numpunct
<char>
28 std::string
do_grouping() const;
29 char do_thousands_sep() const;
33 MyNP::do_grouping() const
40 MyNP::do_thousands_sep() const
45 const char lit
[] = "0123 456\n"
55 "|0x000012 345 678|\n"
56 "|0x12 345 6780000|\n"
57 "|00000x12 345 678|\n"
58 "|0x000012 345 678|\n";
60 std::ostringstream oss
;
61 oss
.imbue(std::locale(std::locale(), new MyNP
));
64 oss
<< std::oct
<< std::showbase
;
65 oss
<< 0123456l << std::endl
;
67 oss
<< ":" << std::setw(11);
68 oss
<< 01234567l << ":" << std::endl
;
70 oss
<< ":" << std::setw(11) << std::left
;
71 oss
<< 0123456l << ":" << std::endl
;
73 oss
<< ":" << std::setw(11) << std::right
;
74 oss
<< 012345l << ":" << std::endl
;
76 oss
<< ":" << std::setw(11) << std::internal
;
77 oss
<< 01234l << ":" << std::endl
;
79 oss
<< ":" << std::setw(11);
80 oss
<< 123456789l << ":" << std::endl
;
82 oss
<< ":" << std::setw(11) << std::left
;
83 oss
<< 1234567l << ":" << std::endl
;
85 oss
<< ":" << std::setw(11) << std::right
;
86 oss
<< 123456l << ":" << std::endl
;
88 oss
<< ":" << std::setw(11) << std::internal
;
89 oss
<< 123l << ":" << std::endl
;
92 oss
<< std::hex
<< std::setfill('0');
93 oss
<< 0x12345678l
<< std::endl
;
95 oss
<< "|" << std::setw(16);
96 oss
<< 0x12345678l
<< "|" << std::endl
;
98 oss
<< "|" << std::setw(16) << std::left
;
99 oss
<< 0x12345678l
<< "|" << std::endl
;
101 oss
<< "|" << std::setw(16) << std::right
;
102 oss
<< 0x12345678l
<< "|" << std::endl
;
104 oss
<< "|" << std::setw(16) << std::internal
;
105 oss
<< 0x12345678l
<< "|" << std::endl
;
107 VERIFY( oss
.good() );
108 VERIFY( oss
.str() == lit
);