Commit 833d3e97 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

uri: test cases for vlc_uri_resolve()

parent 52f5ce5f
......@@ -113,6 +113,26 @@ static void test_url_parse(const char* in, const char* protocol, const char* use
#undef CHECK
static void test_url_resolve(const char *base, const char *reference,
const char *expected)
fprintf(stderr, "(%s) \"%s\" -> \"%s\" ?\n", base, reference, expected);
char *result = vlc_uri_resolve(base, reference);
assert(result != NULL);
if (strcmp(result, expected))
fprintf(stderr, " ERROR: got \"%s\"\n", result);
static void test_rfc3986(const char *reference, const char *expected)
test_url_resolve("http://a/b/c/d;p?q", reference, expected);
int main (void)
int val;
......@@ -246,5 +266,59 @@ int main (void)
/* Invalid URIs */
test_url_parse("p://G a r b a g e", "p", NULL, NULL, NULL, 0, NULL, NULL);
test_url_parse("p://h/G a r b a g e", "p", NULL, NULL, "h", 0, NULL, NULL);
/* Reference test cases for reference URI resolution */
static const char *rfc3986_cases[] =
"g:h", "g:h",
"g", "http://a/b/c/g",
"./g", "http://a/b/c/g",
"g/", "http://a/b/c/g/",
"/g", "http://a/g",
"//g", "http://g",
"?y", "http://a/b/c/d;p?y",
"g?y", "http://a/b/c/g?y",
//"#s", "http://a/b/c/d;p?q#s",
//"g#s", "http://a/b/c/g#s",
//"g?y#s", "http://a/b/c/g?y#s",
";x", "http://a/b/c/;x",
"g;x", "http://a/b/c/g;x",
//"g;x?y#s", "http://a/b/c/g;x?y#s",
"", "http://a/b/c/d;p?q",
".", "http://a/b/c/",
"./", "http://a/b/c/",
"..", "http://a/b/",
"../", "http://a/b/",
"../g", "http://a/b/g",
"../..", "http://a/",
"../../", "http://a/",
"../../g", "http://a/g",
"../../../g", "http://a/g",
"../../../../g", "http://a/g",
"/./g", "http://a/g",
"/../g", "http://a/g",
"g.", "http://a/b/c/g.",
".g", "http://a/b/c/.g",
"g..", "http://a/b/c/g..",
"..g", "http://a/b/c/..g",
"./../g", "http://a/b/g",
"./g/.", "http://a/b/c/g/",
"g/./h", "http://a/b/c/g/h",
"g/../h", "http://a/b/c/h",
"g;x=1/./y", "http://a/b/c/g;x=1/y",
"g;x=1/../y", "http://a/b/c/y",
"g?y/./x", "http://a/b/c/g?y/./x",
"g?y/../x", "http://a/b/c/g?y/../x",
//"g#s/./x", "http://a/b/c/g#s/./x",
//"g#s/../x", "http://a/b/c/g#s/../x",
for (size_t i = 0; i < ARRAY_SIZE(rfc3986_cases); i += 2)
test_rfc3986(rfc3986_cases[i], rfc3986_cases[i + 1]);
return 0;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment