]>
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, 1998, 1999, 2002 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 2, 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 COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
33 #include <testsuite_hooks.h>
35 struct MyNP
: std::numpunct
<char>
37 std::string
do_grouping() const;
38 char do_thousands_sep() const;
42 MyNP::do_grouping() const
49 MyNP::do_thousands_sep() const
54 bool test
__attribute__((unused
)) = true;
55 const char lit
[] = "0123 456\n"
65 "|0x000012 345 678|\n"
66 "|0x12 345 6780000|\n"
67 "|00000x12 345 678|\n"
68 "|0x000012 345 678|\n";
70 std::ostringstream oss
;
71 oss
.imbue(std::locale(std::locale(), new MyNP
));
74 oss
<< std::oct
<< std::showbase
;
75 oss
<< 0123456l << std::endl
;
77 oss
<< ":" << std::setw(11);
78 oss
<< 01234567l << ":" << std::endl
;
80 oss
<< ":" << std::setw(11) << std::left
;
81 oss
<< 0123456l << ":" << std::endl
;
83 oss
<< ":" << std::setw(11) << std::right
;
84 oss
<< 012345l << ":" << std::endl
;
86 oss
<< ":" << std::setw(11) << std::internal
;
87 oss
<< 01234l << ":" << std::endl
;
89 oss
<< ":" << std::setw(11);
90 oss
<< 123456789l << ":" << std::endl
;
92 oss
<< ":" << std::setw(11) << std::left
;
93 oss
<< 1234567l << ":" << std::endl
;
95 oss
<< ":" << std::setw(11) << std::right
;
96 oss
<< 123456l << ":" << std::endl
;
98 oss
<< ":" << std::setw(11) << std::internal
;
99 oss
<< 123l << ":" << std::endl
;
102 oss
<< std::hex
<< std::setfill('0');
103 oss
<< 0x12345678l
<< std::endl
;
105 oss
<< "|" << std::setw(16);
106 oss
<< 0x12345678l
<< "|" << std::endl
;
108 oss
<< "|" << std::setw(16) << std::left
;
109 oss
<< 0x12345678l
<< "|" << std::endl
;
111 oss
<< "|" << std::setw(16) << std::right
;
112 oss
<< 0x12345678l
<< "|" << std::endl
;
114 oss
<< "|" << std::setw(16) << std::internal
;
115 oss
<< 0x12345678l
<< "|" << std::endl
;
117 VERIFY( oss
.good() );
118 VERIFY( oss
.str() == lit
);