diff options
Diffstat (limited to 'test/test_env.c')
-rw-r--r-- | test/test_env.c | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/test/test_env.c b/test/test_env.c index cc3a524f..5a4c95df 100644 --- a/test/test_env.c +++ b/test/test_env.c @@ -8,6 +8,7 @@ #include "serd/env.h" #include "serd/event.h" #include "serd/node.h" +#include "serd/nodes.h" #include "serd/sink.h" #include "serd/status.h" #include "serd/string_view.h" @@ -201,8 +202,9 @@ count_prefixes(void* handle, const SerdEvent* event) static void test_base_uri(void) { - SerdEnv* const env = serd_env_new(NULL, serd_empty_string()); - SerdNode* const eg = serd_node_new(NULL, serd_a_uri_string(NS_EG)); + SerdNodes* const nodes = serd_nodes_new(NULL); + SerdEnv* const env = serd_env_new(NULL, serd_empty_string()); + const SerdNode* const eg = serd_nodes_get(nodes, serd_a_uri_string(NS_EG)); // Test that invalid calls work as expected assert(!serd_env_base_uri(env)); @@ -221,8 +223,8 @@ test_base_uri(void) assert(!serd_env_set_base_uri(env, serd_empty_string())); assert(!serd_env_base_uri(env)); - serd_node_free(NULL, eg); serd_env_free(env); + serd_nodes_free(nodes); } static void @@ -262,13 +264,14 @@ test_set_prefix(void) static void test_expand_untyped_literal(void) { - SerdNode* const untyped = serd_node_new(NULL, serd_a_string("data")); - SerdEnv* const env = serd_env_new(NULL, serd_empty_string()); + SerdNodes* const nodes = serd_nodes_new(NULL); + const SerdNode* const untyped = serd_nodes_get(nodes, serd_a_string("data")); + SerdEnv* const env = serd_env_new(NULL, serd_empty_string()); assert(!serd_env_expand_node(env, untyped)); serd_env_free(env); - serd_node_free(NULL, untyped); + serd_nodes_free(nodes); } static void @@ -276,15 +279,17 @@ test_expand_bad_uri_datatype(void) { const SerdStringView type = serd_string("Type"); - SerdNode* const typed = - serd_node_new(NULL, serd_a_typed_literal(serd_string("data"), type)); + SerdNodes* const nodes = serd_nodes_new(NULL); + + const SerdNode* const typed = + serd_nodes_get(nodes, serd_a_typed_literal(serd_string("data"), type)); SerdEnv* const env = serd_env_new(NULL, serd_empty_string()); assert(!serd_env_expand_node(env, typed)); serd_env_free(env); - serd_node_free(NULL, typed); + serd_nodes_free(nodes); } static void @@ -292,20 +297,21 @@ test_expand_uri(void) { const SerdStringView base = serd_string("http://example.org/b/"); - SerdEnv* const env = serd_env_new(NULL, base); - SerdNode* const rel = serd_node_new(NULL, serd_a_uri_string("rel")); + SerdNodes* const nodes = serd_nodes_new(NULL); + SerdEnv* const env = serd_env_new(NULL, base); + const SerdNode* const rel = serd_nodes_get(nodes, serd_a_uri_string("rel")); + const SerdNode* const empty = serd_nodes_get(nodes, serd_a_uri_string("")); + SerdNode* const rel_out = serd_env_expand_node(env, rel); - SerdNode* const empty = serd_node_new(NULL, serd_a_uri_string("")); SerdNode* const empty_out = serd_env_expand_node(env, empty); assert(!strcmp(serd_node_string(rel_out), "http://example.org/b/rel")); assert(!strcmp(serd_node_string(empty_out), "http://example.org/b/")); serd_node_free(NULL, empty_out); - serd_node_free(NULL, empty); serd_node_free(NULL, rel_out); - serd_node_free(NULL, rel); serd_env_free(env); + serd_nodes_free(nodes); } static void @@ -313,27 +319,31 @@ test_expand_empty_uri_ref(void) { const SerdStringView base = serd_string("http://example.org/b/"); - SerdNode* const rel = serd_node_new(NULL, serd_a_uri_string("rel")); - SerdEnv* const env = serd_env_new(NULL, base); - SerdNode* const rel_out = serd_env_expand_node(env, rel); + SerdNodes* const nodes = serd_nodes_new(NULL); + SerdEnv* const env = serd_env_new(NULL, base); + const SerdNode* const rel = serd_nodes_get(nodes, serd_a_uri_string("rel")); + SerdNode* const rel_out = serd_env_expand_node(env, rel); assert(!strcmp(serd_node_string(rel_out), "http://example.org/b/rel")); serd_node_free(NULL, rel_out); serd_env_free(env); - serd_node_free(NULL, rel); + serd_nodes_free(nodes); } static void test_expand_bad_uri(void) { - SerdNode* const bad_uri = serd_node_new(NULL, serd_a_uri_string("rel")); - SerdEnv* const env = serd_env_new(NULL, serd_empty_string()); + SerdNodes* const nodes = serd_nodes_new(NULL); + SerdEnv* const env = serd_env_new(NULL, serd_empty_string()); + + const SerdNode* const bad_uri = + serd_nodes_get(nodes, serd_a_uri_string("rel")); assert(!serd_env_expand_node(env, bad_uri)); serd_env_free(env); - serd_node_free(NULL, bad_uri); + serd_nodes_free(nodes); } static void @@ -372,13 +382,16 @@ test_expand_bad_curie(void) static void test_expand_blank(void) { - SerdNode* const blank = serd_node_new(NULL, serd_a_blank_string("b1")); - SerdEnv* const env = serd_env_new(NULL, serd_empty_string()); + SerdNodes* const nodes = serd_nodes_new(NULL); + const SerdNode* const blank = + serd_nodes_get(nodes, serd_a_blank(serd_string("b1"))); + + SerdEnv* const env = serd_env_new(NULL, serd_empty_string()); assert(!serd_env_expand_node(env, blank)); serd_env_free(env); - serd_node_free(NULL, blank); + serd_nodes_free(nodes); } static void |