aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-11-14 10:39:05 -0500
committerDavid Robillard <d@drobilla.net>2022-11-14 16:07:28 -0500
commit8334438cb5cb9756885248a952b9feb480eebc8c (patch)
tree3712d121273ea71f05b92a4b2e5db9b8ddade95f /test
parent655c7fcf6c7ce9f98106dfca9cff5dede749b1bd (diff)
downloadserd-8334438cb5cb9756885248a952b9feb480eebc8c.tar.gz
serd-8334438cb5cb9756885248a952b9feb480eebc8c.tar.bz2
serd-8334438cb5cb9756885248a952b9feb480eebc8c.zip
Add Windows path separator support to serd_node_new_file_uri()
Diffstat (limited to 'test')
-rw-r--r--test/test_uri.c56
1 files changed, 51 insertions, 5 deletions
diff --git a/test/test_uri.c b/test/test_uri.c
index c79e618d..ea66d0f1 100644
--- a/test/test_uri.c
+++ b/test/test_uri.c
@@ -81,17 +81,63 @@ static void
test_uri_parsing(void)
{
test_file_uri(NULL, "C:/My 100%", true, "file:///C:/My%20100%%", NULL);
- test_file_uri("ahost",
- "C:\\Pointless Space",
- true,
- "file://ahost/C:/Pointless%20Space",
- "C:/Pointless Space");
test_file_uri(NULL, "/foo/bar", true, "file:///foo/bar", NULL);
test_file_uri("bhost", "/foo/bar", true, "file://bhost/foo/bar", NULL);
test_file_uri(NULL, "a/relative path", false, "a/relative path", NULL);
test_file_uri(
NULL, "a/relative <path>", true, "a/relative%20%3Cpath%3E", NULL);
+#ifdef _WIN32
+ test_file_uri(
+ NULL, "C:\\My 100%", true, "file:///C:/My%20100%%", "C:/My 100%");
+
+ test_file_uri(NULL,
+ "\\drive\\relative",
+ true,
+ "file:///drive/relative",
+ "/drive/relative");
+
+ test_file_uri(NULL,
+ "C:\\Program Files\\Serd",
+ true,
+ "file:///C:/Program%20Files/Serd",
+ "C:/Program Files/Serd");
+
+ test_file_uri("ahost",
+ "C:\\Pointless Space",
+ true,
+ "file://ahost/C:/Pointless%20Space",
+ "C:/Pointless Space");
+#else
+ /* What happens with Windows paths on other platforms is a bit weird, but
+ more or less unavoidable. It doesn't work to interpret backslashes as
+ path separators on any other platform. */
+
+ test_file_uri("ahost",
+ "C:\\Pointless Space",
+ true,
+ "file://ahost/C:%5CPointless%20Space",
+ "/C:\\Pointless Space");
+
+ test_file_uri(NULL,
+ "\\drive\\relative",
+ true,
+ "%5Cdrive%5Crelative",
+ "\\drive\\relative");
+
+ test_file_uri(NULL,
+ "C:\\Program Files\\Serd",
+ true,
+ "file:///C:%5CProgram%20Files%5CSerd",
+ "/C:\\Program Files\\Serd");
+
+ test_file_uri("ahost",
+ "C:\\Pointless Space",
+ true,
+ "file://ahost/C:%5CPointless%20Space",
+ "/C:\\Pointless Space");
+#endif
+
// Test tolerance of parsing junk URI escapes
uint8_t* out_path = serd_file_uri_parse(USTR("file:///foo/%0Xbar"), NULL);