diff options
author | David Robillard <d@drobilla.net> | 2020-12-18 17:01:09 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-12-18 17:38:58 +0100 |
commit | f38626d31547445c1acb73d5838b1655cf8a2639 (patch) | |
tree | 37a6c4b1c4bf4996ec2f995f33c23ddbd4a97c2a /test | |
parent | 189435d25fe03148d4a701e2cd79a931bf26796c (diff) | |
download | lilv-f38626d31547445c1acb73d5838b1655cf8a2639.tar.gz lilv-f38626d31547445c1acb73d5838b1655cf8a2639.tar.bz2 lilv-f38626d31547445c1acb73d5838b1655cf8a2639.zip |
Windows: Prefer backslash as a path separator
This situation is, as always, a total nightmare. In an attempt to not make
weird paths with mixed separators, a heuristic is used here which uses forward
slash if it seems that the input paths do. Otherwise, backslash (the
"preferred" separator on Windows despite all good sense) is used.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_filesystem.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/test/test_filesystem.c b/test/test_filesystem.c index 4faaf15..7e1968d 100644 --- a/test/test_filesystem.c +++ b/test/test_filesystem.c @@ -138,6 +138,18 @@ test_path_relative_to(void) assert(equals(lilv_path_relative_to("/a", "/b/c/"), "/a")); assert(equals(lilv_path_relative_to("/a/b/c", "/a/b/d/"), "../c")); assert(equals(lilv_path_relative_to("/a/b/c", "/a/b/d/e/"), "../../c")); + +#ifdef _WIN32 + assert(equals(lilv_path_relative_to("C:/a/b", "C:/a/"), "b")); + assert(equals(lilv_path_relative_to("C:/a", "C:/b/c/"), "../../a")); + assert(equals(lilv_path_relative_to("C:/a/b/c", "C:/a/b/d/"), "../c")); + assert(equals(lilv_path_relative_to("C:/a/b/c", "C:/a/b/d/e/"), "../../c")); + + assert(equals(lilv_path_relative_to("C:\\a\\b", "C:\\a\\"), "b")); + assert(equals(lilv_path_relative_to("C:\\a", "C:\\b\\c\\"), "..\\..\\a")); + assert(equals(lilv_path_relative_to("C:\\a\\b\\c", "C:\\a\\b\\d\\"), "..\\c")); + assert(equals(lilv_path_relative_to("C:\\a\\b\\c", "C:\\a\\b\\d\\e\\"), "..\\..\\c")); +#endif } static void @@ -183,14 +195,25 @@ test_path_join(void) { assert(lilv_path_join(NULL, NULL) == NULL); assert(lilv_path_join(NULL, "") == NULL); + +#ifdef _WIN32 + assert(equals(lilv_path_join("", NULL), "\\")); + assert(equals(lilv_path_join("", ""), "\\")); + assert(equals(lilv_path_join("a", ""), "a\\")); + assert(equals(lilv_path_join("a", NULL), "a\\")); + assert(equals(lilv_path_join("a", "b"), "a\\b")); +#else assert(equals(lilv_path_join("", NULL), "/")); assert(equals(lilv_path_join("", ""), "/")); + assert(equals(lilv_path_join("a", ""), "a/")); + assert(equals(lilv_path_join("a", NULL), "a/")); + assert(equals(lilv_path_join("a", "b"), "a/b")); +#endif assert(equals(lilv_path_join("/a", ""), "/a/")); assert(equals(lilv_path_join("/a/b", ""), "/a/b/")); assert(equals(lilv_path_join("/a/", ""), "/a/")); assert(equals(lilv_path_join("/a/b/", ""), "/a/b/")); - assert(equals(lilv_path_join("a", ""), "a/")); assert(equals(lilv_path_join("a/b", ""), "a/b/")); assert(equals(lilv_path_join("a/", ""), "a/")); assert(equals(lilv_path_join("a/b/", ""), "a/b/")); @@ -199,20 +222,25 @@ test_path_join(void) assert(equals(lilv_path_join("/a/b", NULL), "/a/b/")); assert(equals(lilv_path_join("/a/", NULL), "/a/")); assert(equals(lilv_path_join("/a/b/", NULL), "/a/b/")); - assert(equals(lilv_path_join("a", NULL), "a/")); assert(equals(lilv_path_join("a/b", NULL), "a/b/")); assert(equals(lilv_path_join("a/", NULL), "a/")); assert(equals(lilv_path_join("a/b/", NULL), "a/b/")); assert(equals(lilv_path_join("/a", "b"), "/a/b")); assert(equals(lilv_path_join("/a/", "b"), "/a/b")); - assert(equals(lilv_path_join("a", "b"), "a/b")); assert(equals(lilv_path_join("a/", "b"), "a/b")); assert(equals(lilv_path_join("/a", "b/"), "/a/b/")); assert(equals(lilv_path_join("/a/", "b/"), "/a/b/")); assert(equals(lilv_path_join("a", "b/"), "a/b/")); assert(equals(lilv_path_join("a/", "b/"), "a/b/")); + +#ifdef _WIN32 + assert(equals(lilv_path_join("C:/a", "b"), "C:/a/b")); + assert(equals(lilv_path_join("C:\\a", "b"), "C:\\a\\b")); + assert(equals(lilv_path_join("C:/a", "b/"), "C:/a/b/")); + assert(equals(lilv_path_join("C:\\a", "b\\"), "C:\\a\\b\\")); +#endif } static void |