diff options
author | David Robillard <d@drobilla.net> | 2018-06-03 19:47:07 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-12-31 11:37:47 -0500 |
commit | 6413746068d35e8e88111f930cbaadc56e2cf0cf (patch) | |
tree | ac2fdc094ed1e0409a5b2fdcdda3ec4034a3ab14 /tests/serd_test.c | |
parent | 39fabf4d292f674f4d669b98e446e66d8ef11aa0 (diff) | |
download | serd-6413746068d35e8e88111f930cbaadc56e2cf0cf.tar.gz serd-6413746068d35e8e88111f930cbaadc56e2cf0cf.tar.bz2 serd-6413746068d35e8e88111f930cbaadc56e2cf0cf.zip |
Make statement sink take a statement rather than nodes
This makes the interface more extensible, towards associating more information
with statements. The serd_sink_write_nodes wrapper remains so that user code
does not need to allocate in order to write statement.
Diffstat (limited to 'tests/serd_test.c')
-rw-r--r-- | tests/serd_test.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c index 9351c06c..989eda4f 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -68,21 +68,16 @@ typedef struct { } ReaderTest; static SerdStatus -test_sink(void* handle, - SerdStatementFlags flags, - const SerdNode* graph, - const SerdNode* subject, - const SerdNode* predicate, - const SerdNode* object) +test_sink(void* handle, + SerdStatementFlags flags, + const SerdStatement* statement) { (void)flags; - (void)subject; - (void)predicate; - (void)object; + (void)statement; ReaderTest* rt = (ReaderTest*)handle; ++rt->n_statements; - rt->graph = graph; + rt->graph = serd_statement_get_graph(statement); return SERD_SUCCESS; } @@ -478,7 +473,7 @@ main(void) serd_writer_chop_blank_prefix(writer, "tmp"); serd_writer_chop_blank_prefix(writer, NULL); - const SerdSink* iface = serd_writer_get_sink(writer); + SerdSink* iface = serd_writer_get_sink(writer); assert(iface->base(iface->handle, lit)); assert(iface->prefix(iface->handle, lit, lit)); assert(iface->end(iface->handle, NULL)); @@ -501,9 +496,8 @@ main(void) { s, p, NULL }, { NULL, NULL, NULL } }; for (unsigned i = 0; i < sizeof(junk) / (sizeof(SerdNode*) * 5); ++i) { - assert(iface->statement( - iface->handle, 0, NULL, - junk[i][0], junk[i][1], junk[i][2])); + assert(serd_sink_write( + iface, 0, junk[i][0], junk[i][1], junk[i][2], 0)); } SerdNode* urn_Type = serd_node_new_uri("urn:Type"); @@ -521,24 +515,23 @@ main(void) { s, p, o }, { s, p, o } }; for (unsigned i = 0; i < sizeof(good) / (sizeof(SerdNode*) * 5); ++i) { - assert(!iface->statement( - iface->handle, 0, NULL, good[i][0], good[i][1], good[i][2])); + assert(!serd_sink_write( + iface, 0, good[i][0], good[i][1], good[i][2], 0)); } // Write statements with bad UTF-8 (should be replaced) const char bad_str[] = { (char)0xFF, (char)0x90, 'h', 'i', 0 }; SerdNode* bad_lit = serd_node_new_string(bad_str); SerdNode* bad_uri = serd_node_new_uri(bad_str); - assert(!iface->statement(iface->handle, 0, NULL, s, p, bad_lit)); - assert(!iface->statement(iface->handle, 0, NULL, s, p, bad_uri)); - + assert(!serd_sink_write(iface, 0, s, p, bad_lit, 0)); + assert(!serd_sink_write(iface, 0, s, p, bad_uri, 0)); serd_node_free(bad_uri); serd_node_free(bad_lit); // Write 1 valid statement serd_node_free(o); o = serd_node_new_string("hello"); - assert(!iface->statement(iface->handle, 0, NULL, s, p, o)); + assert(!serd_sink_write(iface, 0, s, p, o, 0)); serd_writer_free(writer); serd_node_free(lit); |