]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/num_put/put/char/38210.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / num_put / put / char / 38210.cc
CommitLineData
5624e564 1// Copyright (C) 2008-2015 Free Software Foundation, Inc.
d2f6b13b
PC
2//
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
748086b7 6// Free Software Foundation; either version 3, or (at your option)
d2f6b13b
PC
7// any later version.
8
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.
13
14// You should have received a copy of the GNU General Public License along
748086b7
JJ
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
d2f6b13b
PC
17
18// 22.2.2.2.1 num_put members
19
20#include <locale>
21#include <sstream>
22#include <testsuite_hooks.h>
23
24// libstdc++/38210
25void test01()
26{
27 bool test __attribute__((unused)) = true;
28 using namespace std;
29
30 ostringstream oss1, oss2, oss3, oss4;
31 string result1, result2, result3, result4;
32
33 const num_put<char>& ng1 = use_facet<num_put<char> >(oss1.getloc());
34 const num_put<char>& ng2 = use_facet<num_put<char> >(oss2.getloc());
35 const num_put<char>& ng3 = use_facet<num_put<char> >(oss3.getloc());
36 const num_put<char>& ng4 = use_facet<num_put<char> >(oss4.getloc());
37
38 void* p = (void*)0x1;
39
40 oss1.width(5);
d2f6b13b
PC
41 ng1.put(oss1.rdbuf(), oss1, '*', p);
42 result1 = oss1.str();
43 VERIFY( result1 == "**0x1" );
44
45 oss2.width(5);
46 oss2.setf(ios_base::right, ios_base::adjustfield);
d2f6b13b
PC
47 ng2.put(oss2.rdbuf(), oss2, '*', p);
48 result2 = oss2.str();
49 VERIFY( result2 == "**0x1" );
50
51 oss3.width(5);
52 oss3.setf(ios_base::internal, ios_base::adjustfield);
d2f6b13b
PC
53 ng3.put(oss3.rdbuf(), oss3, '*', p);
54 result3 = oss3.str();
55 VERIFY( result3 == "0x**1" );
56
57 oss4.width(5);
58 oss4.setf(ios_base::left, ios_base::adjustfield);
d2f6b13b
PC
59 ng4.put(oss4.rdbuf(), oss4, '*', p);
60 result4 = oss4.str();
61 VERIFY( result4 == "0x1**" );
62}
63
64int main()
65{
66 test01();
67 return 0;
68}