]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/ctype/to/char/1.cc
1 // Copyright (C) 2000-2022 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 char char_type
;
25 class gnu_ctype
: public std::ctype
<char_type
> { };
29 const char_type strlit00
[] = "manilla, cebu, tandag PHILIPPINES";
30 const char_type strlit01
[] = "MANILLA, CEBU, TANDAG PHILIPPINES";
31 const char_type strlit02
[] = "manilla, cebu, tandag philippines";
32 const char_type c00
= 'S';
33 const char_type c10
= 's';
37 int len
= std::char_traits
<char_type
>::length(strlit00
);
38 char_type c_array
[len
+ 1];
40 // sanity check ctype_base::mask members
41 int i01
= std::ctype_base::space
;
42 int i02
= std::ctype_base::upper
;
43 int i03
= std::ctype_base::lower
;
44 int i04
= std::ctype_base::digit
;
45 int i05
= std::ctype_base::punct
;
46 int i06
= std::ctype_base::alpha
;
47 int i07
= std::ctype_base::xdigit
;
48 int i08
= std::ctype_base::alnum
;
49 int i09
= std::ctype_base::graph
;
50 int i10
= std::ctype_base::print
;
51 int i11
= std::ctype_base::cntrl
;
64 // char_type toupper(char_type c) const
65 c100
= gctype
.toupper(c10
);
66 VERIFY( c100
== c00
);
68 // char_type tolower(char_type c) const
69 c100
= gctype
.tolower(c00
);
70 VERIFY( c100
== c10
);
72 // char_type toupper(char_type* low, const char_type* hi) const
73 std::char_traits
<char_type
>::copy(c_array
, strlit02
, len
+ 1);
74 gctype
.toupper(c_array
, c_array
+ len
);
75 VERIFY( !std::char_traits
<char_type
>::compare(c_array
, strlit01
, len
- 1) );
77 // char_type tolower(char_type* low, const char_type* hi) const
78 std::char_traits
<char_type
>::copy(c_array
, strlit01
, len
+ 1);
79 gctype
.tolower(c_array
, c_array
+ len
);
80 VERIFY( !std::char_traits
<char_type
>::compare(c_array
, strlit02
, len
- 1) );