29 static const char *
const strings[] = {
51 " foo bar : blahblah",
53 "'foo : \\ \\ ' : blahblah",
54 "'\\fo\\o:': blahblah",
55 "\\'fo\\o\\:': foo ' :blahblah"
57 const char *haystack =
"Education consists mainly in what we have unlearned.";
58 const char *
const needle[] = {
"learned.",
"unlearned.",
"Unlearned"};
60 printf(
"Testing av_get_token()\n");
62 const char *p = strings[
i];
71 printf(
"Testing av_append_path_component()\n");
72 #define TEST_APPEND_PATH_COMPONENT(path, component, expected) \
73 fullpath = av_append_path_component((path), (component)); \
74 printf("%s = %s\n", fullpath ? fullpath : "(null)", expected); \
86 #define TEST_STRNSTR(haystack, needle, hay_length, expected) \
87 ptr = av_strnstr(haystack, needle, hay_length); \
88 if (ptr != expected){ \
89 printf("expected: %p, received %p\n", expected, ptr); \
91 TEST_STRNSTR(haystack, needle [0], strlen(haystack), haystack+44);
92 TEST_STRNSTR(haystack, needle [1], strlen(haystack), haystack+42);
94 TEST_STRNSTR(haystack, strings[1], strlen(haystack), haystack );
97 #define TEST_STRIREPLACE(haystack, needle, expected) \
98 ptr = av_strireplace(haystack, needle, "instead"); \
100 printf("error, received null pointer!\n"); \
102 if (strcmp(ptr, expected) != 0) \
103 printf( "expected: %s, received: %s\n", expected, ptr); \
107 TEST_STRIREPLACE(haystack, needle [0],
"Education consists mainly in what we have uninstead");
108 TEST_STRIREPLACE(haystack, needle [1],
"Education consists mainly in what we have instead");
109 TEST_STRIREPLACE(haystack, needle [2],
"Education consists mainly in what we have instead.");
110 TEST_STRIREPLACE(haystack, needle [1],
"Education consists mainly in what we have instead");