aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/serd_test.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 2201242c..7b1301d3 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -543,40 +543,42 @@ test_env(void)
SerdWorld* world = serd_world_new();
SerdNode* hello = serd_new_string("hello\"");
- SerdNode* u = serd_new_uri("http://example.org/foo");
+ SerdNode* eg = serd_new_uri("http://example.org/");
+ SerdNode* foo_u = serd_new_uri("http://example.org/foo");
+ SerdNode* foo_c = serd_new_curie("eg.2:foo");
SerdNode* b = serd_new_curie("invalid");
- SerdNode* c = serd_new_curie("eg.2:b");
- SerdNode* s = serd_new_string("hello");
+ SerdNode* pre = serd_new_curie("eg.2");
SerdEnv* env = serd_env_new(NULL);
- serd_env_set_prefix_from_strings(env, "eg.2", "http://example.org/");
+ serd_env_set_prefix(env, pre, eg);
assert(!serd_env_get_base_uri(env));
assert(serd_env_set_base_uri(env, NULL));
assert(!serd_env_get_base_uri(env));
assert(serd_env_set_base_uri(env, hello));
assert(!serd_env_get_base_uri(env));
- serd_node_free(hello);
- SerdStringView prefix;
- SerdStringView suffix;
- assert(serd_env_expand(env, b, &prefix, &suffix));
+ SerdNode* xnode = serd_env_expand(env, hello);
+ assert(!xnode);
- assert(!serd_env_expand_node(env, b));
- assert(!serd_env_expand_node(env, s));
+ assert(!serd_env_expand(env, b));
+ assert(!serd_env_expand(env, hello));
- assert(serd_env_set_base_uri(NULL, u));
+ assert(serd_env_set_base_uri(NULL, eg));
assert(serd_env_set_base_uri(env, NULL));
- SerdNode* xu = serd_env_expand_node(env, u);
+ serd_node_free(hello);
+
+ SerdNode* xu = serd_env_expand(env, foo_c);
assert(!strcmp(serd_node_get_string(xu), "http://example.org/foo"));
serd_node_free(xu);
SerdNode* badpre = serd_new_curie("hm:what");
- SerdNode* xbadpre = serd_env_expand_node(env, badpre);
+ SerdNode* xbadpre = serd_env_expand(env, badpre);
assert(!xbadpre);
+ serd_node_free(badpre);
- SerdNode* xc = serd_env_expand_node(env, c);
- assert(!strcmp(serd_node_get_string(xc), "http://example.org/b"));
+ SerdNode* xc = serd_env_expand(env, foo_c);
+ assert(serd_node_equals(xc, foo_u));
serd_node_free(xc);
assert(serd_env_set_prefix(env, NULL, NULL));
@@ -585,20 +587,23 @@ test_env(void)
assert(serd_env_set_prefix(env, b, lit));
int n_prefixes = 0;
- serd_env_set_prefix_from_strings(env, "eg.2", "http://example.org/");
+ serd_env_set_prefix(env, pre, eg);
serd_env_foreach(env, count_prefixes, &n_prefixes);
assert(n_prefixes == 1);
- SerdNode* shorter_uri = serd_new_uri("urn:foo");
- const SerdNode* prefix_name = NULL;
- assert(!serd_env_qualify(env, shorter_uri, &prefix_name, &suffix));
+ SerdNode* shorter_uri = serd_new_uri("urn:foo");
+ assert(!serd_env_qualify(env, shorter_uri));
serd_node_free(shorter_uri);
+
+ SerdNode* qualified = serd_env_qualify(env, foo_u);
+ assert(serd_node_equals(qualified, foo_c));
+ serd_node_free(qualified);
+ serd_node_free(foo_c);
+ serd_node_free(foo_u);
serd_node_free(lit);
- serd_node_free(badpre);
- serd_node_free(s);
- serd_node_free(c);
serd_node_free(b);
- serd_node_free(u);
+ serd_node_free(pre);
+ serd_node_free(eg);
serd_env_free(env);
serd_world_free(world);