1 // Copyright (C) 2000, 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
16 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // As a special exception, you may use this file as part of a free software
20 // library without restriction. Specifically, if other files instantiate
21 // templates or use macros or inline functions from this file, or you compile
22 // this file and link it with other files to produce an executable, this
23 // file does not by itself cause the resulting executable to be covered by
24 // the GNU General Public License. This exception does not however
25 // invalidate any other reasons why the executable file might be covered by
26 // the GNU General Public License.
28 // 22.2.1.3.2 ctype<char> members
31 #include <testsuite_hooks.h>
33 typedef wchar_t char_type
;
34 class gnu_ctype
: public std::ctype
<char_type
> { };
38 bool test
__attribute__((unused
)) = true;
39 const char_type strlit00
[] = L
"manilla, cebu, tandag PHILIPPINES";
40 const char_type strlit01
[] = L
"MANILLA, CEBU, TANDAG PHILIPPINES";
41 const char_type strlit02
[] = L
"manilla, cebu, tandag philippines";
42 const char_type c00
= L
'S';
43 const char_type c10
= L
's';
47 int len
= std::char_traits
<char_type
>::length(strlit00
);
48 char_type c_array
[len
+ 1];
50 // sanity check ctype_base::mask members
51 int i01
= std::ctype_base::space
;
52 int i02
= std::ctype_base::upper
;
53 int i03
= std::ctype_base::lower
;
54 int i04
= std::ctype_base::digit
;
55 int i05
= std::ctype_base::punct
;
56 int i06
= std::ctype_base::alpha
;
57 int i07
= std::ctype_base::xdigit
;
58 int i08
= std::ctype_base::alnum
;
59 int i09
= std::ctype_base::graph
;
60 int i10
= std::ctype_base::print
;
61 int i11
= std::ctype_base::cntrl
;
74 // char_type toupper(char_type c) const
75 c100
= gctype
.toupper(c10
);
76 VERIFY( c100
== c00
);
78 // char_type tolower(char_type c) const
79 c100
= gctype
.tolower(c00
);
80 VERIFY( c100
== c10
);
82 // char_type toupper(char_type* low, const char_type* hi) const
83 std::char_traits
<char_type
>::copy(c_array
, strlit02
, len
+ 1);
84 gctype
.toupper(c_array
, c_array
+ len
);
85 VERIFY( !std::char_traits
<char_type
>::compare(c_array
, strlit01
, len
- 1) );
87 // char_type tolower(char_type* low, const char_type* hi) const
88 std::char_traits
<char_type
>::copy(c_array
, strlit01
, len
+ 1);
89 gctype
.tolower(c_array
, c_array
+ len
);
90 VERIFY( !std::char_traits
<char_type
>::compare(c_array
, strlit02
, len
- 1) );