diff options
author | David Robillard <d@drobilla.net> | 2023-12-02 17:11:23 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | b13ad41a4d65b577b4db67660a9edf3056bdf7af (patch) | |
tree | e89535f6098a1b860f38ec8a7a1b698b30a72545 /test/test_uri.c | |
parent | 0db18e483f11ac2f9518d96e137d217040ed1339 (diff) | |
download | serd-b13ad41a4d65b577b4db67660a9edf3056bdf7af.tar.gz serd-b13ad41a4d65b577b4db67660a9edf3056bdf7af.tar.bz2 serd-b13ad41a4d65b577b4db67660a9edf3056bdf7af.zip |
Use SerdNodes instead of manual memory management in tests
Diffstat (limited to 'test/test_uri.c')
-rw-r--r-- | test/test_uri.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/test/test_uri.c b/test/test_uri.c index 294b00ec..b1af8a02 100644 --- a/test/test_uri.c +++ b/test/test_uri.c @@ -169,13 +169,15 @@ test_parse_uri(void) const SerdURIView base_uri = serd_parse_uri(base.data); const SerdURIView empty_uri = serd_parse_uri(""); - SerdNode* const nil = serd_node_new( - NULL, serd_a_parsed_uri(serd_resolve_uri(empty_uri, base_uri))); + SerdNodes* const nodes = serd_nodes_new(NULL); + + const SerdNode* const nil = serd_nodes_get( + nodes, 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)); - serd_node_free(NULL, nil); + serd_nodes_free(nodes); } static void @@ -230,27 +232,27 @@ check_relative_uri(const char* const uri_string, assert(base_string); assert(expected_string); - 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)); - + SerdNodes* const nodes = serd_nodes_new(NULL); + const SerdNode* uri_node = + serd_nodes_get(nodes, serd_a_uri_string(uri_string)); + const SerdURIView uri = serd_node_uri_view(uri_node); + const SerdNode* base_node = + serd_nodes_get(nodes, serd_a_uri_string(base_string)); const SerdURIView base = serd_node_uri_view(base_node); - SerdNode* result_node = NULL; + const SerdNode* result_node = NULL; if (!root_string) { result_node = - serd_node_new(NULL, serd_a_parsed_uri(serd_relative_uri(uri, base))); + serd_nodes_get(nodes, serd_a_parsed_uri(serd_relative_uri(uri, base))); } else { - SerdNode* const root_node = - serd_node_new(NULL, serd_a_uri_string(root_string)); + const SerdNode* root_node = + serd_nodes_get(nodes, 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)); - serd_node_free(NULL, root_node); + ? serd_nodes_get(nodes, serd_a_parsed_uri(serd_relative_uri(uri, base))) + : serd_nodes_get(nodes, serd_a_uri_string(uri_string)); } assert(!strcmp(serd_node_string(result_node), expected_string)); @@ -263,10 +265,7 @@ check_relative_uri(const char* const uri_string, assert(chunk_equals(&result.path, &expected.path)); assert(chunk_equals(&result.query, &expected.query)); assert(chunk_equals(&result.fragment, &expected.fragment)); - - serd_node_free(NULL, result_node); - serd_node_free(NULL, base_node); - serd_node_free(NULL, uri_node); + serd_nodes_free(nodes); } static void |