add _DEFAULT_SOURCE wherever _BSD_SOURCE was used
[libc-test] / src / functional / string_strcspn.c
1 #include <stddef.h>
2 #include <string.h>
3 #include "test.h"
4
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)); \
11 }
12
13 int main(void)
14 {
15         int i;
16         char a[128];
17         char s[256];
18
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;
23
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)
32
33         return t_status;
34 }