X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftest%2Furl.c;h=875c9a5f7b37a588f8fbba482e712428abe679b7;hb=14f37b2101842fa6e427f962f689db74eff6faba;hp=a097aca0277beb8f711330a7bfd582bf2ceb2bf2;hpb=d666030b2349e8a710fcba4d2cabb912cc700580;p=vlc diff --git a/src/test/url.c b/src/test/url.c index a097aca027..875c9a5f7b 100644 --- a/src/test/url.c +++ b/src/test/url.c @@ -29,6 +29,7 @@ #include #include +#include typedef char * (*conv_t) (const char *); @@ -60,8 +61,24 @@ static inline void test_b64 (const char *in, const char *out) test (vlc_b64_encode, in, out); } +static inline void test_path (const char *in, const char *out) +{ + test (make_URI, in, out); +} + +static inline void test_current_directory_path (const char *in, const char *cwd, const char *out) +{ + char * expected_result = NULL; + int val = asprintf(&expected_result, "file://%s/%s", cwd, out); + assert (val != -1); + + test (make_URI, in, expected_result); +} + int main (void) { + int val; + (void)setvbuf (stdout, NULL, _IONBF, 0); test_decode ("this_should_not_be_modified_1234", "this_should_not_be_modified_1234"); @@ -93,5 +110,31 @@ int main (void) test_b64 ("fooba", "Zm9vYmE="); test_b64 ("foobar", "Zm9vYmFy"); + /* Path test */ + test_path ("file:///", "file:///"); + test_path ("http://www.example.com/%7Ejohn/", + "http://www.example.com/%7Ejohn/"); + test_path ("/", "file:///"); + test_path ("/home/john/", "file:///home/john/"); + test_path ("/home/john/music.ogg", "file:///home/john/music.ogg"); + //test_path ("\\\\server/pub/music.ogg", "file://server/pub/music.ogg"); + + /*int fd = open (".", O_RDONLY); + assert (fd != -1);*/ + val = chdir ("/tmp"); + assert (val != -1); + + char buf[256]; + char * tmpdir; + tmpdir = getcwd(buf, sizeof(buf)/sizeof(*buf)); + assert (tmpdir); + + test_current_directory_path ("movie.ogg", tmpdir, "movie.ogg"); + test_current_directory_path (".", tmpdir, "."); + test_current_directory_path ("", tmpdir, ""); + + /*val = fchdir (fd); + assert (val != -1);*/ + return 0; }