7 #define N(s, tail, sub) { \
9 char *q = memmem(p, strlen(s), sub, strlen(sub)); \
11 t_error("memmem("#s" "#tail", %d, "#sub", %d) returned str+%d, wanted 0\n",\
12 strlen(s), strlen(sub), q-p); \
15 #define T(s, sub, n) { \
17 char *q = memmem(p, strlen(p), sub, strlen(sub)); \
19 t_error("memmem(%s,%s) returned 0, wanted str+%d\n", #s, #sub, n); \
20 else if (q - p != n) \
21 t_error("memmem(%s,%s) returned str+%d, wanted str+%d\n", #s, #sub, q-p, n); \
34 N("abc abc","d", "abcd")
35 N("0-1-2-3-4-5-6-7-8-9","", "-3-4-56-7-8-")
36 N("0-1-2-3-4-5-6-7-8-9","", "-3-4-5+6-7-8-")
37 N("_ _ _\xff_ _ _","\x7f_", "_\x7f_")
38 N("_ _ _\x7f_ _ _","\xff_", "_\xff_")
50 T("ababab", "babab", 1)
51 T("abababa", "bababa", 1)
52 T("abababab", "bababab", 1)
53 T("ababababa", "babababa", 1)
54 T("abbababab", "bababa", 2)
55 T("abbababab", "ababab", 3)
56 T("abacabcabcab", "abcabcab", 4)
57 T("nanabanabanana", "aba", 3)
58 T("nanabanabanana", "ban", 4)
59 T("nanabanabanana", "anab", 1)
60 T("nanabanabanana", "banana", 8)
61 T("_ _\xff_ _", "_\xff_", 2)