OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [27_io/] [manipulators/] [basefield/] [wchar_t/] [1.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// Copyright (C) 2004 Free Software Foundation, Inc.
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
6
// Free Software Foundation; either version 2, or (at your option)
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
15
// with this library; see the file COPYING.  If not, write to the Free
16
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
// USA.
18
 
19
// As a special exception, you may use this file as part of a free software
20
// library without restriction.  Specifically, if other files instantiate
21
// templates or use macros or inline functions from this file, or you compile
22
// this file and link it with other files to produce an executable, this
23
// file does not by itself cause the resulting executable to be covered by
24
// the GNU General Public License.  This exception does not however
25
// invalidate any other reasons why the executable file might be covered by
26
// the GNU General Public License.
27
 
28
#include <sstream>
29
#include <locale>
30
#include <iomanip>
31
#include <testsuite_hooks.h>
32
 
33
struct MyNP : std::numpunct<wchar_t>
34
{
35
  std::string do_grouping() const;
36
  wchar_t do_thousands_sep() const;
37
};
38
 
39
std::string
40
MyNP::do_grouping() const
41
{
42
  std::string s("\3");
43
  return s;
44
}
45
 
46
wchar_t
47
MyNP::do_thousands_sep() const
48
{ return L' '; }
49
 
50
void test01()
51
{
52
  bool test __attribute__((unused)) = true;
53
  const wchar_t lit[] = L"0123 456\n"
54
                        L": 01 234 567:\n"
55
                        L":0123 456   :\n"
56
                        L":    012 345:\n"
57
                        L":     01 234:\n"
58
                        L":0726 746 425:\n"
59
                        L":04 553 207 :\n"
60
                        L":   0361 100:\n"
61
                        L":       0173:\n"
62
                        L"0x12 345 678\n"
63
                        L"|0x000012 345 678|\n"
64
                        L"|0x12 345 6780000|\n"
65
                        L"|00000x12 345 678|\n"
66
                        L"|0x000012 345 678|\n";
67
 
68
  std::wostringstream oss;
69
  oss.imbue(std::locale(std::locale(), new MyNP));
70
 
71
  // Octals
72
  oss << std::oct << std::showbase;
73
  oss << 0123456l << std::endl;
74
 
75
  oss << L":" << std::setw(11);
76
  oss << 01234567l << L":" << std::endl;
77
 
78
  oss << L":" << std::setw(11) << std::left;
79
  oss << 0123456l << L":" << std::endl;
80
 
81
  oss << L":" << std::setw(11) << std::right;
82
  oss << 012345l << L":" << std::endl;
83
 
84
  oss << L":" << std::setw(11) << std::internal;
85
  oss << 01234l << L":" << std::endl;
86
 
87
  oss << L":" << std::setw(11);
88
  oss << 123456789l << L":" << std::endl;
89
 
90
  oss << L":" << std::setw(11) << std::left;
91
  oss << 1234567l << L":" << std::endl;
92
 
93
  oss << L":" << std::setw(11) << std::right;
94
  oss << 123456l << L":" << std::endl;
95
 
96
  oss << L":" << std::setw(11) << std::internal;
97
  oss << 123l << L":" << std::endl;
98
 
99
  // Hexadecimals
100
  oss << std::hex << std::setfill(L'0');
101
  oss << 0x12345678l << std::endl;
102
 
103
  oss << L"|" << std::setw(16);
104
  oss << 0x12345678l << L"|" << std::endl;
105
 
106
  oss << L"|" << std::setw(16) << std::left;
107
  oss << 0x12345678l << L"|" << std::endl;
108
 
109
  oss << L"|" << std::setw(16) << std::right;
110
  oss << 0x12345678l << L"|" << std::endl;
111
 
112
  oss << L"|" << std::setw(16) << std::internal;
113
  oss << 0x12345678l << L"|" << std::endl;
114
 
115
  VERIFY( oss.good() );
116
  VERIFY( oss.str() == lit );
117
}
118
 
119
int
120
main()
121
{
122
  test01();
123
  return 0;
124
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.