Commit 1a277242 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

url: use common test harness for URI resolve and fixup

parent e2a296be
...@@ -142,38 +142,19 @@ static void test_url_parse(const char* in, const char* protocol, const char* use ...@@ -142,38 +142,19 @@ static void test_url_parse(const char* in, const char* protocol, const char* use
#undef CHECK #undef CHECK
} }
static void test_url_resolve(const char *base, const char *reference, static char *vlc_uri_resolve_rfc3986_test(const char *in)
const char *expected)
{ {
fprintf(stderr, "(%s) \"%s\" -> \"%s\" ?\n", base, reference, expected); return vlc_uri_resolve("http://a/b/c/d;p?q", in);
char *result = vlc_uri_resolve(base, reference);
assert(result != NULL);
if (strcmp(result, expected))
{
fprintf(stderr, " ERROR: got \"%s\"\n", result);
abort();
}
free(result);
} }
static void test_rfc3986(const char *reference, const char *expected) static void test_rfc3986(const char *reference, const char *expected)
{ {
test_url_resolve("http://a/b/c/d;p?q", reference, expected); test(vlc_uri_resolve_rfc3986_test, reference, expected);
} }
static void test_fixup_noop(const char *expected) static void test_fixup_noop(const char *expected)
{ {
fprintf(stderr, "\"%s\" -> \"%s\" ?\n", expected, expected); test(vlc_uri_fixup, expected, expected);
char *result = vlc_uri_fixup(expected);
assert(result != NULL);
if (strcmp(result, expected))
{
fprintf(stderr, " ERROR: got \"%s\"\n", result);
abort();
}
free(result);
} }
int main (void) int main (void)
......
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