aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-06-13 21:32:11 -0400
committerDavid Robillard <d@drobilla.net>2018-12-31 11:37:48 -0500
commitfeb16bc18d586080e979845374f053075e6bb7ed (patch)
treeb4e87632c7689798635ae37a9bd097987a7019dd /tests
parentb6197eb59799c2933bd776ea22760fea5e97b4bd (diff)
downloadserd-feb16bc18d586080e979845374f053075e6bb7ed.tar.gz
serd-feb16bc18d586080e979845374f053075e6bb7ed.tar.bz2
serd-feb16bc18d586080e979845374f053075e6bb7ed.zip
Simplify SerdEnv API
Diffstat (limited to 'tests')
-rw-r--r--tests/serd_test.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index b37b7401..68c2579b 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -409,34 +409,36 @@ main(void)
return 1;
}
- SerdNode* u = serd_new_uri("http://example.org/foo");
- SerdNode* b = serd_new_curie("invalid");
- SerdNode* c = serd_new_curie("eg.2:b");
- SerdEnv* env = serd_env_new(NULL);
- serd_env_set_prefix_from_strings(env, "eg.2", "http://example.org/");
+ 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* pre = serd_new_curie("eg.2");
+ SerdEnv* env = serd_env_new(NULL);
+ 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);
- SerdSlice prefix, 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));
+ serd_node_free(hello);
- SerdNode* xu = serd_env_expand_node(env, u);
+ 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));
@@ -445,18 +447,22 @@ main(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;
- assert(!serd_env_qualify(env, shorter_uri, &prefix_name, &suffix));
+ assert(!serd_env_qualify(env, shorter_uri));
serd_node_free(shorter_uri);
- serd_node_free(badpre);
- serd_node_free(c);
+
+ 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(b);
- serd_node_free(u);
+ serd_node_free(pre);
+ serd_node_free(eg);
// Test SerdReader and SerdWriter