]> git.ozlabs.org Git - ccan/blob - ccan/memmem/test/run.c
Syntax highlighting for module example code using prettify. Note: prettify is introdu...
[ccan] / ccan / memmem / test / run.c
1 #include <ccan/array_size/array_size.h>
2 #include <ccan/memmem/memmem.h>
3 #include <ccan/tap/tap.h>
4
5 int main(void)
6 {
7         char haystack1[] = "abcd\0efgh";
8         char needle1[] = "ab";
9         char needle2[] = "d\0e";
10
11         /* This is how many tests you plan to run */
12         plan_tests(3);
13
14         ok1(memmem(haystack1, sizeof(haystack1), needle1, 2) == haystack1);
15         ok1(memmem(haystack1, sizeof(haystack1), needle1, 3) == NULL);
16         ok1(memmem(haystack1, sizeof(haystack1), needle2, 3) == (haystack1 + 3));
17
18         /* This exits depending on whether all tests passed */
19         return exit_status();
20 }