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/] [money_get/] [get/] [wchar_t/] [2.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// { dg-require-namedlocale "" }
2
 
3
// 2001-09-12 Benjamin Kosnik  <bkoz@redhat.com>
4
 
5
// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation
6
//
7
// This file is part of the GNU ISO C++ Library.  This library is free
8
// software; you can redistribute it and/or modify it under the
9
// terms of the GNU General Public License as published by the
10
// Free Software Foundation; either version 2, or (at your option)
11
// any later version.
12
 
13
// This library is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
// GNU General Public License for more details.
17
 
18
// You should have received a copy of the GNU General Public License along
19
// with this library; see the file COPYING.  If not, write to the Free
20
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21
// USA.
22
 
23
// 22.2.6.1.1 money_get members
24
 
25
#include <locale>
26
#include <sstream>
27
#include <testsuite_hooks.h>
28
 
29
// test wstring version
30
void test02()
31
{
32
  using namespace std;
33
  typedef istreambuf_iterator<wchar_t> iterator_type;
34
 
35
  bool test __attribute__((unused)) = true;
36
 
37
  // basic construction
38
  locale loc_c = locale::classic();
39
  locale loc_hk = locale("en_HK");
40
  VERIFY( loc_c != loc_hk );
41
 
42
  // total EPA budget FY 2002
43
  const wstring digits1(L"720000000000");
44
 
45
  // est. cost, national missile "defense", expressed as a loss in USD 2001
46
  const wstring digits2(L"-10000000000000");
47
 
48
  // input less than frac_digits
49
  const wstring digits4(L"-1");
50
 
51
  iterator_type end;
52
  wistringstream iss;
53
  iss.imbue(loc_hk);
54
  // cache the money_get facet
55
  const money_get<wchar_t>& mon_get = use_facet<money_get<wchar_t> >(iss.getloc());
56
 
57
  // now try with showbase, to get currency symbol in format
58
  iss.setf(ios_base::showbase);
59
 
60
  iss.str(L"HK$7,200,000,000.00");
61
  iterator_type is_it09(iss);
62
  wstring result9;
63
  ios_base::iostate err09 = ios_base::goodbit;
64
  mon_get.get(is_it09, end, false, iss, err09, result9);
65
  VERIFY( result9 == digits1 );
66
  VERIFY( err09 == ios_base::eofbit );
67
 
68
  iss.str(L"(HKD 100,000,000,000.00)");
69
  iterator_type is_it10(iss);
70
  wstring result10;
71
  ios_base::iostate err10 = ios_base::goodbit;
72
  mon_get.get(is_it10, end, true, iss, err10, result10);
73
  VERIFY( result10 == digits2 );
74
  VERIFY( err10 == ios_base::eofbit );
75
 
76
  iss.str(L"(HKD .01)");
77
  iterator_type is_it11(iss);
78
  wstring result11;
79
  ios_base::iostate err11 = ios_base::goodbit;
80
  mon_get.get(is_it11, end, true, iss, err11, result11);
81
  VERIFY( result11 == digits4 );
82
  VERIFY( err11 == ios_base::eofbit );
83
 
84
  // for the "en_HK" locale the parsing of the very same input streams must
85
  // be successful without showbase too, since the symbol field appears in
86
  // the first positions in the format and the symbol, when present, must be
87
  // consumed.
88
  iss.unsetf(ios_base::showbase);
89
 
90
  iss.str(L"HK$7,200,000,000.00");
91
  iterator_type is_it12(iss);
92
  wstring result12;
93
  ios_base::iostate err12 = ios_base::goodbit;
94
  mon_get.get(is_it12, end, false, iss, err12, result12);
95
  VERIFY( result12 == digits1 );
96
  VERIFY( err12 == ios_base::eofbit );
97
 
98
  iss.str(L"(HKD 100,000,000,000.00)");
99
  iterator_type is_it13(iss);
100
  wstring result13;
101
  ios_base::iostate err13 = ios_base::goodbit;
102
  mon_get.get(is_it13, end, true, iss, err13, result13);
103
  VERIFY( result13 == digits2 );
104
  VERIFY( err13 == ios_base::eofbit );
105
 
106
  iss.str(L"(HKD .01)");
107
  iterator_type is_it14(iss);
108
  wstring result14;
109
  ios_base::iostate err14 = ios_base::goodbit;
110
  mon_get.get(is_it14, end, true, iss, err14, result14);
111
  VERIFY( result14 == digits4 );
112
  VERIFY( err14 == ios_base::eofbit );
113
}
114
 
115
int main()
116
{
117
  test02();
118
  return 0;
119
}

powered by: WebSVN 2.1.0

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