From 957fbbae9d51e3850f00ed109052ce7bab7087e0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 3 Jun 2018 19:47:07 +0200 Subject: 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. --- tests/serd_test.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/serd_test.c b/tests/serd_test.c index 049b4767..3475d08e 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -69,16 +69,13 @@ 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) { ReaderTest* rt = (ReaderTest*)handle; ++rt->n_statements; - rt->graph = graph; + rt->graph = serd_statement_get_graph(statement); return SERD_SUCCESS; } @@ -602,9 +599,8 @@ main(void) { s, p, NULL }, { NULL, NULL, NULL } }; for (unsigned i = 0; i < sizeof(junk) / (sizeof(SerdNode*) * 5); ++i) { - if (!iface->statement( - iface->handle, 0, NULL, - junk[i][0], junk[i][1], junk[i][2])) { + if (!serd_sink_write_nodes( + iface, 0, junk[i][0], junk[i][1], junk[i][2], 0)) { FAILF("Successfully wrote junk statement %d\n", i); } } @@ -624,8 +620,8 @@ main(void) { s, p, o }, { s, p, o } }; for (unsigned i = 0; i < sizeof(good) / (sizeof(SerdNode*) * 5); ++i) { - if (iface->statement( - iface->handle, 0, NULL, good[i][0], good[i][1], good[i][2])) { + if (serd_sink_write_nodes( + iface, 0, good[i][0], good[i][1], good[i][2], 0)) { FAILF("Failed to write good statement %d\n", i); } } @@ -634,9 +630,9 @@ main(void) 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); - if (iface->statement(iface->handle, 0, NULL, s, p, bad_lit)) { + if (serd_sink_write_nodes(iface, 0, s, p, bad_lit, 0)) { FAIL("Failed to write junk UTF-8 literal\n"); - } else if (iface->statement(iface->handle, 0, NULL, s, p, bad_uri)) { + } else if (serd_sink_write_nodes(iface, 0, s, p, bad_uri, 0)) { FAIL("Failed to write junk UTF-8 URI\n"); } serd_node_free(bad_uri); @@ -645,7 +641,7 @@ main(void) // Write 1 valid statement serd_node_free(o); o = serd_node_new_string("hello"); - if (iface->statement(iface->handle, 0, NULL, s, p, o)) { + if (serd_sink_write_nodes(iface, 0, s, p, o, 0)) { FAIL("Failed to write valid statement\n"); } -- cgit v1.2.1