1*03a78d15Sespie // 2001-08-24 Benjamin Kosnik <bkoz@redhat.com> 2*03a78d15Sespie 3*03a78d15Sespie // Copyright (C) 2001 Free Software Foundation 4*03a78d15Sespie // 5*03a78d15Sespie // This file is part of the GNU ISO C++ Library. This library is free 6*03a78d15Sespie // software; you can redistribute it and/or modify it under the 7*03a78d15Sespie // terms of the GNU General Public License as published by the 8*03a78d15Sespie // Free Software Foundation; either version 2, or (at your option) 9*03a78d15Sespie // any later version. 10*03a78d15Sespie 11*03a78d15Sespie // This library is distributed in the hope that it will be useful, 12*03a78d15Sespie // but WITHOUT ANY WARRANTY; without even the implied warranty of 13*03a78d15Sespie // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*03a78d15Sespie // GNU General Public License for more details. 15*03a78d15Sespie 16*03a78d15Sespie // You should have received a copy of the GNU General Public License along 17*03a78d15Sespie // with this library; see the file COPYING. If not, write to the Free 18*03a78d15Sespie // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19*03a78d15Sespie // USA. 20*03a78d15Sespie 21*03a78d15Sespie // 22.2.6.4 Template class moneypunct_byname 22*03a78d15Sespie 23*03a78d15Sespie #include <locale> 24*03a78d15Sespie #include <testsuite_hooks.h> 25*03a78d15Sespie 26*03a78d15Sespie // XXX This test is not working for non-glibc locale models. 27*03a78d15Sespie // { dg-do run { xfail *-*-* } } 28*03a78d15Sespie test01()29*03a78d15Sespievoid test01() 30*03a78d15Sespie { 31*03a78d15Sespie using namespace std; 32*03a78d15Sespie typedef money_base::part part; 33*03a78d15Sespie typedef money_base::pattern pattern; 34*03a78d15Sespie 35*03a78d15Sespie bool test = true; 36*03a78d15Sespie string str; 37*03a78d15Sespie 38*03a78d15Sespie locale loc_byname(locale::classic(), new moneypunct_byname<char>("de_DE")); 39*03a78d15Sespie str = loc_byname.name(); 40*03a78d15Sespie 41*03a78d15Sespie locale loc_de("de_DE"); 42*03a78d15Sespie str = loc_de.name(); 43*03a78d15Sespie 44*03a78d15Sespie locale loc_c = locale::classic(); 45*03a78d15Sespie 46*03a78d15Sespie VERIFY( loc_de != loc_byname ); 47*03a78d15Sespie 48*03a78d15Sespie // cache the moneypunct facets 49*03a78d15Sespie const moneypunct<char>& monp_c = use_facet<moneypunct<char> >(loc_c); 50*03a78d15Sespie const moneypunct<char>& monp_byname = 51*03a78d15Sespie use_facet<moneypunct<char> >(loc_byname); 52*03a78d15Sespie const moneypunct<char>& monp_de = use_facet<moneypunct<char> >(loc_de); 53*03a78d15Sespie 54*03a78d15Sespie // sanity check that the data match 55*03a78d15Sespie char dp1 = monp_de.decimal_point(); 56*03a78d15Sespie char th1 = monp_de.thousands_sep(); 57*03a78d15Sespie string g1 = monp_de.grouping(); 58*03a78d15Sespie string cs1 = monp_de.curr_symbol(); 59*03a78d15Sespie string ps1 = monp_de.positive_sign(); 60*03a78d15Sespie string ns1 = monp_de.negative_sign(); 61*03a78d15Sespie int fd1 = monp_de.frac_digits(); 62*03a78d15Sespie pattern pos1 = monp_de.pos_format(); 63*03a78d15Sespie pattern neg1 = monp_de.neg_format(); 64*03a78d15Sespie 65*03a78d15Sespie char dp2 = monp_byname.decimal_point(); 66*03a78d15Sespie char th2 = monp_byname.thousands_sep(); 67*03a78d15Sespie string g2 = monp_byname.grouping(); 68*03a78d15Sespie string cs2 = monp_byname.curr_symbol(); 69*03a78d15Sespie string ps2 = monp_byname.positive_sign(); 70*03a78d15Sespie string ns2 = monp_byname.negative_sign(); 71*03a78d15Sespie int fd2 = monp_byname.frac_digits(); 72*03a78d15Sespie pattern pos2 = monp_byname.pos_format(); 73*03a78d15Sespie pattern neg2 = monp_byname.neg_format(); 74*03a78d15Sespie 75*03a78d15Sespie VERIFY( dp1 == dp2 ); 76*03a78d15Sespie VERIFY( th1 == th2 ); 77*03a78d15Sespie VERIFY( g1 == g2 ); 78*03a78d15Sespie VERIFY( cs1 == cs2 ); 79*03a78d15Sespie VERIFY( ps1 == ps2 ); 80*03a78d15Sespie VERIFY( ns1 == ns2 ); 81*03a78d15Sespie VERIFY( fd1 == fd2 ); 82*03a78d15Sespie VERIFY(static_cast<part>(pos1.field[0]) == static_cast<part>(pos2.field[0])); 83*03a78d15Sespie VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1])); 84*03a78d15Sespie VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2])); 85*03a78d15Sespie VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3])); 86*03a78d15Sespie 87*03a78d15Sespie VERIFY(static_cast<part>(neg1.field[0]) == static_cast<part>(neg2.field[0])); 88*03a78d15Sespie VERIFY(static_cast<part>(neg1.field[1]) == static_cast<part>(neg2.field[1])); 89*03a78d15Sespie VERIFY(static_cast<part>(neg1.field[2]) == static_cast<part>(neg2.field[2])); 90*03a78d15Sespie VERIFY(static_cast<part>(neg1.field[3]) == static_cast<part>(neg2.field[3])); 91*03a78d15Sespie 92*03a78d15Sespie // ...and don't match "C" 93*03a78d15Sespie char dp3 = monp_c.decimal_point(); 94*03a78d15Sespie VERIFY( dp1 != dp3 ); 95*03a78d15Sespie } 96*03a78d15Sespie main()97*03a78d15Sespieint main() 98*03a78d15Sespie { 99*03a78d15Sespie test01(); 100*03a78d15Sespie 101*03a78d15Sespie return 0; 102*03a78d15Sespie } 103