diff options
author | David Robillard <d@drobilla.net> | 2023-05-05 09:43:57 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | 4711fdf527f416faee8ff19e15f050d4b48dcfb2 (patch) | |
tree | 6b18712ec44cce5713ddef1a21aec5f12651d901 /test/test_uri.c | |
parent | 248a874d7425749d29cf900a1c3783c624ea8d8c (diff) | |
download | serd-4711fdf527f416faee8ff19e15f050d4b48dcfb2.tar.gz serd-4711fdf527f416faee8ff19e15f050d4b48dcfb2.tar.bz2 serd-4711fdf527f416faee8ff19e15f050d4b48dcfb2.zip |
[WIP] Generalize node construction API
Diffstat (limited to 'test/test_uri.c')
-rw-r--r-- | test/test_uri.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/test/test_uri.c b/test/test_uri.c index 79d3f73e..7a15ffb8 100644 --- a/test/test_uri.c +++ b/test/test_uri.c @@ -75,8 +75,8 @@ test_file_uri(const char* const hostname, expected_path = path; } - SerdNode* node = - serd_new_file_uri(NULL, serd_string(path), serd_string(hostname)); + SerdNode* node = serd_node_new( + NULL, serd_a_file_uri(serd_string(path), serd_string(hostname))); const char* node_str = serd_node_string(node); char* out_hostname = NULL; @@ -166,8 +166,8 @@ test_parse_uri(void) const SerdURIView base_uri = serd_parse_uri(base.data); const SerdURIView empty_uri = serd_parse_uri(""); - SerdNode* const nil = - serd_new_parsed_uri(NULL, serd_resolve_uri(empty_uri, base_uri)); + SerdNode* const nil = serd_node_new( + NULL, serd_a_parsed_uri(serd_resolve_uri(empty_uri, base_uri))); assert(serd_node_type(nil) == SERD_URI); assert(!strcmp(serd_node_string(nil), base.data)); @@ -227,21 +227,26 @@ check_relative_uri(const char* const uri_string, assert(base_string); assert(expected_string); - SerdNode* const uri_node = serd_new_uri(NULL, serd_string(uri_string)); - const SerdURIView uri = serd_node_uri_view(uri_node); - SerdNode* const base_node = serd_new_uri(NULL, serd_string(base_string)); - const SerdURIView base = serd_node_uri_view(base_node); + SerdNode* const uri_node = serd_node_new(NULL, serd_a_uri_string(uri_string)); + const SerdURIView uri = serd_node_uri_view(uri_node); + SerdNode* const base_node = + serd_node_new(NULL, serd_a_uri_string(base_string)); + const SerdURIView base = serd_node_uri_view(base_node); SerdNode* result_node = NULL; if (!root_string) { - result_node = serd_new_parsed_uri(NULL, serd_relative_uri(uri, base)); + result_node = + serd_node_new(NULL, serd_a_parsed_uri(serd_relative_uri(uri, base))); } else { - SerdNode* const root_node = serd_new_uri(NULL, serd_string(root_string)); - const SerdURIView root = serd_node_uri_view(root_node); + SerdNode* const root_node = + serd_node_new(NULL, serd_a_uri_string(root_string)); + const SerdURIView root = serd_node_uri_view(root_node); + + result_node = + serd_uri_is_within(uri, root) + ? serd_node_new(NULL, serd_a_parsed_uri(serd_relative_uri(uri, base))) + : serd_node_new(NULL, serd_a_uri_string(uri_string)); - result_node = serd_uri_is_within(uri, root) - ? serd_new_parsed_uri(NULL, serd_relative_uri(uri, base)) - : serd_new_uri(NULL, serd_string(uri_string)); serd_node_free(NULL, root_node); } @@ -359,7 +364,7 @@ test_relative_uri(void) static void check_uri_string(const SerdURIView uri, const char* const expected) { - SerdNode* const node = serd_new_parsed_uri(NULL, uri); + SerdNode* const node = serd_node_new(NULL, serd_a_parsed_uri(uri)); assert(!strcmp(serd_node_string(node), expected)); serd_node_free(NULL, node); } |