Commit 8549e2b0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Additionnal unit test for decode_URI

parent 55687512
...@@ -22,29 +22,44 @@ ...@@ -22,29 +22,44 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include "vlc_url.h" #include "vlc_url.h"
#undef NDEBUG #include <stdio.h>
#include <assert.h> #include <stdlib.h>
void test_decode (const char *in, const char *out)
{
char *res;
printf ("\"%s\" -> \"%s\" ?\n", in, out);
res = decode_URI_duplicate (in);
if (res == NULL)
exit (1);
if (strcmp (res, out))
exit (2);
free (res);
}
int main (void) int main (void)
{ {
const char url1[] = "this_should_not_be_modified_1234"; (void)setvbuf (stdout, NULL, _IONBF, 0);
const char url2[] = "This+should+be+modified+1234!"; test_decode ("this_should_not_be_modified_1234",
const char url3[] = "This%20should%20be%20modified%201234!"; "this_should_not_be_modified_1234");
char *durl = decode_URI_duplicate (url1); test_decode ("This+should+be+modified+1234!",
assert (durl != NULL); "This should be modified 1234!");
assert (!strcmp (durl, url1));
free (durl); test_decode ("This%20should%20be%20modified%201234!",
"This should be modified 1234!");
durl = decode_URI_duplicate (url2);
assert (durl != NULL); /* tests with invalid input */
assert (!strcmp (durl, "This should be modified 1234!")); test_decode ("%", "%");
free (durl); test_decode ("%2", "%2");
test_decode ("%0000", "");
durl = decode_URI_duplicate (url3);
assert (durl != NULL); /* UTF-8 tests */
assert (!strcmp (durl, "This should be modified 1234!")); test_decode ("T%C3%a9l%c3%A9vision", "Télévision");
free (durl); test_decode ("T%E9l%E9vision", "T?l?vision");
return 0; 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