1 /* Copyright (C) 2000  Free Software Foundation.
2 
3    Ensure all expected transformations of builtin strspn occur and
4    perform correctly.
5 
6    Written by Kaveh R. Ghazi, 11/27/2000.  */
7 
8 extern void abort (void);
9 typedef __SIZE_TYPE__ size_t;
10 extern size_t strspn (const char *, const char *);
11 extern char *strcpy (char *, const char *);
12 
13 void
main_test(void)14 main_test (void)
15 {
16   const char *const s1 = "hello world";
17   char dst[64], *d2;
18 
19   if (strspn (s1, "hello") != 5)
20     abort();
21   if (strspn (s1+4, "hello") != 1)
22     abort();
23   if (strspn (s1, "z") != 0)
24     abort();
25   if (strspn (s1, "hello world") != 11)
26     abort();
27   if (strspn (s1, "") != 0)
28     abort();
29   strcpy (dst, s1);
30   if (strspn (dst, "") != 0)
31     abort();
32   strcpy (dst, s1); d2 = dst;
33   if (strspn (++d2, "") != 0 || d2 != dst+1)
34     abort();
35   strcpy (dst, s1); d2 = dst;
36   if (strspn (++d2+5, "") != 0 || d2 != dst+1)
37     abort();
38   if (strspn ("", s1) != 0)
39     abort();
40   strcpy (dst, s1);
41   if (strspn ("", dst) != 0)
42     abort();
43   strcpy (dst, s1); d2 = dst;
44   if (strspn ("", ++d2) != 0 || d2 != dst+1)
45     abort();
46   strcpy (dst, s1); d2 = dst;
47   if (strspn ("", ++d2+5) != 0 || d2 != dst+1)
48     abort();
49 
50   /* Test at least one instance of the __builtin_ style.  We do this
51      to ensure that it works and that the prototype is correct.  */
52   if (__builtin_strspn (s1, "hello") != 5)
53     abort();
54 }
55