From b58e829adcaca5a74f666a3f1b4c76644a7d49b7 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 30 Dec 2018 12:34:24 -0500 Subject: Simplify reader test sink --- tests/serd_test.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/tests/serd_test.c b/tests/serd_test.c index a2bb9013..bab255e6 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -62,20 +62,15 @@ count_prefixes(void* handle, const SerdNode* name, const SerdNode* uri) return SERD_SUCCESS; } -typedef struct { - int n_statements; -} ReaderTest; - static SerdStatus -test_sink(void* handle, - SerdStatementFlags flags, - const SerdStatement* statement) +count_statements(void* handle, + SerdStatementFlags flags, + const SerdStatement* statement) { (void)flags; (void)statement; - ReaderTest* rt = (ReaderTest*)handle; - ++rt->n_statements; + ++*(size_t*)handle; return SERD_SUCCESS; } @@ -602,9 +597,9 @@ main(void) // Rewind and test reader fseek(fd, 0, SEEK_SET); - ReaderTest rt = { 0 }; - SerdSink* sink = serd_sink_new(&rt); - serd_sink_set_statement_func(sink, test_sink); + size_t n_statements = 0; + SerdSink* sink = serd_sink_new(&n_statements); + serd_sink_set_statement_func(sink, count_statements); SerdReader* reader = serd_reader_new(world, SERD_TURTLE, sink, 4096); assert(reader); @@ -618,7 +613,7 @@ main(void) assert(!serd_reader_start_file(reader, path, true)); assert(!serd_reader_read_document(reader)); - assert(rt.n_statements == 13); + assert(n_statements == 13); serd_reader_finish(reader); serd_reader_free(reader); -- cgit v1.2.1