aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_uri.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_uri.c')
-rw-r--r--test/test_uri.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/test/test_uri.c b/test/test_uri.c
index d3ba5514..0942439f 100644
--- a/test/test_uri.c
+++ b/test/test_uri.c
@@ -44,17 +44,18 @@ test_file_uri(const char* const hostname,
expected_path = path;
}
- SerdNode node = serd_new_file_uri(path, hostname, 0);
- char* out_hostname = NULL;
- char* out_path = serd_file_uri_parse(node.buf, &out_hostname);
- assert(!strcmp(node.buf, expected_uri));
+ SerdNode* node = serd_new_file_uri(path, hostname, 0);
+ const char* node_str = serd_node_string(node);
+ char* out_hostname = NULL;
+ char* out_path = serd_file_uri_parse(node_str, &out_hostname);
+ assert(!strcmp(node_str, expected_uri));
assert((hostname && out_hostname) || (!hostname && !out_hostname));
assert(!hostname || !strcmp(hostname, out_hostname));
assert(!strcmp(out_path, expected_path));
serd_free(out_path);
serd_free(out_hostname);
- serd_node_free(&node);
+ serd_node_free(node);
}
static void
@@ -114,22 +115,20 @@ test_uri_parsing(void)
static void
test_uri_from_string(void)
{
- SerdNode nonsense = serd_new_uri_from_string(NULL, NULL, NULL);
- assert(nonsense.type == SERD_NOTHING);
+ assert(!serd_new_uri_from_string(NULL, NULL, NULL));
SerdURIView base_uri;
- SerdNode base =
+ SerdNode* base =
serd_new_uri_from_string("http://example.org/", NULL, &base_uri);
- SerdNode nil = serd_new_uri_from_string(NULL, &base_uri, NULL);
- SerdNode nil2 = serd_new_uri_from_string("", &base_uri, NULL);
- assert(nil.type == SERD_URI);
- assert(!strcmp(nil.buf, base.buf));
- assert(nil2.type == SERD_URI);
- assert(!strcmp(nil2.buf, base.buf));
- serd_node_free(&nil);
- serd_node_free(&nil2);
-
- serd_node_free(&base);
+ SerdNode* nil = serd_new_uri_from_string(NULL, &base_uri, NULL);
+ SerdNode* nil2 = serd_new_uri_from_string("", &base_uri, NULL);
+ assert(serd_node_type(nil) == SERD_URI);
+ assert(!strcmp(serd_node_string(nil), serd_node_string(base)));
+ assert(serd_node_type(nil2) == SERD_URI);
+ assert(!strcmp(serd_node_string(nil2), serd_node_string(base)));
+ serd_node_free(nil);
+ serd_node_free(nil2);
+ serd_node_free(base);
}
static inline bool
@@ -154,21 +153,21 @@ check_relative_uri(const char* const uri_string,
SerdURIView base = SERD_URI_NULL;
SerdURIView result = SERD_URI_NULL;
- SerdNode uri_node = serd_new_uri_from_string(uri_string, NULL, &uri);
- SerdNode base_node = serd_new_uri_from_string(base_string, NULL, &base);
+ SerdNode* uri_node = serd_new_uri_from_string(uri_string, NULL, &uri);
+ SerdNode* base_node = serd_new_uri_from_string(base_string, NULL, &base);
- SerdNode result_node = SERD_NODE_NULL;
+ SerdNode* result_node = NULL;
if (root_string) {
SerdURIView root = SERD_URI_NULL;
- SerdNode root_node = serd_new_uri_from_string(root_string, NULL, &root);
+ SerdNode* root_node = serd_new_uri_from_string(root_string, NULL, &root);
result_node = serd_new_relative_uri(&uri, &base, &root, &result);
- serd_node_free(&root_node);
+ serd_node_free(root_node);
} else {
result_node = serd_new_relative_uri(&uri, &base, NULL, &result);
}
- assert(!strcmp((const char*)result_node.buf, expected_string));
+ assert(!strcmp(serd_node_string(result_node), expected_string));
SerdURIView expected = SERD_URI_NULL;
assert(!serd_uri_parse(expected_string, &expected));
@@ -179,9 +178,9 @@ check_relative_uri(const char* const uri_string,
assert(chunk_equals(&result.query, &expected.query));
assert(chunk_equals(&result.fragment, &expected.fragment));
- serd_node_free(&result_node);
- serd_node_free(&base_node);
- serd_node_free(&uri_node);
+ serd_node_free(result_node);
+ serd_node_free(base_node);
+ serd_node_free(uri_node);
}
static void