]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/ctype/is/char/2.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / ctype / is / char / 2.cc
CommitLineData
9275f73a 1// { dg-do run { xfail { ! { *-*-linux* *-*-gnu* } } } }
4216708a 2// { dg-require-namedlocale "de_DE.ISO8859-15" }
6aca9695 3
7adcbafe 4// Copyright (C) 2000-2022 Free Software Foundation, Inc.
5f8d36fe
BK
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
748086b7 9// Free Software Foundation; either version 3, or (at your option)
5f8d36fe
BK
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
748086b7
JJ
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
5f8d36fe 20
5f8d36fe
BK
21
22// 22.2.1.3.2 ctype<char> members
23
24#include <locale>
25#include <vector>
26#include <testsuite_hooks.h>
27
28typedef char char_type;
29
30// libstdc++/4456, libstdc++/4457, libstdc++/4458
31void test02()
32{
33 using namespace std;
f90e600a 34 typedef ctype_base::mask mask;
5f8d36fe
BK
35 typedef vector<mask> vector_type;
36
5f8d36fe
BK
37 // const int max = numeric_limits<char>::max();
38 const int max = 255;
39 const int ctype_mask_max = 10;
40 vector_type v_c(max);
41 vector_type v_de(max);
42
43 // "C"
44 locale loc_c = locale::classic();
45 const ctype<char>& ctype_c = use_facet<ctype<char> >(loc_c);
46 for (int i = 0; i < max; ++i)
47 {
48 char_type c = static_cast<char>(i);
49 mask mask_test = static_cast<mask>(0);
50 mask mask_is = static_cast<mask>(0);
51 for (int j = 0; j <= ctype_mask_max; ++j)
52 {
53 mask_test = static_cast<mask>(1 << j);
54 if (ctype_c.is(mask_test, c))
55 mask_is |= mask_test;
56 }
57 v_c[i] = mask_is;
58 }
59
4216708a
JM
60 // "de_DE.ISO8859-15"
61 locale loc_de = locale(ISO_8859(15,de_DE));
5f8d36fe
BK
62 const ctype<char>& ctype_de = use_facet<ctype<char> >(loc_de);
63 for (int i = 0; i < max; ++i)
64 {
65 char_type c = static_cast<char>(i);
66 mask mask_test = static_cast<mask>(0);
67 mask mask_is = static_cast<mask>(0);
68 for (int j = 0; j <= ctype_mask_max; ++j)
69 {
70 mask_test = static_cast<mask>(1 << j);
71 if (ctype_de.is(mask_test, c))
72 mask_is |= mask_test;
73 }
74 v_de[i] = mask_is;
75 }
76
77#if QUANNUM_VERBOSE_LYRICALLY_ADEPT_BAY_AREA_MCS_MODE
78 for (int i = 0; i < max; ++i)
79 {
80 char_type mark = v_c[i] == v_de[i] ? ' ' : '-';
81 cout << i << ' ' << mark << ' ' << static_cast<char>(i) << '\t' ;
82 cout << "v_c: " << setw(4) << v_c[i] << '\t';
83 cout << "v_de: " << setw(4) << v_de[i] << endl;
84 }
85 cout << (v_c == v_de) << endl;
86#endif
87
88 VERIFY( v_c != v_de );
89}
90
91int main()
92{
3d838e28 93 test02();
5f8d36fe
BK
94 return 0;
95}