1
/* $Id: strcasecmp.c,v 1.1 2007/02/24 14:20:17 dmix Exp $ */
10
void Check (int line, const char *s1, const char *s2, int expect)
15
if ( strlen_P(s1) > sizeof(t1) - 1
16
|| strlen_P(s2) > sizeof(t2) - 1)
20
i = strcasecmp (t1, t2);
24
printf ("\nLine %d: expect: %d, result: %d\n",
26
if (line > 255) line = 255;
33
#define CHECK(s1, s2, expect) do { \
34
Check (__LINE__, PSTR(s1), PSTR(s2), expect); \
39
/* One or both strings are empty. */
41
CHECK ("", "\001", -1);
42
CHECK ("", "\377", -255);
43
CHECK ("\001", "", 1);
44
CHECK ("\377", "", 255);
47
CHECK ("a", "[", 'a' - '[');
48
CHECK ("[", "a", '[' - 'a');
51
CHECK ("\001", "\001", 0);
52
CHECK ("1234\377", "1234\377", 0);
53
CHECK ("ABC", "abc", 0);
54
CHECK ("FoO", "fOO", 0);
56
/* Args are not equal. */
57
CHECK ("@", "`", '@' - '`'); /* '@'=='A'-1, '`'=='a'-1 */
58
CHECK ("{", "[", '{' - '['); /* '{'=='z'+1, '['=='A'+1 */
60
/* Alpha is always converted to lower */
61
CHECK ("1", "A", '1'-'a');
62
CHECK ("Z", "2", 'z'-'2');
64
/* Chars are unsigned */
65
CHECK ("\200", "\177", 1);
66
CHECK ("\177", "\200", -1);
67
CHECK ("\001", "\377", -254);
68
CHECK ("\377", "\001", 254);