]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/manipulators/adjustfield/char/1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / manipulators / adjustfield / char / 1.cc
CommitLineData
b2dad0e3
BK
1// 981027 ncm work with libstdc++v3
2
a945c346 3// Copyright (C) 1997-2024 Free Software Foundation, Inc.
b2dad0e3
BK
4//
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
748086b7 8// Free Software Foundation; either version 3, or (at your option)
b2dad0e3
BK
9// any later version.
10
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.
15
16// You should have received a copy of the GNU General Public License along
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
b2dad0e3 19
b2dad0e3 20
b2dad0e3
BK
21#include <sstream>
22#include <locale>
23#include <iomanip>
fe413112 24#include <testsuite_hooks.h>
b2dad0e3
BK
25
26struct MyNP : std::numpunct<char>
27{
28 std::string do_truename() const;
29 std::string do_falsename() const;
30};
31
0be27b59
PC
32std::string
33MyNP::do_truename() const
2dc8835a 34{
694d519f 35 std::string s("yea");
2dc8835a
PC
36 return s;
37}
38
0be27b59
PC
39std::string
40MyNP::do_falsename() const
2dc8835a 41{
694d519f 42 std::string s("nay");
2dc8835a
PC
43 return s;
44}
b2dad0e3 45
2dc8835a 46void
aa1b2f7d 47test01()
b2dad0e3 48{
0be27b59
PC
49 const char lit[] = "1 0\n"
50 "true false\n"
51 ": true:\n"
52 ":true :\n"
53 ": false:\n"
54 ": 1:\n"
55 ":1 :\n"
56 ": 0:\n"
57 "yea nay\n"
58 ": yea:\n"
59 ":yea :\n"
60 ": nay:\n";
61
2dc8835a
PC
62 std::ostringstream oss;
63 oss << true << " " << false << std::endl;
64 oss << std::boolalpha;
65 oss << true << " " << false << std::endl;
66
67 oss << ":" << std::setw(6) << std::internal << true << ":" << std::endl;
68 oss << ":" << std::setw(6) << std::left << true << ":" << std::endl;
69 oss << ":" << std::setw(6) << std::right << false << ":" << std::endl;
70 oss << std::noboolalpha;
71 oss << ":" << std::setw(3) << std::internal << true << ":" << std::endl;
72 oss << ":" << std::setw(3) << std::left << true << ":" << std::endl;
73 oss << ":" << std::setw(3) << std::right << false << ":" << std::endl;
b2dad0e3 74
0be27b59 75 std::locale loc = std::locale(std::locale::classic(), new MyNP);
2dc8835a 76 oss.imbue(loc);
b2dad0e3 77
2dc8835a
PC
78 oss << std::boolalpha;
79 oss << true << " " << false << std::endl;
b2dad0e3 80
2dc8835a
PC
81 oss << ":" << std::setw(6) << std::internal << true << ":" << std::endl;
82 oss << ":" << std::setw(6) << std::left << true << ":" << std::endl;
83 oss << ":" << std::setw(6) << std::right << false << ":" << std::endl;
b2dad0e3 84
2dc8835a
PC
85 VERIFY( oss.good() );
86 VERIFY( oss.str() == lit );
b2dad0e3
BK
87}
88
aa1b2f7d 89int
2dc8835a
PC
90main()
91{
b2dad0e3 92 test01();
b2dad0e3
BK
93 return 0;
94}