Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / testsuite / 22_locale / moneypunct_byname / named_equivalence.cc
blob924f01104666dfb094918dfe7abaf95f2510eb92
1 // { dg-require-namedlocale "" }
3 // 2001-08-24 Benjamin Kosnik <bkoz@redhat.com>
5 // Copyright (C) 2001, 2003, 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.
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.
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.
23 // 22.2.6.4 Template class moneypunct_byname
25 #include <locale>
26 #include <testsuite_hooks.h>
28 void test01()
30 using namespace std;
31 typedef money_base::part part;
32 typedef money_base::pattern pattern;
34 bool test __attribute__((unused)) = true;
35 string str;
37 locale loc_de = locale("de_DE");
38 str = loc_de.name();
40 locale loc_byname(locale::classic(), new moneypunct_byname<char>("de_DE"));
41 str = loc_byname.name();
43 locale loc_c = locale::classic();
45 VERIFY( loc_de != loc_byname );
47 // cache the moneypunct facets
48 const moneypunct<char>& monp_c = use_facet<moneypunct<char> >(loc_c);
49 const moneypunct<char>& monp_byname =
50 use_facet<moneypunct<char> >(loc_byname);
51 const moneypunct<char>& monp_de = use_facet<moneypunct<char> >(loc_de);
53 // sanity check that the data match
54 char dp1 = monp_de.decimal_point();
55 char th1 = monp_de.thousands_sep();
56 string g1 = monp_de.grouping();
57 string cs1 = monp_de.curr_symbol();
58 string ps1 = monp_de.positive_sign();
59 string ns1 = monp_de.negative_sign();
60 int fd1 = monp_de.frac_digits();
61 pattern pos1 = monp_de.pos_format();
62 pattern neg1 = monp_de.neg_format();
64 char dp2 = monp_byname.decimal_point();
65 char th2 = monp_byname.thousands_sep();
66 string g2 = monp_byname.grouping();
67 string cs2 = monp_byname.curr_symbol();
68 string ps2 = monp_byname.positive_sign();
69 string ns2 = monp_byname.negative_sign();
70 int fd2 = monp_byname.frac_digits();
71 pattern pos2 = monp_byname.pos_format();
72 pattern neg2 = monp_byname.neg_format();
74 VERIFY( dp1 == dp2 );
75 VERIFY( th1 == th2 );
76 VERIFY( g1 == g2 );
77 VERIFY( cs1 == cs2 );
78 VERIFY( ps1 == ps2 );
79 VERIFY( ns1 == ns2 );
80 VERIFY( fd1 == fd2 );
81 VERIFY(static_cast<part>(pos1.field[0]) == static_cast<part>(pos2.field[0]));
82 VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1]));
83 VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2]));
84 VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3]));
86 VERIFY(static_cast<part>(neg1.field[0]) == static_cast<part>(neg2.field[0]));
87 VERIFY(static_cast<part>(neg1.field[1]) == static_cast<part>(neg2.field[1]));
88 VERIFY(static_cast<part>(neg1.field[2]) == static_cast<part>(neg2.field[2]));
89 VERIFY(static_cast<part>(neg1.field[3]) == static_cast<part>(neg2.field[3]));
91 // ...and don't match "C"
92 char dp3 = monp_c.decimal_point();
93 VERIFY( dp1 != dp3 );
96 int main()
98 test01();
99 return 0;