MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / main

Function main

libavutil/tests/avstring.c:25–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23#include "libavutil/avstring.h"
24
25int main(void)
26{
27 int i;
28 char *fullpath, *ptr;
29 static const char * const strings[] = {
30 "''",
31 "",
32 ":",
33 "\\",
34 "'",
35 " '' :",
36 " '' '' :",
37 "foo '' :",
38 "'foo'",
39 "foo ",
40 " ' foo ' ",
41 "foo\\",
42 "foo': blah:blah",
43 "foo\\: blah:blah",
44 "foo\'",
45 "'foo : ' :blahblah",
46 "\\ :blah",
47 " foo",
48 " foo ",
49 " foo \\ ",
50 "foo ':blah",
51 " foo bar : blahblah",
52 "\\f\\o\\o",
53 "'foo : \\ \\ ' : blahblah",
54 "'\\fo\\o:': blahblah",
55 "\\'fo\\o\\:': foo ' :blahblah"
56 };
57 const char *haystack = "Education consists mainly in what we have unlearned.";
58 const char * const needle[] = {"learned.", "unlearned.", "Unlearned"};
59
60 printf("Testing av_get_token()\n");
61 for (i = 0; i < FF_ARRAY_ELEMS(strings); i++) {
62 const char *p = strings[i];
63 char *q;
64 printf("|%s|", p);
65 q = av_get_token(&p, ":");
66 printf(" -> |%s|", q);
67 printf(" + |%s|\n", p);
68 av_free(q);
69 }
70
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); \
75 av_free(fullpath);
76 TEST_APPEND_PATH_COMPONENT(NULL, NULL, "(null)")
77 TEST_APPEND_PATH_COMPONENT("path", NULL, "path");
78 TEST_APPEND_PATH_COMPONENT(NULL, "comp", "comp");
79 TEST_APPEND_PATH_COMPONENT("path", "comp", "path/comp");
80 TEST_APPEND_PATH_COMPONENT("path/", "comp", "path/comp");
81 TEST_APPEND_PATH_COMPONENT("path", "/comp", "path/comp");
82 TEST_APPEND_PATH_COMPONENT("path/", "/comp", "path/comp");

Callers

nothing calls this directly

Calls 2

av_get_tokenFunction · 0.85
av_freeFunction · 0.50

Tested by

no test coverage detected