aboutsummaryrefslogtreecommitdiff
path: root/test/sanitizer_common/TestCases/ctype.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/sanitizer_common/TestCases/ctype.c')
-rw-r--r--test/sanitizer_common/TestCases/ctype.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/test/sanitizer_common/TestCases/ctype.c b/test/sanitizer_common/TestCases/ctype.c
new file mode 100644
index 000000000000..37e0af89be6d
--- /dev/null
+++ b/test/sanitizer_common/TestCases/ctype.c
@@ -0,0 +1,89 @@
+// RUN: %clang %s -o %t && %run %t 2>&1 | FileCheck %s
+
+#include <ctype.h>
+#include <limits.h>
+#include <locale.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void check_ctype(void) {
+ unsigned char c;
+ volatile size_t i = 0; /* a dummy variable to prevent optimizing code out */
+
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!isalpha(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!isascii(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!isblank(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!iscntrl(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!isdigit(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!isgraph(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!islower(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!isprint(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!ispunct(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!isspace(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!isupper(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!isxdigit(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!isalnum(c);
+
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!tolower(c);
+ for (c = 0; c < UCHAR_MAX; c++)
+ i += !!toupper(c);
+
+ i += !!isalpha(EOF);
+ i += !!isascii(EOF);
+ i += !!isblank(EOF);
+ i += !!iscntrl(EOF);
+ i += !!isdigit(EOF);
+ i += !!isgraph(EOF);
+ i += !!islower(EOF);
+ i += !!isprint(EOF);
+ i += !!ispunct(EOF);
+ i += !!isspace(EOF);
+ i += !!isupper(EOF);
+ i += !!isxdigit(EOF);
+ i += !!isalnum(EOF);
+
+ i += !!tolower(EOF);
+ i += !!toupper(EOF);
+
+ if (i)
+ return;
+ else
+ return;
+}
+
+int main(int argc, char **argv) {
+ check_ctype();
+
+ setlocale(LC_ALL, "");
+
+ check_ctype();
+
+ setlocale(LC_ALL, "en_US.UTF-8");
+
+ check_ctype();
+
+ setlocale(LC_CTYPE, "pl_PL.UTF-8");
+
+ check_ctype();
+
+ printf("OK\n");
+
+ // CHECK: OK
+
+ return 0;
+}