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