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/] [money_get/] [get/] [char/] [6.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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