conformance fixes
[libc-test.git] / src / functional / string_strcspn.c
blob88df3838a851b49aff3b193178ac20091ee9d689
1 #include <stddef.h>
2 #include <string.h>
3 #include "test.h"
5 #define T(s, c, n) { \
6 char *p = s; \
7 char *q = c; \
8 size_t r = strcspn(p, q); \
9 if (r != n) \
10 t_error("strcspn(%s,%s) returned %lu, wanted %lu\n", #s, #c, (unsigned long)r, (unsigned long)(n)); \
13 int main(void)
15 int i;
16 char a[128];
17 char s[256];
19 for (i = 0; i < 128; i++)
20 a[i] = (i+1) & 127;
21 for (i = 0; i < 256; i++)
22 *((unsigned char*)s+i) = i+1;
24 T("", "", 0)
25 T("a", "", 1)
26 T("", "a", 0)
27 T("abc", "cde", 2)
28 T("abc", "ccc", 2)
29 T("abc", a, 0)
30 T("\xff\x80 abc", a, 2)
31 T(s, "\xff", 254)
33 return t_status;