1
/* $Id: strcspn_P.c,v 1.1 2007/03/01 13:06:02 dmix Exp $ */
5
# define strcspn_P strcspn
11
void Check (int line, const char *s1, const char *s2, size_t expect)
16
if (strlen_P(s1) > sizeof(t1) - 1)
19
n = strcspn_P (t1, s2);
23
printf ("\nLine %d: expect: %d, result: %d\n",
25
if (line > 255) line = 255;
32
#define CHECK(s1, s2, expect) do { \
33
Check (__LINE__, PSTR(s1), PSTR(s2), expect); \
41
CHECK ("", "abcdef", 0);
43
CHECK ("0123456789", "", 10);
45
/* accept[] length is 1. */
47
CHECK ("abcdefghij", "A", 10);
49
CHECK ("AAAAAAAA", "A", 0);
51
/* accept[] length is 2. */
53
CHECK ("cd", "ab", 2);
54
CHECK ("cde", "ab", 3);
56
CHECK (".a", "ab", 1);
57
CHECK ("..a", "ab", 2);
58
CHECK ("...a", "ab", 3);
60
CHECK (".b", "ab", 1);
61
CHECK ("..b", "ab", 2);
62
CHECK ("...b", "ab", 3);
63
CHECK ("0101010101", "23", 10);
64
CHECK ("0123456789AB", ".A", 10);
66
/* accept[] length > 2 */
67
CHECK ("the quick brown fox", "QWERTYUIOPASDFGHJKLZXCVBNM", 19);
68
CHECK ("the quick brown fox ...", ".QWERTYUIOPASDFGHJKLZXCVBNM", 20);
69
CHECK ("the quick brown fox .?", "QWERTYUIOPASDFGHJKLZXCVBNM?", 21);
72
CHECK ("\001", "\001", 0);
73
CHECK ("\377", "\377", 0);
74
CHECK ("\002\376", "\001\377", 2);
76
/* Result approx. 256 */
77
CHECK ("................................................................"
78
"................................................................"
79
"................................................................"
80
"...............................................................",
82
CHECK ("................................................................"
83
"................................................................"
84
"................................................................"
85
"................................................................",
87
CHECK ("................................................................"
88
"................................................................"
89
"................................................................"
90
"................................................................"