]>
Commit | Line | Data |
---|---|---|
a5544970 | 1 | // Copyright (C) 2000-2019 Free Software Foundation, Inc. |
f64ce6c6 BK |
2 | // |
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 | |
748086b7 | 6 | // Free Software Foundation; either version 3, or (at your option) |
f64ce6c6 BK |
7 | // any later version. |
8 | ||
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. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
15 | // with this library; see the file COPYING3. If not see |
16 | // <http://www.gnu.org/licenses/>. | |
f64ce6c6 | 17 | |
f64ce6c6 BK |
18 | |
19 | // 22.2.1.3.2 ctype<char> members | |
20 | ||
21 | #include <locale> | |
22 | #include <testsuite_hooks.h> | |
23 | ||
24 | typedef wchar_t char_type; | |
25 | class gnu_ctype: public std::ctype<char_type> { }; | |
26 | ||
27 | void test01() | |
28 | { | |
f64ce6c6 BK |
29 | const char_type strlit00[] = L"manilla, cebu, tandag PHILIPPINES"; |
30 | const char_type strlit01[] = L"MANILLA, CEBU, TANDAG PHILIPPINES"; | |
31 | const char_type strlit02[] = L"manilla, cebu, tandag philippines"; | |
32 | const char_type c00 = L'S'; | |
33 | const char_type c10 = L's'; | |
f64ce6c6 BK |
34 | |
35 | gnu_ctype gctype; | |
36 | char_type c100; | |
37 | int len = std::char_traits<char_type>::length(strlit00); | |
38 | char_type c_array[len + 1]; | |
39 | ||
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; | |
f64ce6c6 BK |
52 | VERIFY ( i01 != i02); |
53 | VERIFY ( i02 != i03); | |
54 | VERIFY ( i03 != i04); | |
55 | VERIFY ( i04 != i05); | |
56 | VERIFY ( i05 != i06); | |
57 | VERIFY ( i06 != i07); | |
58 | VERIFY ( i07 != i08); | |
59 | VERIFY ( i08 != i09); | |
60 | VERIFY ( i09 != i10); | |
61 | VERIFY ( i10 != i11); | |
62 | VERIFY ( i11 != i01); | |
63 | ||
64 | // char_type toupper(char_type c) const | |
65 | c100 = gctype.toupper(c10); | |
66 | VERIFY( c100 == c00 ); | |
67 | ||
68 | // char_type tolower(char_type c) const | |
69 | c100 = gctype.tolower(c00); | |
70 | VERIFY( c100 == c10 ); | |
71 | ||
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) ); | |
76 | ||
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) ); | |
81 | } | |
82 | ||
f64ce6c6 BK |
83 | int main() |
84 | { | |
85 | test01(); | |
f64ce6c6 BK |
86 | return 0; |
87 | } |