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/] [moneypunct_byname/] [named_equivalence.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// { dg-require-namedlocale "" }
2
 
3
// 2001-08-24 Benjamin Kosnik  <bkoz@redhat.com>
4
 
5
// Copyright (C) 2001, 2003, 2005, 2009 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 3, 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 COPYING3.  If not see
20
// <http://www.gnu.org/licenses/>.
21
 
22
// 22.2.6.4 Template class moneypunct_byname
23
 
24
#include <locale>
25
#include <testsuite_hooks.h>
26
 
27
void test01()
28
{
29
  using namespace std;
30
  typedef money_base::part part;
31
  typedef money_base::pattern pattern;
32
 
33
  bool test __attribute__((unused)) = true;
34
  string str;
35
 
36
  locale loc_de = locale("de_DE");
37
  str = loc_de.name();
38
 
39
  locale loc_byname(locale::classic(), new moneypunct_byname<char>("de_DE"));
40
  str = loc_byname.name();
41
 
42
  locale loc_c = locale::classic();
43
 
44
  VERIFY( loc_de != loc_byname );
45
 
46
  // cache the moneypunct facets
47
  const moneypunct<char>& monp_c = use_facet<moneypunct<char> >(loc_c);
48
  const moneypunct<char>& monp_byname =
49
                                    use_facet<moneypunct<char> >(loc_byname);
50
  const moneypunct<char>& monp_de = use_facet<moneypunct<char> >(loc_de);
51
 
52
  // sanity check that the data match
53
  char dp1 = monp_de.decimal_point();
54
  char th1 = monp_de.thousands_sep();
55
  string g1 = monp_de.grouping();
56
  string cs1 = monp_de.curr_symbol();
57
  string ps1 = monp_de.positive_sign();
58
  string ns1 = monp_de.negative_sign();
59
  int fd1 = monp_de.frac_digits();
60
  pattern pos1 = monp_de.pos_format();
61
  pattern neg1 = monp_de.neg_format();
62
 
63
  char dp2 = monp_byname.decimal_point();
64
  char th2 = monp_byname.thousands_sep();
65
  string g2 = monp_byname.grouping();
66
  string cs2 = monp_byname.curr_symbol();
67
  string ps2 = monp_byname.positive_sign();
68
  string ns2 = monp_byname.negative_sign();
69
  int fd2 = monp_byname.frac_digits();
70
  pattern pos2 = monp_byname.pos_format();
71
  pattern neg2 = monp_byname.neg_format();
72
 
73
  VERIFY( dp1 == dp2 );
74
  VERIFY( th1 == th2 );
75
  VERIFY( g1 == g2 );
76
  VERIFY( cs1 == cs2 );
77
  VERIFY( ps1 == ps2 );
78
  VERIFY( ns1 == ns2 );
79
  VERIFY( fd1 == fd2 );
80
  VERIFY(static_cast<part>(pos1.field[0]) == static_cast<part>(pos2.field[0]));
81
  VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1]));
82
  VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2]));
83
  VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3]));
84
 
85
  VERIFY(static_cast<part>(neg1.field[0]) == static_cast<part>(neg2.field[0]));
86
  VERIFY(static_cast<part>(neg1.field[1]) == static_cast<part>(neg2.field[1]));
87
  VERIFY(static_cast<part>(neg1.field[2]) == static_cast<part>(neg2.field[2]));
88
  VERIFY(static_cast<part>(neg1.field[3]) == static_cast<part>(neg2.field[3]));
89
 
90
  // ...and don't match "C"
91
  char dp3 = monp_c.decimal_point();
92
  VERIFY( dp1 != dp3 );
93
}
94
 
95
int main()
96
{
97
  test01();
98
  return 0;
99
}

powered by: WebSVN 2.1.0

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