1// 2001-08-24 Benjamin Kosnik <bkoz@redhat.com> 2 3// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free 18// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19// USA. 20 21// 22.2.6.4 Template class moneypunct_byname 22 23#include <locale> 24#include <testsuite_hooks.h> 25 26// XXX This test is not working for non-glibc locale models. 27// { dg-do run { xfail *-*-* } } 28 29void test01() 30{ 31 using namespace std; 32 typedef money_base::part part; 33 typedef money_base::pattern pattern; 34 35 bool test = true; 36 string str; 37 38 locale loc_byname(locale::classic(), new moneypunct_byname<char>("de_DE")); 39 str = loc_byname.name(); 40 41 locale loc_de("de_DE"); 42 str = loc_de.name(); 43 44 locale loc_c = locale::classic(); 45 46 VERIFY( loc_de != loc_byname ); 47 48 // cache the moneypunct facets 49 const moneypunct<char>& monp_c = use_facet<moneypunct<char> >(loc_c); 50 const moneypunct<char>& monp_byname = 51 use_facet<moneypunct<char> >(loc_byname); 52 const moneypunct<char>& monp_de = use_facet<moneypunct<char> >(loc_de); 53 54 // sanity check that the data match 55 char dp1 = monp_de.decimal_point(); 56 char th1 = monp_de.thousands_sep(); 57 string g1 = monp_de.grouping(); 58 string cs1 = monp_de.curr_symbol(); 59 string ps1 = monp_de.positive_sign(); 60 string ns1 = monp_de.negative_sign(); 61 int fd1 = monp_de.frac_digits(); 62 pattern pos1 = monp_de.pos_format(); 63 pattern neg1 = monp_de.neg_format(); 64 65 char dp2 = monp_byname.decimal_point(); 66 char th2 = monp_byname.thousands_sep(); 67 string g2 = monp_byname.grouping(); 68 string cs2 = monp_byname.curr_symbol(); 69 string ps2 = monp_byname.positive_sign(); 70 string ns2 = monp_byname.negative_sign(); 71 int fd2 = monp_byname.frac_digits(); 72 pattern pos2 = monp_byname.pos_format(); 73 pattern neg2 = monp_byname.neg_format(); 74 75 VERIFY( dp1 == dp2 ); 76 VERIFY( th1 == th2 ); 77 VERIFY( g1 == g2 ); 78 VERIFY( cs1 == cs2 ); 79 VERIFY( ps1 == ps2 ); 80 VERIFY( ns1 == ns2 ); 81 VERIFY( fd1 == fd2 ); 82 VERIFY(static_cast<part>(pos1.field[0]) == static_cast<part>(pos2.field[0])); 83 VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1])); 84 VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2])); 85 VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3])); 86 87 VERIFY(static_cast<part>(neg1.field[0]) == static_cast<part>(neg2.field[0])); 88 VERIFY(static_cast<part>(neg1.field[1]) == static_cast<part>(neg2.field[1])); 89 VERIFY(static_cast<part>(neg1.field[2]) == static_cast<part>(neg2.field[2])); 90 VERIFY(static_cast<part>(neg1.field[3]) == static_cast<part>(neg2.field[3])); 91 92 // ...and don't match "C" 93 char dp3 = monp_c.decimal_point(); 94 VERIFY( dp1 != dp3 ); 95} 96 97int main() 98{ 99 test01(); 100 101 return 0; 102} 103