]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/numpunct_members_wchar_t.cc
dwarf2out.c (fde_table_in_use): Mark GTY.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / numpunct_members_wchar_t.cc
1 // 2001-11-20 Benjamin Kosnik <bkoz@redhat.com>
2
3 // Copyright (C) 2001, 2002 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 #ifdef _GLIBCPP_USE_WCHAR_T
30 void test01()
31 {
32 using namespace std;
33
34 bool test = true;
35
36 // basic construction
37 locale loc_c = locale::classic();
38 locale loc_us("en_US");
39 locale loc_fr("fr_FR");
40 locale loc_de("de_DE");
41 VERIFY( loc_c != loc_de );
42 VERIFY( loc_us != loc_fr );
43 VERIFY( loc_us != loc_de );
44 VERIFY( loc_de != loc_fr );
45
46 // cache the numpunct facets
47 const numpunct<wchar_t>& nump_c = use_facet<numpunct<wchar_t> >(loc_c);
48 const numpunct<wchar_t>& nump_us = use_facet<numpunct<wchar_t> >(loc_us);
49 const numpunct<wchar_t>& nump_fr = use_facet<numpunct<wchar_t> >(loc_fr);
50 const numpunct<wchar_t>& nump_de = use_facet<numpunct<wchar_t> >(loc_de);
51
52 // sanity check the data is correct.
53 wchar_t dp1 = nump_c.decimal_point();
54 wchar_t th1 = nump_c.thousands_sep();
55 string g1 = nump_c.grouping();
56 wstring t1 = nump_c.truename();
57 wstring f1 = nump_c.falsename();
58
59 wchar_t dp2 = nump_us.decimal_point();
60 wchar_t th2 = nump_us.thousands_sep();
61 string g2 = nump_us.grouping();
62 wstring t2 = nump_us.truename();
63 wstring f2 = nump_us.falsename();
64
65 wchar_t dp3 = nump_fr.decimal_point();
66 wchar_t th3 = nump_fr.thousands_sep();
67 string g3 = nump_fr.grouping();
68 wstring t3 = nump_fr.truename();
69 wstring f3 = nump_fr.falsename();
70
71 wchar_t dp4 = nump_de.decimal_point();
72 wchar_t th4 = nump_de.thousands_sep();
73 string g4 = nump_de.grouping();
74 wstring t4 = nump_de.truename();
75 wstring f4 = nump_de.falsename();
76
77 VERIFY( dp2 != dp3 );
78 VERIFY( th2 != th3 );
79
80 VERIFY( dp2 != dp4 );
81 VERIFY( th2 != th4 );
82 }
83
84 // libstdc++/5280
85 void test02()
86 {
87 #ifdef _GLIBCPP_HAVE_SETENV
88 // Set the global locale to non-"C".
89 std::locale loc_de("de_DE");
90 std::locale::global(loc_de);
91
92 // Set LANG environment variable to de_DE.
93 const char* oldLANG = getenv("LANG");
94 if (!setenv("LANG", "de_DE", 1))
95 {
96 test01();
97 setenv("LANG", oldLANG ? oldLANG : "", 1);
98 }
99 #endif
100 }
101
102 // http://gcc.gnu.org/ml/libstdc++/2002-05/msg00038.html
103 void test03()
104 {
105 bool test = true;
106
107 const char* tentLANG = std::setlocale(LC_ALL, "ja_JP.eucjp");
108 if (tentLANG != NULL)
109 {
110 std::string preLANG = tentLANG;
111 test01();
112 std::string postLANG = std::setlocale(LC_ALL, NULL);
113 VERIFY( preLANG == postLANG );
114 }
115 }
116 #endif
117
118 int main()
119 {
120 #ifdef _GLIBCPP_USE_WCHAR_T
121 test01();
122 test02();
123 test03();
124 #endif
125 return 0;
126 }