OSDN Git Service

2001-08-07 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / 22_locale / numpunct_char_members.cc
1 // 2001-01-17 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.3.1.1 nunpunct members
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
29 void test01()
30 {
31   using namespace std;
32   
33   bool test = true;
34   string str;
35
36   // basic construction
37   locale loc_c = locale::classic();
38   str = loc_c.name();
39
40   locale loc_us("en_US");
41   str = loc_us.name();
42   VERIFY( loc_c != loc_us );
43
44   locale loc_fr("fr_FR");
45   str = loc_fr.name();
46   VERIFY( loc_c != loc_fr );
47
48   locale loc_de("de_DE");
49   str = loc_de.name();
50   VERIFY( loc_c != loc_de );
51
52   VERIFY( loc_us != loc_fr );
53   VERIFY( loc_us != loc_de );
54   VERIFY( loc_de != loc_fr );
55
56   // cache the numpunct facets
57   const numpunct<char>& nump_c = use_facet<numpunct<char> >(loc_c); 
58   const numpunct<char>& nump_us = use_facet<numpunct<char> >(loc_us); 
59   const numpunct<char>& nump_fr = use_facet<numpunct<char> >(loc_fr); 
60   const numpunct<char>& nump_de = use_facet<numpunct<char> >(loc_de); 
61
62   // sanity check the data is correct.
63   char dp1 = nump_c.decimal_point();
64   char th1 = nump_c.thousands_sep();
65   string g1 = nump_c.grouping();
66   string t1 = nump_c.truename();
67   string f1 = nump_c.falsename();
68
69   char dp2 = nump_us.decimal_point();
70   char th2 = nump_us.thousands_sep();
71   string g2 = nump_us.grouping();
72   string t2 = nump_us.truename();
73   string f2 = nump_us.falsename();
74
75   char dp3 = nump_fr.decimal_point();
76   char th3 = nump_fr.thousands_sep();
77   string g3 = nump_fr.grouping();
78   string t3 = nump_fr.truename();
79   string f3 = nump_fr.falsename();
80
81   char dp4 = nump_de.decimal_point();
82   char th4 = nump_de.thousands_sep();
83   string g4 = nump_de.grouping();
84   string t4 = nump_de.truename();
85   string f4 = nump_de.falsename();
86
87   VERIFY( dp2 != dp3 );
88   VERIFY( th2 != th3 );
89 #if 0
90   // XXX isn't actually supported right now.
91   VERIFY( t2 != t3 );
92   VERIFY( f2 != f3 );
93 #endif
94
95   VERIFY( dp2 != dp4 );
96   VERIFY( th2 != th4 );
97 #if 0
98   // XXX isn't actually supported right now.
99   VERIFY( t2 != t3 );
100   VERIFY( f2 != f3 );
101 #endif
102 }
103
104 int main()
105 {
106   test01();
107
108   return 0;
109 }