1 /* Copyright (C) 2000, 2001, 2003 Free Software Foundation.
3 Ensure all expected transformations of builtin strncmp occur and
6 Written by Kaveh R. Ghazi, 11/26/2000. */
8 extern void abort (void);
9 typedef __SIZE_TYPE__
size_t;
10 extern int strncmp (const char *, const char *, size_t);
15 const char *const s1
= "hello world";
18 if (strncmp (s1
, "hello world", 12) != 0)
20 if (strncmp ("hello world", s1
, 12) != 0)
22 if (strncmp ("hello", "hello", 6) != 0)
24 if (strncmp ("hello", "hello", 2) != 0)
26 if (strncmp ("hello", "hello", 100) != 0)
28 if (strncmp (s1
+10, "d", 100) != 0)
30 if (strncmp (10+s1
, "d", 100) != 0)
32 if (strncmp ("d", s1
+10, 1) != 0)
34 if (strncmp ("d", 10+s1
, 1) != 0)
36 if (strncmp ("hello", "aaaaa", 100) <= 0)
38 if (strncmp ("aaaaa", "hello", 100) >= 0)
40 if (strncmp ("hello", "aaaaa", 1) <= 0)
42 if (strncmp ("aaaaa", "hello", 1) >= 0)
46 if (strncmp (++s2
, ++s3
, 0) != 0 || s2
!= s1
+1 || s3
!= s1
+5)
49 if (strncmp (++s2
, "", 1) <= 0 || s2
!= s1
+1)
51 if (strncmp ("", ++s2
, 1) >= 0 || s2
!= s1
+2)
53 if (strncmp (++s2
, "", 100) <= 0 || s2
!= s1
+3)
55 if (strncmp ("", ++s2
, 100) >= 0 || s2
!= s1
+4)
57 if (strncmp (++s2
+6, "", 100) != 0 || s2
!= s1
+5)
59 if (strncmp ("", ++s2
+5, 100) != 0 || s2
!= s1
+6)
61 if (strncmp ("ozz", ++s2
, 1) != 0 || s2
!= s1
+7)
63 if (strncmp (++s2
, "rzz", 1) != 0 || s2
!= s1
+8)
66 if (strncmp (++s2
, ++s3
+2, 1) >= 0 || s2
!= s1
+1 || s3
!= s1
+5)
69 /* Test at least one instance of the __builtin_ style. We do this
70 to ensure that it works and that the prototype is correct. */
71 if (__builtin_strncmp ("hello", "a", 100) <= 0)