aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_uri.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-10 09:45:15 +0100
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:06 -0500
commit8f1192bb2361fcd7907b926e86c41a171ed04ad0 (patch)
treefdaeb65c1210c09128b890cd452b7940644e49a4 /test/test_uri.c
parent79367b620492ac941f41c61adbffc29867ac0998 (diff)
downloadserd-8f1192bb2361fcd7907b926e86c41a171ed04ad0.tar.gz
serd-8f1192bb2361fcd7907b926e86c41a171ed04ad0.tar.bz2
serd-8f1192bb2361fcd7907b926e86c41a171ed04ad0.zip
Add serd_new_real_file_uri()
Diffstat (limited to 'test/test_uri.c')
-rw-r--r--test/test_uri.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/test_uri.c b/test/test_uri.c
index 88aa342c..dff4d999 100644
--- a/test/test_uri.c
+++ b/test/test_uri.c
@@ -20,6 +20,11 @@
#include "serd/serd.h"
+#if defined(_WIN32) && !defined(__MINGW32__)
+# include <io.h>
+# define mkstemp(pat) _mktemp(pat)
+#endif
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -80,6 +85,24 @@ test_uri_parsing(void)
}
static void
+test_real_file_uri(void)
+{
+ char path[16];
+ strncpy(path, "serd_XXXXXX", sizeof(path));
+ assert(mkstemp(path) > 0);
+
+ SerdNode* const good = serd_new_real_file_uri(path, NULL);
+ assert(good);
+ assert(!strncmp(serd_node_string(good), "file://", 7));
+ serd_node_free(good);
+
+ SerdNode* const bad = serd_new_real_file_uri("not_a_file", NULL);
+ assert(!bad);
+
+ assert(!remove(path));
+}
+
+static void
test_parse_uri(void)
{
const SerdStringView base = SERD_STATIC_STRING("http://example.org/a/b/c/");
@@ -204,7 +227,7 @@ test_uri_resolution(void)
const SerdURIView rel_foo_uri = serd_relative_uri(abs_foo_uri, base_uri);
const SerdURIView resolved_uri = serd_resolve_uri(rel_foo_uri, base_uri);
-SerdNode* const resolved = serd_new_parsed_uri(resolved_uri);
+ SerdNode* const resolved = serd_new_parsed_uri(resolved_uri);
assert(!strcmp(serd_node_string(resolved), "http://example.org/a/b/c/foo"));
serd_node_free(resolved);
@@ -215,6 +238,7 @@ main(void)
{
test_uri_parsing();
test_parse_uri();
+ test_real_file_uri();
test_is_within();
test_relative_uri();
test_uri_resolution();