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/] [6.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// 2001-09-12 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.6.1.1 money_get members
22
 
23
#include <locale>
24
#include <sstream>
25
#include <testsuite_hooks.h>
26
 
27
struct My_money_io : public std::moneypunct<wchar_t,false>
28
{
29
  char_type do_decimal_point() const { return '.'; }
30
  std::string do_grouping() const { return "\004"; }
31
 
32
  std::wstring do_curr_symbol() const { return L"$"; }
33
  std::wstring do_positive_sign() const { return L""; }
34
  std::wstring do_negative_sign() const { return L"-"; }
35
 
36
  int do_frac_digits() const { return 2; }
37
 
38
  pattern do_neg_format() const
39
  {
40
    pattern pat = { { symbol, none, sign, value } };
41
    return pat;
42
  }
43
};
44
 
45
// libstdc++/5579
46
void test06()
47
{
48
  using namespace std;
49
  typedef istreambuf_iterator<wchar_t> InIt;
50
 
51
  bool test __attribute__((unused)) = true;
52
 
53
  locale loc(locale::classic(), new My_money_io);
54
 
55
  wstring bufferp(L"$1234.56");
56
  wstring buffern(L"$-1234.56");
57
  wstring bufferp_ns(L"1234.56");
58
  wstring buffern_ns(L"-1234.56");
59
 
60
  bool intl = false;
61
 
62
  InIt iendp, iendn, iendp_ns, iendn_ns;
63
  ios_base::iostate err;
64
  wstring valp, valn, valp_ns, valn_ns;
65
 
66
  const money_get<wchar_t,InIt>& mg = use_facet<money_get<wchar_t, InIt> >(loc);
67
  wistringstream fmtp(bufferp);
68
  fmtp.imbue(loc);
69
  InIt ibegp(fmtp);
70
  mg.get(ibegp,iendp,intl,fmtp,err,valp);
71
  VERIFY( valp == L"123456" );
72
 
73
  wistringstream fmtn(buffern);
74
  fmtn.imbue(loc);
75
  InIt ibegn(fmtn);
76
  mg.get(ibegn,iendn,intl,fmtn,err,valn);
77
  VERIFY( valn == L"-123456" );
78
 
79
  wistringstream fmtp_ns(bufferp_ns);
80
  fmtp_ns.imbue(loc);
81
  InIt ibegp_ns(fmtp_ns);
82
  mg.get(ibegp_ns,iendp_ns,intl,fmtp_ns,err,valp_ns);
83
  VERIFY( valp_ns == L"123456" );
84
 
85
  wistringstream fmtn_ns(buffern_ns);
86
  fmtn_ns.imbue(loc);
87
  InIt ibegn_ns(fmtn_ns);
88
  mg.get(ibegn_ns,iendn_ns,intl,fmtn_ns,err,valn_ns);
89
  VERIFY( valn_ns == L"-123456" );
90
}
91
 
92
int main()
93
{
94
  test06();
95
  return 0;
96
}

powered by: WebSVN 2.1.0

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