]> git.ozlabs.org Git - ccan/blobdiff - ccan/str/test/compile_fail-iscntrl.c
str: provide checks for ctype.h char functions, and strstr and strchr functions.
[ccan] / ccan / str / test / compile_fail-iscntrl.c
diff --git a/ccan/str/test/compile_fail-iscntrl.c b/ccan/str/test/compile_fail-iscntrl.c
new file mode 100644 (file)
index 0000000..5ae783b
--- /dev/null
@@ -0,0 +1,23 @@
+#define CCAN_STR_DEBUG 1
+#include <ccan/str/str.h>
+
+int main(int argc, char *argv[])
+{
+#ifdef FAIL
+#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
+#error We need typeof to check iscntrl.
+#endif
+       char
+#else
+       unsigned char
+#endif
+               c = argv[0][0];
+
+#ifdef FAIL
+       /* Fake fail on unsigned char platforms. */
+       c = 255;
+       BUILD_ASSERT(c < 0);
+#endif
+
+       return iscntrl(c);
+}