.
[glibc/history.git] / string / tst-svc2.c
blob12c88aa2b8c10c71943ad3dad745f4cc5e68a13c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
6 static struct
8 const char *str1;
9 const char *str2;
10 } tests[] =
12 { "B0075022800016.gbp.corp.com", "B007502280067.gbp.corp.com" },
13 { "B0075022800016.gbp.corp.com", "B007502357019.GBP.CORP.COM" },
14 { "B007502280067.gbp.corp.com", "B007502357019.GBP.CORP.COM" }
16 #define ntests (sizeof (tests) / sizeof (tests[0]))
19 int
20 compare (const char *str1, const char *str2, int exp)
22 int c = strverscmp (str1, str2);
23 if (c != 0)
24 c /= abs (c);
25 return c != exp;
29 static int
30 do_test (void)
32 int res = 0;
33 for (int i = 0; i < ntests; ++i)
35 if (compare (tests[i].str1, tests[i].str2, -1))
37 printf ("FAIL: \"%s\" > \"%s\"\n", tests[i].str1, tests[i].str2);
38 res = 1;
40 if (compare (tests[i].str2, tests[i].str1, +1))
42 printf ("FAIL: \"%s\" > \"%s\"\n", tests[i].str2, tests[i].str1);
43 res = 1;
45 char *copy1 = strdupa (tests[i].str1);
46 if (compare (tests[i].str1, copy1, 0))
48 printf ("FAIL: \"%s\" != \"%s\"\n", tests[i].str1, copy1);
49 res = 1;
51 char *copy2 = strdupa (tests[i].str2);
52 if (compare (tests[i].str2, copy2, 0))
54 printf ("FAIL: \"%s\" != \"%s\"\n", tests[i].str2, copy2);
55 res = 1;
58 return res;
61 #define TEST_FUNCTION do_test ()
62 #include "../test-skeleton.c"