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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [22_locale/] [num_put/] [put/] [wchar_t/] [2.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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