]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/numpunct_members_char.cc
c_compatibility: New.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / numpunct_members_char.cc
CommitLineData
33590f13 1// 2001-01-17 Benjamin Kosnik <bkoz@redhat.com>
0214010c 2
4b9aaf63 3// Copyright (C) 2001, 2002 Free Software Foundation
0214010c
BK
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>
fe413112 24#include <testsuite_hooks.h>
0214010c 25
2965361b
BK
26// XXX This test is not working for non-glibc locale models.
27// { dg-do run { xfail *-*-* } }
28
0214010c
BK
29void test01()
30{
31 using namespace std;
32
33 bool test = true;
0214010c
BK
34
35 // basic construction
36 locale loc_c = locale::classic();
0214010c 37 locale loc_us("en_US");
0214010c 38 locale loc_fr("fr_FR");
13f83598 39 locale loc_de("de_DE");
13f83598 40 VERIFY( loc_c != loc_de );
13f83598
BK
41 VERIFY( loc_us != loc_fr );
42 VERIFY( loc_us != loc_de );
43 VERIFY( loc_de != loc_fr );
0214010c
BK
44
45 // cache the numpunct facets
46 const numpunct<char>& nump_c = use_facet<numpunct<char> >(loc_c);
47 const numpunct<char>& nump_us = use_facet<numpunct<char> >(loc_us);
48 const numpunct<char>& nump_fr = use_facet<numpunct<char> >(loc_fr);
13f83598 49 const numpunct<char>& nump_de = use_facet<numpunct<char> >(loc_de);
0214010c
BK
50
51 // sanity check the data is correct.
52 char dp1 = nump_c.decimal_point();
53 char th1 = nump_c.thousands_sep();
54 string g1 = nump_c.grouping();
55 string t1 = nump_c.truename();
56 string f1 = nump_c.falsename();
57
58 char dp2 = nump_us.decimal_point();
59 char th2 = nump_us.thousands_sep();
60 string g2 = nump_us.grouping();
61 string t2 = nump_us.truename();
62 string f2 = nump_us.falsename();
63
64 char dp3 = nump_fr.decimal_point();
65 char th3 = nump_fr.thousands_sep();
66 string g3 = nump_fr.grouping();
67 string t3 = nump_fr.truename();
68 string f3 = nump_fr.falsename();
69
13f83598
BK
70 char dp4 = nump_de.decimal_point();
71 char th4 = nump_de.thousands_sep();
72 string g4 = nump_de.grouping();
73 string t4 = nump_de.truename();
74 string f4 = nump_de.falsename();
75
76 VERIFY( dp2 != dp3 );
77 VERIFY( th2 != th3 );
13f83598
BK
78
79 VERIFY( dp2 != dp4 );
80 VERIFY( th2 != th4 );
86ade44c
BK
81 // XXX This isn't actually supported right now.
82 // VERIFY( t2 != t3 );
83 // VERIFY( f2 != f3 );
0214010c
BK
84}
85
4b9aaf63
BK
86// libstdc++/5280
87void test02()
88{
b6a95741 89#ifdef _GLIBCPP_HAVE_SETENV
4b9aaf63
BK
90 // Set the global locale to non-"C".
91 std::locale loc_de("de_DE");
92 std::locale::global(loc_de);
93
94 // Set LANG environment variable to de_DE.
95 const char* oldLANG = getenv("LANG");
96 if (!setenv("LANG", "de_DE", 1))
97 {
98 test01();
4a78d864 99 setenv("LANG", oldLANG ? oldLANG : "", 1);
4b9aaf63 100 }
b6a95741 101#endif
4b9aaf63
BK
102}
103
b5623829
PC
104// http://gcc.gnu.org/ml/libstdc++/2002-05/msg00038.html
105void test03()
106{
107 bool test = true;
108
8081da07 109 const char* tentLANG = std::setlocale(LC_ALL, "ja_JP.eucjp");
27b4d95a
PC
110 if (tentLANG != NULL)
111 {
112 std::string preLANG = tentLANG;
113 test01();
8081da07 114 std::string postLANG = std::setlocale(LC_ALL, NULL);
27b4d95a
PC
115 VERIFY( preLANG == postLANG );
116 }
b5623829
PC
117}
118
0214010c
BK
119int main()
120{
121 test01();
4b9aaf63 122 test02();
b5623829 123 test03();
0214010c
BK
124 return 0;
125}