aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-12-30 12:34:24 -0500
committerDavid Robillard <d@drobilla.net>2018-12-31 11:37:49 -0500
commitbb495bd3c02629f1e0396fd89d2ff503b889d3dd (patch)
treeee95436679496dde004e362d36dac5a9b82ba6a2
parent88d62648449a3f7d8e31a70d3d81dec6c895dd31 (diff)
downloadserd-bb495bd3c02629f1e0396fd89d2ff503b889d3dd.tar.gz
serd-bb495bd3c02629f1e0396fd89d2ff503b889d3dd.tar.bz2
serd-bb495bd3c02629f1e0396fd89d2ff503b889d3dd.zip
Simplify reader test sink
-rw-r--r--tests/serd_test.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 88528775..02df79d3 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);