]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/1.cc
e6ab564fc3cb17bd0fc97cb6797ade303e199e9d
1 // Copyright (C) 2000-2019 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
19 // 22.2.1.3.2 ctype<char> members
22 #include <testsuite_hooks.h>
24 typedef wchar_t char_type
;
25 class gnu_ctype
: public std::ctype
<char_type
> { };
29 const char_type strlit00
[] = L
"manilla, cebu, tandag PHILIPPINES";
30 const char_type strlit01
[] = L
"MANILLA, CEBU, TANDAG PHILIPPINES";
31 const char_type c00
= L
'S';
32 const char_type c10
= L
's';
33 const char_type c20
= L
'9';
34 const char_type c30
= L
' ';
35 const char_type c40
= L
'!';
36 const char_type c50
= L
'F';
37 const char_type c60
= L
'f';
38 const char_type c80
= L
'x';
42 // sanity check ctype_base::mask members
43 int i01
= std::ctype_base::space
;
44 int i02
= std::ctype_base::upper
;
45 int i03
= std::ctype_base::lower
;
46 int i04
= std::ctype_base::digit
;
47 int i05
= std::ctype_base::punct
;
48 int i06
= std::ctype_base::alpha
;
49 int i07
= std::ctype_base::xdigit
;
50 int i08
= std::ctype_base::alnum
;
51 int i09
= std::ctype_base::graph
;
52 int i10
= std::ctype_base::print
;
53 int i11
= std::ctype_base::cntrl
;
66 // bool is(mask m, char_type c) const;
67 VERIFY( gctype
.is(std::ctype_base::space
, c30
) );
68 VERIFY( gctype
.is(std::ctype_base::upper
, c00
) );
69 VERIFY( gctype
.is(std::ctype_base::lower
, c10
) );
70 VERIFY( gctype
.is(std::ctype_base::digit
, c20
) );
71 VERIFY( gctype
.is(std::ctype_base::punct
, c40
) );
72 VERIFY( gctype
.is(std::ctype_base::alpha
, c50
) );
73 VERIFY( gctype
.is(std::ctype_base::alpha
, c60
) );
74 VERIFY( gctype
.is(std::ctype_base::xdigit
, c20
) );
75 VERIFY( !gctype
.is(std::ctype_base::xdigit
, c80
) );
76 VERIFY( gctype
.is(std::ctype_base::alnum
, c50
) );
77 VERIFY( gctype
.is(std::ctype_base::alnum
, c20
) );
78 VERIFY( gctype
.is(std::ctype_base::graph
, c40
) );
79 VERIFY( gctype
.is(std::ctype_base::graph
, c20
) );
81 // const char* is(const char* low, const char* high, mask* vec) const
82 std::ctype_base::mask m00
= static_cast<std::ctype_base::mask
>(0);
83 std::ctype_base::mask m01
[3];
84 std::ctype_base::mask m02
[13];
85 const char_type
* cc0
= strlit00
;
86 const char_type
* cc1
= 0;
87 const char_type
* cc2
= 0;
90 for (std::size_t i
= 0; i
< 3; ++i
)
92 cc1
= gctype
.is(cc0
, cc0
, m01
);
93 VERIFY( cc1
== strlit00
);
94 VERIFY( m01
[0] == m00
);
95 VERIFY( m01
[1] == m00
);
96 VERIFY( m01
[2] == m00
);
99 for (std::size_t i
= 0; i
< 3; ++i
)
101 cc2
= gctype
.is(cc0
, cc0
+ 3, m01
);
102 VERIFY( cc2
== strlit00
+ 3);
103 VERIFY( m01
[0] != m00
);
104 VERIFY( m01
[1] != m00
);
105 VERIFY( m01
[2] != m00
);
106 VERIFY( gctype
.is(m01
[0], cc0
[0]) );
107 VERIFY( gctype
.is(m01
[1], cc0
[1]) );
108 VERIFY( gctype
.is(m01
[2], cc0
[2]) );
111 for (std::size_t i
= 0; i
< 13; ++i
)
113 cc1
= gctype
.is(cc0
, cc0
+ 13, m02
);
114 VERIFY( cc1
== strlit01
+ 13);
115 VERIFY( m02
[6] != m00
);
116 VERIFY( m02
[7] != m00
);
117 VERIFY( m02
[8] != m00
);
118 VERIFY( m02
[8] != m02
[6] );
119 VERIFY( m02
[6] != m02
[7] );
120 VERIFY( static_cast<bool>(m02
[6] & std::ctype_base::alnum
) );
121 VERIFY( static_cast<bool>(m02
[6] & std::ctype_base::upper
) );
122 VERIFY( static_cast<bool>(m02
[6] & std::ctype_base::alpha
) );
123 VERIFY( static_cast<bool>(m02
[7] & std::ctype_base::punct
) );
124 VERIFY( static_cast<bool>(m02
[8] & std::ctype_base::space
) );
125 VERIFY( gctype
.is(m02
[6], cc0
[6]) );
126 VERIFY( gctype
.is(m02
[7], cc0
[7]) );
127 VERIFY( gctype
.is(m02
[8], cc0
[8]) );