diff options
Diffstat (limited to 'test/test_env.c')
-rw-r--r-- | test/test_env.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/test/test_env.c b/test/test_env.c index 8dbc24a1..31446f69 100644 --- a/test/test_env.c +++ b/test/test_env.c @@ -4,7 +4,9 @@ #undef NDEBUG #include "serd/env.h" +#include "serd/event.h" #include "serd/node.h" +#include "serd/sink.h" #include "serd/status.h" #include "serd/string_view.h" @@ -12,12 +14,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; } @@ -73,10 +75,13 @@ test_env(void) assert(!serd_env_expand_node(env, blank)); serd_node_free(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); SerdNode* shorter_uri = serd_new_uri(serd_string("urn:foo")); @@ -93,6 +98,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_node_free(shorter_uri); serd_node_free(badpre); serd_node_free(s); |