1
/* $Id: strrchr_P.c,v 1.1 2007/03/01 13:06:02 dmix Exp $ */
5
# define strrchr_P strrchr
11
void Check (int line, const char *s, int c, int expect)
15
if (expect == -1 && !p)
20
printf ("\nLine %d: expect: %d, result: %d\n",
21
line, expect, (p ? p-s : -1));
26
#define CHECK(s, c, expect) do { \
27
Check (__LINE__, PSTR(s), c, expect); \
35
CHECK ("ABCDEF", 'a', -1);
39
CHECK ("\377", 255, 0);
40
CHECK ("987654321", '7', 2);
42
/* '\0' is a part of string */
43
CHECK ("12345", 0, 5);
48
CHECK ("abcdabcd", 'b', 5);
49
CHECK ("***********", '*', 10);
51
/* 'c' converted to a char */
52
CHECK ("ABCDEF", 'A'+0x100, 0);
53
CHECK ("ABCDE\377", ~0, 5);
54
CHECK ("+", ~0xff, 1);
56
/* Very long string */
57
CHECK ("................................................................"
58
"................................................................"
59
"................................................................"
60
"................................................................"
61
"*...............", '*', 256);