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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [22_locale/] [num_put/] [put/] [wchar_t/] [2.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 2001-11-19 Benjamin Kosnik  <bkoz@redhat.com>
2
 
3
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation
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
8
// Free Software Foundation; either version 2, or (at your option)
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
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,
19
// USA.
20
 
21
// 22.2.2.2.1  num_put members
22
 
23
#include <locale>
24
#include <sstream>
25
#include <testsuite_hooks.h>
26
 
27
void test02()
28
{
29
  using namespace std;
30
  typedef ostreambuf_iterator<wchar_t> iterator_type;
31
 
32
  bool test __attribute__((unused)) = true;
33
 
34
  // basic construction
35
  locale loc_c = locale::classic();
36
 
37
  // sanity check the data is correct.
38
  const wstring empty;
39
  wstring result1;
40
  wstring result2;
41
 
42
  bool b1 = true;
43
  bool b0 = false;
44
  unsigned long ul1 = 1294967294;
45
  unsigned long ul2 = 0;
46
 
47
  // cache the num_put facet
48
  wostringstream oss;
49
  oss.imbue(loc_c);
50
  const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
51
 
52
  // C
53
  // bool, more twisted examples
54
  oss.str(empty);
55
  oss.width(20);
56
  oss.setf(ios_base::right, ios_base::adjustfield);
57
  np.put(oss.rdbuf(), oss, L'+', b0);
58
  result1 = oss.str();
59
  VERIFY( result1 == L"+++++++++++++++++++0" );
60
 
61
  oss.str(empty);
62
  oss.width(20);
63
  oss.setf(ios_base::left, ios_base::adjustfield);
64
  oss.setf(ios_base::boolalpha);
65
  np.put(oss.rdbuf(), oss, L'+', b1);
66
  result2 = oss.str();
67
  VERIFY( result2 == L"true++++++++++++++++" );
68
 
69
  // unsigned long, in a locale that does not group
70
  oss.imbue(loc_c);
71
  oss.str(empty);
72
  oss.clear();
73
  np.put(oss.rdbuf(), oss, L'+', ul1);
74
  result1 = oss.str();
75
  VERIFY( result1 == L"1294967294" );
76
 
77
  oss.str(empty);
78
  oss.clear();
79
  oss.width(20);
80
  oss.setf(ios_base::left, ios_base::adjustfield);
81
  np.put(oss.rdbuf(), oss, L'+', ul2);
82
  result1 = oss.str();
83
  VERIFY( result1 == L"0+++++++++++++++++++" );
84
}
85
 
86
int main()
87
{
88
  test02();
89
  return 0;
90
}

powered by: WebSVN 2.1.0

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