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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc4/] [libstdc++-v3/] [testsuite/] [22_locale/] [num_get/] [get/] [wchar_t/] [22131.cc] - Blame information for rev 519

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// 2005-06-28  Paolo Carlini  <pcarlini@suse.de>
2
 
3
// Copyright (C) 2005, 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.1.1  num_get members
21
 
22
#include <locale>
23
#include <sstream>
24
#include <testsuite_hooks.h>
25
 
26
struct Punct: std::numpunct<wchar_t>
27
{
28
  std::string do_grouping() const { return "\1"; }
29
  wchar_t do_thousands_sep() const { return L'#'; }
30
};
31
 
32
// libstdc++/22131
33
void test01()
34
{
35
  using namespace std;
36
  typedef istreambuf_iterator<wchar_t> iterator_type;
37
 
38
  bool test __attribute__((unused)) = true;
39
 
40
  wistringstream iss1, iss2;
41
  iss1.imbue(locale(iss1.getloc(), new Punct));
42
  const num_get<wchar_t>& ng1 = use_facet<num_get<wchar_t> >(iss1.getloc());
43
 
44
  ios_base::iostate err = ios_base::goodbit;
45
  iterator_type end;
46
  long l = 0l;
47
  long l1 = 1l;
48
  long l2 = 2l;
49
  long l3 = 3l;
50
  double d = 0.0;
51
  double d1 = 1.0;
52
  double d2 = 2.0;
53
 
54
  iss1.str(L"00#0#1");
55
  err = ios_base::goodbit;
56
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
57
  VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
58
  VERIFY( l == l1 );
59
 
60
  iss1.str(L"000##2");
61
  iss1.clear();
62
  err = ios_base::goodbit;
63
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
64
  VERIFY( err == ios_base::failbit );
65
  VERIFY( *end == L'#' );
66
  VERIFY( l == 0 );
67
 
68
  iss1.str(L"0#0#0#2");
69
  iss1.clear();
70
  err = ios_base::goodbit;
71
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
72
  VERIFY( err == ios_base::eofbit );
73
  VERIFY( l == l2 );
74
 
75
  iss1.str(L"00#0#1");
76
  iss1.clear();
77
  err = ios_base::goodbit;
78
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
79
  VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
80
  VERIFY( d == d1 );
81
 
82
  iss1.str(L"000##2");
83
  iss1.clear();
84
  err = ios_base::goodbit;
85
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
86
  VERIFY( err == ios_base::failbit );
87
  VERIFY( *end == L'#' );
88
  VERIFY( d == 0.0 );
89
 
90
  iss1.str(L"0#0#0#2");
91
  iss1.clear();
92
  err = ios_base::goodbit;
93
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
94
  VERIFY( err == ios_base::eofbit );
95
  VERIFY( d == d2 );
96
 
97
  iss1.str(L"0#0");
98
  iss1.clear();
99
  iss1.unsetf(ios::basefield);
100
  err = ios_base::goodbit;
101
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
102
  VERIFY( err == ios_base::failbit );
103
  VERIFY( *end == L'#' );
104
  VERIFY( l == 0 );
105
 
106
  iss1.str(L"00#0#3");
107
  iss1.clear();
108
  err = ios_base::goodbit;
109
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
110
  VERIFY( err == ios_base::eofbit );
111
  VERIFY( l == l3 );
112
 
113
  iss1.str(L"00#02");
114
  iss1.clear();
115
  err = ios_base::goodbit;
116
  end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
117
  VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
118
  VERIFY( l == l2 );
119
}
120
 
121
int main()
122
{
123
  test01();
124
  return 0;
125
}

powered by: WebSVN 2.1.0

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