]>
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-2014 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 bool test
__attribute__((unused
)) = true;
46 const char lit
[] = "0123 456\n"
56 "|0x000012 345 678|\n"
57 "|0x12 345 6780000|\n"
58 "|00000x12 345 678|\n"
59 "|0x000012 345 678|\n";
61 std::ostringstream oss
;
62 oss
.imbue(std::locale(std::locale(), new MyNP
));
65 oss
<< std::oct
<< std::showbase
;
66 oss
<< 0123456l << std::endl
;
68 oss
<< ":" << std::setw(11);
69 oss
<< 01234567l << ":" << std::endl
;
71 oss
<< ":" << std::setw(11) << std::left
;
72 oss
<< 0123456l << ":" << std::endl
;
74 oss
<< ":" << std::setw(11) << std::right
;
75 oss
<< 012345l << ":" << std::endl
;
77 oss
<< ":" << std::setw(11) << std::internal
;
78 oss
<< 01234l << ":" << std::endl
;
80 oss
<< ":" << std::setw(11);
81 oss
<< 123456789l << ":" << std::endl
;
83 oss
<< ":" << std::setw(11) << std::left
;
84 oss
<< 1234567l << ":" << std::endl
;
86 oss
<< ":" << std::setw(11) << std::right
;
87 oss
<< 123456l << ":" << std::endl
;
89 oss
<< ":" << std::setw(11) << std::internal
;
90 oss
<< 123l << ":" << std::endl
;
93 oss
<< std::hex
<< std::setfill('0');
94 oss
<< 0x12345678l
<< std::endl
;
96 oss
<< "|" << std::setw(16);
97 oss
<< 0x12345678l
<< "|" << std::endl
;
99 oss
<< "|" << std::setw(16) << std::left
;
100 oss
<< 0x12345678l
<< "|" << std::endl
;
102 oss
<< "|" << std::setw(16) << std::right
;
103 oss
<< 0x12345678l
<< "|" << std::endl
;
105 oss
<< "|" << std::setw(16) << std::internal
;
106 oss
<< 0x12345678l
<< "|" << std::endl
;
108 VERIFY( oss
.good() );
109 VERIFY( oss
.str() == lit
);