aboutsummaryrefslogtreecommitdiffstats
path: root/src/serd_test.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-12-24 22:14:46 +0000
committerDavid Robillard <d@drobilla.net>2011-12-24 22:14:46 +0000
commit544486680095d1024ae991ce95cde52080cbf43c (patch)
tree8c1cd74c86bef156eaf4402641a2aa5f1df12d12 /src/serd_test.c
parent834aede2613d3973170d9314e4a43695dfc14bf2 (diff)
downloadserd-544486680095d1024ae991ce95cde52080cbf43c.tar.gz
serd-544486680095d1024ae991ce95cde52080cbf43c.tar.bz2
serd-544486680095d1024ae991ce95cde52080cbf43c.zip
Support file://localhost/foo URIs in serd_uri_to_path().
Support Windows file://c:/foo URIs in serd_uri_to_path() on all platforms. 100% test coverage (by line) for uri.c. git-svn-id: http://svn.drobilla.net/serd/trunk@269 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/serd_test.c')
-rw-r--r--src/serd_test.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/serd_test.c b/src/serd_test.c
index cf211e7b..725517b4 100644
--- a/src/serd_test.c
+++ b/src/serd_test.c
@@ -126,6 +126,7 @@ main()
}
// Test serd_strlen
+
const uint8_t str[] = { '"', '5', 0xE2, 0x82, 0xAC, '"', '\n', 0 };
size_t n_bytes;
@@ -139,6 +140,7 @@ main()
}
// Test serd_strerror
+
const uint8_t* msg = NULL;
if (strcmp((const char*)(msg = serd_strerror(SERD_SUCCESS)), "Success")) {
fprintf(stderr, "Bad message `%s' for SERD_SUCCESS\n", msg);
@@ -151,7 +153,29 @@ main()
return 1;
}
}
-
+
+ // Test serd_uri_to_path
+ const uint8_t* uri = (const uint8_t*)"file:///home/user/foo.ttl";
+ if (strcmp((const char*)serd_uri_to_path(uri), "/home/user/foo.ttl")) {
+ fprintf(stderr, "Bad path %s for %s\n", serd_uri_to_path(uri), uri);
+ return 1;
+ }
+ uri = (const uint8_t*)"file://localhost/home/user/foo.ttl";
+ if (strcmp((const char*)serd_uri_to_path(uri), "/home/user/foo.ttl")) {
+ fprintf(stderr, "Bad path %s for %s\n", serd_uri_to_path(uri), uri);
+ return 1;
+ }
+ uri = (const uint8_t*)"file:illegal/file/uri";
+ if (serd_uri_to_path(uri)) {
+ fprintf(stderr, "Converted invalid URI `%s' to path `%s'\n",
+ uri, serd_uri_to_path(uri));
+ }
+ uri = (const uint8_t*)"file:///c:/awful/system";
+ if (strcmp((const char*)serd_uri_to_path(uri), "c:/awful/system")) {
+ fprintf(stderr, "Bad path %s for %s\n", serd_uri_to_path(uri), uri);
+ return 1;
+ }
+
printf("Success\n");
return 0;
}