]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/ctype/to/wchar_t/1.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / ctype / to / wchar_t / 1.cc
CommitLineData
aa118a03 1// Copyright (C) 2000-2014 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
24typedef wchar_t char_type;
25class gnu_ctype: public std::ctype<char_type> { };
26
27void test01()
28{
11f10e6b 29 bool test __attribute__((unused)) = true;
f64ce6c6
BK
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';
f64ce6c6
BK
35
36 gnu_ctype gctype;
37 char_type c100;
38 int len = std::char_traits<char_type>::length(strlit00);
39 char_type c_array[len + 1];
40
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;
f64ce6c6
BK
53 VERIFY ( i01 != i02);
54 VERIFY ( i02 != i03);
55 VERIFY ( i03 != i04);
56 VERIFY ( i04 != i05);
57 VERIFY ( i05 != i06);
58 VERIFY ( i06 != i07);
59 VERIFY ( i07 != i08);
60 VERIFY ( i08 != i09);
61 VERIFY ( i09 != i10);
62 VERIFY ( i10 != i11);
63 VERIFY ( i11 != i01);
64
65 // char_type toupper(char_type c) const
66 c100 = gctype.toupper(c10);
67 VERIFY( c100 == c00 );
68
69 // char_type tolower(char_type c) const
70 c100 = gctype.tolower(c00);
71 VERIFY( c100 == c10 );
72
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) );
77
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) );
82}
83
f64ce6c6
BK
84int main()
85{
86 test01();
f64ce6c6
BK
87 return 0;
88}