xref: /llvm-project/libcxx/test/std/strings/c.strings/cwctype.pass.cpp (revision c281b127ab5656eec289cf0b39bf1f473cf71757)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <cwctype>
10 
11 // UNSUPPORTED: no-wide-characters
12 
13 // towctrans and wctrans were added in Android API 26.
14 // TODO: Switch from UNSUPPORTED to XFAIL once the Android CI Docker sysroot is
15 // updated.
16 // UNSUPPORTED: LIBCXX-ANDROID-FIXME && target={{.+}}-android{{(eabi)?(21|22|23|24|25)}}
17 
18 #include <cwctype>
19 #include <type_traits>
20 
21 #include "test_macros.h"
22 
23 #ifndef WEOF
24 #  error WEOF not defined
25 #endif
26 
27 #ifdef iswalnum
28 #  error iswalnum defined
29 #endif
30 
31 #ifdef iswalpha
32 #  error iswalpha defined
33 #endif
34 
35 #ifdef iswblank
36 #  error iswblank defined
37 #endif
38 
39 #ifdef iswcntrl
40 #  error iswcntrl defined
41 #endif
42 
43 #ifdef iswdigit
44 #  error iswdigit defined
45 #endif
46 
47 #ifdef iswgraph
48 #  error iswgraph defined
49 #endif
50 
51 #ifdef iswlower
52 #  error iswlower defined
53 #endif
54 
55 #ifdef iswprint
56 #  error iswprint defined
57 #endif
58 
59 #ifdef iswpunct
60 #  error iswpunct defined
61 #endif
62 
63 #ifdef iswspace
64 #  error iswspace defined
65 #endif
66 
67 #ifdef iswupper
68 #  error iswupper defined
69 #endif
70 
71 #ifdef iswxdigit
72 #  error iswxdigit defined
73 #endif
74 
75 #ifdef iswctype
76 #  error iswctype defined
77 #endif
78 
79 #ifdef wctype
80 #  error wctype defined
81 #endif
82 
83 #ifdef towlower
84 #  error towlower defined
85 #endif
86 
87 #ifdef towupper
88 #  error towupper defined
89 #endif
90 
91 #ifdef towctrans
92 #  error towctrans defined
93 #endif
94 
95 #ifdef wctrans
96 #  error wctrans defined
97 #endif
98 
99 int main(int, char**) {
100   std::wint_t w = 0;
101   ASSERT_SAME_TYPE(int, decltype(std::iswalnum(w)));
102   ASSERT_SAME_TYPE(int, decltype(std::iswalpha(w)));
103   ASSERT_SAME_TYPE(int, decltype(std::iswblank(w)));
104   ASSERT_SAME_TYPE(int, decltype(std::iswcntrl(w)));
105   ASSERT_SAME_TYPE(int, decltype(std::iswdigit(w)));
106   ASSERT_SAME_TYPE(int, decltype(std::iswgraph(w)));
107   ASSERT_SAME_TYPE(int, decltype(std::iswlower(w)));
108   ASSERT_SAME_TYPE(int, decltype(std::iswprint(w)));
109   ASSERT_SAME_TYPE(int, decltype(std::iswpunct(w)));
110   ASSERT_SAME_TYPE(int, decltype(std::iswspace(w)));
111   ASSERT_SAME_TYPE(int, decltype(std::iswupper(w)));
112   ASSERT_SAME_TYPE(int, decltype(std::iswxdigit(w)));
113 
114   ASSERT_SAME_TYPE(int, decltype(std::iswctype(w, std::wctype_t())));
115 
116   ASSERT_SAME_TYPE(std::wctype_t, decltype(std::wctype("")));
117   ASSERT_SAME_TYPE(std::wint_t, decltype(std::towlower(w)));
118   ASSERT_SAME_TYPE(std::wint_t, decltype(std::towupper(w)));
119   ASSERT_SAME_TYPE(std::wint_t, decltype(std::towctrans(w, std::wctrans_t())));
120   ASSERT_SAME_TYPE(std::wctrans_t, decltype(std::wctrans("")));
121 
122   return 0;
123 }
124