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];
66 printf(
" -> |%s|", q);
67 printf(
" + |%s|\n", p);
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");
113 #define TEST_D2STR(value, expected) \
114 if((ptr = av_d2str(value)) == NULL){ \
115 printf("error, received null pointer!\n"); \
117 if(strcmp(ptr, expected) != 0) \
118 printf( "expected: %s, received: %s\n", expected, ptr); \
Memory handling functions.
#define TEST_D2STR(value, expected)
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
#define TEST_STRIREPLACE(haystack, needle, expected)
#define FF_ARRAY_ELEMS(a)
#define TEST_STRNSTR(haystack, needle, hay_length, expected)
common internal and external API header
#define TEST_APPEND_PATH_COMPONENT(path, component, expected)