]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/ctype/is/char/2.cc
[multiple changes]
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / ctype / is / char / 2.cc
1 // { dg-do run { xfail { ! { *-*-linux* } } } }
2 // { dg-require-namedlocale "de_DE" }
3
4 // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2009
5 // Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
11 // any later version.
12
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
21
22
23 // 22.2.1.3.2 ctype<char> members
24
25 #include <locale>
26 #include <vector>
27 #include <testsuite_hooks.h>
28
29 typedef char char_type;
30
31 // libstdc++/4456, libstdc++/4457, libstdc++/4458
32 void test02()
33 {
34 using namespace std;
35 typedef ctype_base::mask mask;
36 typedef vector<mask> vector_type;
37
38 bool test __attribute__((unused)) = true;
39
40 // const int max = numeric_limits<char>::max();
41 const int max = 255;
42 const int ctype_mask_max = 10;
43 vector_type v_c(max);
44 vector_type v_de(max);
45
46 // "C"
47 locale loc_c = locale::classic();
48 const ctype<char>& ctype_c = use_facet<ctype<char> >(loc_c);
49 for (int i = 0; i < max; ++i)
50 {
51 char_type c = static_cast<char>(i);
52 mask mask_test = static_cast<mask>(0);
53 mask mask_is = static_cast<mask>(0);
54 for (int j = 0; j <= ctype_mask_max; ++j)
55 {
56 mask_test = static_cast<mask>(1 << j);
57 if (ctype_c.is(mask_test, c))
58 mask_is |= mask_test;
59 }
60 v_c[i] = mask_is;
61 }
62
63 // "de_DE"
64 locale loc_de = locale("de_DE");
65 const ctype<char>& ctype_de = use_facet<ctype<char> >(loc_de);
66 for (int i = 0; i < max; ++i)
67 {
68 char_type c = static_cast<char>(i);
69 mask mask_test = static_cast<mask>(0);
70 mask mask_is = static_cast<mask>(0);
71 for (int j = 0; j <= ctype_mask_max; ++j)
72 {
73 mask_test = static_cast<mask>(1 << j);
74 if (ctype_de.is(mask_test, c))
75 mask_is |= mask_test;
76 }
77 v_de[i] = mask_is;
78 }
79
80 #if QUANNUM_VERBOSE_LYRICALLY_ADEPT_BAY_AREA_MCS_MODE
81 for (int i = 0; i < max; ++i)
82 {
83 char_type mark = v_c[i] == v_de[i] ? ' ' : '-';
84 cout << i << ' ' << mark << ' ' << static_cast<char>(i) << '\t' ;
85 cout << "v_c: " << setw(4) << v_c[i] << '\t';
86 cout << "v_de: " << setw(4) << v_de[i] << endl;
87 }
88 cout << (v_c == v_de) << endl;
89 #endif
90
91 VERIFY( v_c != v_de );
92 }
93
94 int main()
95 {
96 test02();
97 return 0;
98 }