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