]> git.sesse.net Git - vlc/blobdiff - src/test/url.c
playlist: fix first subitem added as last and refactor
[vlc] / src / test / url.c
index 875c9a5f7b37a588f8fbba482e712428abe679b7..f5df985fab8603d1771cfb5c7989f41edcbf9c7f 100644 (file)
@@ -37,12 +37,19 @@ static void test (conv_t f, const char *in, const char *out)
 {
     char *res;
 
-    printf ("\"%s\" -> \"%s\" ?\n", in, out);
+    if (out != NULL)
+       printf ("\"%s\" -> \"%s\" ?\n", in, out);
+    else
+       printf ("\"%s\" -> NULL ?\n", in);
     res = f (in);
     if (res == NULL)
-        exit (1);
-
-    if (strcmp (res, out))
+    {
+        if (out == NULL)
+            return; /* good: NULL -> NULL */
+        puts (" ERROR: got NULL");
+        exit (2);
+    }
+    if (out == NULL || strcmp (res, out))
     {
         printf (" ERROR: got \"%s\"\n", res);
         exit (2);
@@ -117,7 +124,8 @@ int main (void)
     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");
+    test_path ("\\\\server/pub/music.ogg", "smb://server/pub/music.ogg");
+    test_path ("\\\\server\\pub\\music.ogg", "smb://server/pub/music.ogg");
 
     /*int fd = open (".", O_RDONLY);
     assert (fd != -1);*/
@@ -136,5 +144,19 @@ int main (void)
     /*val = fchdir (fd);
     assert (val != -1);*/
 
+    /* URI to path tests */
+#define test( a, b ) test (make_path, a, b)
+    test ("mailto:john@example.com", NULL);
+    test ("http://www.example.com/file.html#ref", NULL);
+    test ("file://", NULL);
+    test ("file:///", "/");
+    test ("file://localhost/home/john/music%2Eogg", "/home/john/music.ogg");
+    test ("file://localhost/home/john/text#ref", "/home/john/text");
+    test ("fd://0foobar", NULL);
+    test ("fd://0#ref", "/dev/stdin");
+    test ("fd://1", "/dev/stdout");
+    test ("fd://12345", "/dev/fd/12345");
+#undef test
+
     return 0;
 }