1 // 2001-09-09 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001, 2002 Free Software Foundation
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)
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.
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // 22.2.6.3.1 moneypunct members
24 #include <testsuite_hooks.h>
26 // XXX This test is not working for non-glibc locale models.
27 // { dg-do run { xfail *-*-* } }
29 #ifdef _GLIBCPP_USE_WCHAR_T
33 typedef money_base::part part;
34 typedef money_base::pattern pattern;
39 locale loc_c = locale::classic();
40 locale loc_us("en_US");
41 locale loc_fr("fr_FR");
42 locale loc_de("de_DE");
43 VERIFY( loc_c != loc_de );
44 VERIFY( loc_us != loc_fr );
45 VERIFY( loc_us != loc_de );
46 VERIFY( loc_de != loc_fr );
48 // cache the moneypunct facets
49 typedef moneypunct<wchar_t, true> __money_true;
50 typedef moneypunct<wchar_t, false> __money_false;
51 const __money_true& monp_c_t = use_facet<__money_true>(loc_c);
52 const __money_true& monp_us_t = use_facet<__money_true>(loc_us);
53 const __money_true& monp_fr_t = use_facet<__money_true>(loc_fr);
54 const __money_true& monp_de_t = use_facet<__money_true>(loc_de);
55 const __money_false& monp_c_f = use_facet<__money_false>(loc_c);
56 const __money_false& monp_us_f = use_facet<__money_false>(loc_us);
57 const __money_false& monp_fr_f = use_facet<__money_false>(loc_fr);
58 const __money_false& monp_de_f = use_facet<__money_false>(loc_de);
60 // quick sanity check for data.
61 wchar_t q1 = monp_c_t.decimal_point();
62 wchar_t q2 = monp_c_t.thousands_sep();
63 wchar_t q3 = monp_c_f.decimal_point();
64 wchar_t q4 = monp_c_f.thousands_sep();
65 VERIFY( q1 != wchar_t() );
66 VERIFY( q2 != wchar_t() );
67 VERIFY( q3 != wchar_t() );
68 VERIFY( q4 != wchar_t() );
70 // sanity check the data is correct.
71 wchar_t dp1 = monp_c_t.decimal_point();
72 wchar_t th1 = monp_c_t.thousands_sep();
73 string g1 = monp_c_t.grouping();
74 wstring cs1 = monp_c_t.curr_symbol();
75 wstring ps1 = monp_c_t.positive_sign();
76 wstring ns1 = monp_c_t.negative_sign();
77 int fd1 = monp_c_t.frac_digits();
78 pattern pos1 = monp_c_t.pos_format();
79 pattern neg1 = monp_c_t.neg_format();
81 wchar_t dp2 = monp_de_t.decimal_point();
82 wchar_t th2 = monp_de_t.thousands_sep();
83 string g2 = monp_de_t.grouping();
84 wstring cs2 = monp_de_t.curr_symbol();
85 wstring ps2 = monp_de_t.positive_sign();
86 wstring ns2 = monp_de_t.negative_sign();
87 int fd2 = monp_de_t.frac_digits();
88 pattern pos2 = monp_de_t.pos_format();
89 pattern neg2 = monp_de_t.neg_format();
95 // VERIFY( ps1 != ps2 );
98 VERIFY(static_cast<part>(pos1.field[0]) != static_cast<part>(pos2.field[0]));
99 VERIFY(static_cast<part>(pos1.field[1]) != static_cast<part>(pos2.field[1]));
100 VERIFY(static_cast<part>(pos1.field[2]) != static_cast<part>(pos2.field[2]));
101 VERIFY(static_cast<part>(pos1.field[3]) != static_cast<part>(pos2.field[3]));
103 VERIFY(static_cast<part>(neg1.field[0]) != static_cast<part>(neg2.field[0]));
104 VERIFY(static_cast<part>(neg1.field[1]) != static_cast<part>(neg2.field[1]));
105 VERIFY(static_cast<part>(neg1.field[2]) != static_cast<part>(neg2.field[2]));
106 VERIFY(static_cast<part>(neg1.field[3]) != static_cast<part>(neg2.field[3]));
112 #ifdef _GLIBCPP_HAVE_SETENV
113 // Set the global locale to non-"C".
114 std::locale loc_de("de_DE");
115 std::locale::global(loc_de);
117 // Set LANG environment variable to de_DE.
118 const char* oldLANG = getenv("LANG");
119 if (!setenv("LANG", "de_DE", 1))
122 setenv("LANG", oldLANG ? oldLANG : "", 1);
130 #ifdef _GLIBCPP_USE_WCHAR_T