diff options
Diffstat (limited to 'test/test_env.c')
-rw-r--r-- | test/test_env.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/test/test_env.c b/test/test_env.c index 1748b4cf..e5be688e 100644 --- a/test/test_env.c +++ b/test/test_env.c @@ -22,12 +22,12 @@ #include <string.h> static SerdStatus -count_prefixes(void* handle, const SerdNode* name, const SerdNode* uri) +count_prefixes(void* handle, const SerdEvent* event) { - (void)name; - (void)uri; + if (event->type == SERD_PREFIX) { + ++*(int*)handle; + } - ++*(int*)handle; return SERD_SUCCESS; } @@ -87,10 +87,13 @@ test_env(void) const SerdNode* blank = serd_nodes_blank(nodes, SERD_STRING("b1")); assert(!serd_env_expand_node(env, blank)); - int n_prefixes = 0; + size_t n_prefixes = 0; + SerdSink* const count_prefixes_sink = + serd_sink_new(&n_prefixes, count_prefixes, NULL); + serd_env_set_prefix( env, SERD_STRING("eg.2"), SERD_STRING("http://example.org/")); - serd_env_foreach(env, count_prefixes, &n_prefixes); + serd_env_write_prefixes(env, count_prefixes_sink); assert(n_prefixes == 1); const SerdNode* shorter_uri = serd_nodes_uri(nodes, SERD_STRING("urn:foo")); @@ -107,6 +110,7 @@ test_env(void) assert(!serd_env_set_base_uri(env, SERD_EMPTY_STRING())); assert(!serd_env_base_uri(env)); + serd_sink_free(count_prefixes_sink); serd_nodes_free(nodes); serd_env_free(env); } |