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 | // <ctype.h> |
10 | |
11 | #include <ctype.h> |
12 | |
13 | #include "test_macros.h" |
14 | |
15 | #ifdef isalnum |
16 | #error isalnum defined |
17 | #endif |
18 | |
19 | #ifdef isalpha |
20 | #error isalpha defined |
21 | #endif |
22 | |
23 | #ifdef isblank |
24 | #error isblank defined |
25 | #endif |
26 | |
27 | #ifdef iscntrl |
28 | #error iscntrl defined |
29 | #endif |
30 | |
31 | #ifdef isdigit |
32 | #error isdigit defined |
33 | #endif |
34 | |
35 | #ifdef isgraph |
36 | #error isgraph defined |
37 | #endif |
38 | |
39 | #ifdef islower |
40 | #error islower defined |
41 | #endif |
42 | |
43 | #ifdef isprint |
44 | #error isprint defined |
45 | #endif |
46 | |
47 | #ifdef ispunct |
48 | #error ispunct defined |
49 | #endif |
50 | |
51 | #ifdef isspace |
52 | #error isspace defined |
53 | #endif |
54 | |
55 | #ifdef isupper |
56 | #error isupper defined |
57 | #endif |
58 | |
59 | #ifdef isxdigit |
60 | #error isxdigit defined |
61 | #endif |
62 | |
63 | #ifdef tolower |
64 | #error tolower defined |
65 | #endif |
66 | |
67 | #ifdef toupper |
68 | #error toupper defined |
69 | #endif |
70 | |
71 | ASSERT_SAME_TYPE(int, decltype(isalnum(0))); |
72 | ASSERT_SAME_TYPE(int, decltype(isalpha(0))); |
73 | ASSERT_SAME_TYPE(int, decltype(isblank(0))); |
74 | ASSERT_SAME_TYPE(int, decltype(iscntrl(0))); |
75 | ASSERT_SAME_TYPE(int, decltype(isdigit(0))); |
76 | ASSERT_SAME_TYPE(int, decltype(isgraph(0))); |
77 | ASSERT_SAME_TYPE(int, decltype(islower(0))); |
78 | ASSERT_SAME_TYPE(int, decltype(isprint(0))); |
79 | ASSERT_SAME_TYPE(int, decltype(ispunct(0))); |
80 | ASSERT_SAME_TYPE(int, decltype(isspace(0))); |
81 | ASSERT_SAME_TYPE(int, decltype(isupper(0))); |
82 | ASSERT_SAME_TYPE(int, decltype(isxdigit(0))); |
83 | ASSERT_SAME_TYPE(int, decltype(tolower(c: 0))); |
84 | ASSERT_SAME_TYPE(int, decltype(toupper(c: 0))); |
85 | |
86 | #include <cassert> |
87 | |
88 | int main(int, char**) { |
89 | assert(isalnum('a')); |
90 | assert(isalpha('a')); |
91 | assert(isblank(' ')); |
92 | assert(!iscntrl(' ')); |
93 | assert(!isdigit('a')); |
94 | assert(isgraph('a')); |
95 | assert(islower('a')); |
96 | assert(isprint('a')); |
97 | assert(!ispunct('a')); |
98 | assert(!isspace('a')); |
99 | assert(!isupper('a')); |
100 | assert(isxdigit('a')); |
101 | assert(tolower('A') == 'a'); |
102 | assert(toupper('a') == 'A'); |
103 | |
104 | return 0; |
105 | } |
106 | |