diff options
author | David Robillard <d@drobilla.net> | 2018-05-10 19:29:22 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-11-25 15:58:15 +0100 |
commit | f2a19949d0da60465e2d68b5e66a52e0d970ebd1 (patch) | |
tree | 0e72fcb7205e52f82e3821b2da9e5335716a5115 /tests | |
parent | 6cf2ecfab4b3cb150b154bdc1130aca022a8f89c (diff) | |
download | serd-f2a19949d0da60465e2d68b5e66a52e0d970ebd1.tar.gz serd-f2a19949d0da60465e2d68b5e66a52e0d970ebd1.tar.bz2 serd-f2a19949d0da60465e2d68b5e66a52e0d970ebd1.zip |
Add SerdSink interface and hide individual function implementations
Diffstat (limited to 'tests')
-rw-r--r-- | tests/serd_test.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c index 62435dd3..d0025ec9 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -538,12 +538,13 @@ main(void) serd_writer_chop_blank_prefix(writer, "tmp"); serd_writer_chop_blank_prefix(writer, NULL); - if (!serd_writer_set_base_uri(writer, lit)) { + const SerdSink* iface = serd_writer_get_sink(writer); + if (!iface->base(iface->handle, lit)) { FAILF("Set base URI to %s\n", serd_node_get_string(lit)); - } else if (!serd_writer_set_prefix(writer, lit, lit)) { + } else if (!iface->prefix(iface->handle, lit, lit)) { FAILF("Set prefix %s to %s\n", serd_node_get_string(lit), serd_node_get_string(lit)); - } else if (!serd_writer_end_anon(writer, NULL)) { + } else if (!iface->end(iface->handle, NULL)) { FAIL("Ended non-existent anonymous node\n"); } else if (serd_writer_get_env(writer) != env) { FAIL("Writer has incorrect env\n"); @@ -566,8 +567,8 @@ main(void) { s, p, NULL }, { NULL, NULL, NULL } }; for (unsigned i = 0; i < sizeof(junk) / (sizeof(SerdNode*) * 5); ++i) { - if (!serd_writer_write_statement( - writer, 0, NULL, + if (!iface->statement( + iface->handle, 0, NULL, junk[i][0], junk[i][1], junk[i][2])) { FAILF("Successfully wrote junk statement %d\n", i); } @@ -586,8 +587,8 @@ main(void) { s, p, o }, { s, p, o } }; for (unsigned i = 0; i < sizeof(good) / (sizeof(SerdNode*) * 5); ++i) { - if (serd_writer_write_statement( - writer, 0, NULL, good[i][0], good[i][1], good[i][2])) { + if (iface->statement( + iface->handle, 0, NULL, good[i][0], good[i][1], good[i][2])) { FAILF("Failed to write good statement %d\n", i); } } @@ -596,11 +597,9 @@ main(void) const char bad_str[] = { (char)0xFF, (char)0x90, 'h', 'i', 0 }; SerdNode* bad_lit = serd_node_new_string(SERD_LITERAL, bad_str); SerdNode* bad_uri = serd_node_new_string(SERD_URI, bad_str); - if (serd_writer_write_statement(writer, 0, NULL, - s, p, bad_lit)) { + if (iface->statement(iface->handle, 0, NULL, s, p, bad_lit)) { FAIL("Failed to write junk UTF-8 literal\n"); - } else if (serd_writer_write_statement(writer, 0, NULL, - s, p, bad_uri)) { + } else if (iface->statement(iface->handle, 0, NULL, s, p, bad_uri)) { FAIL("Failed to write junk UTF-8 URI\n"); } serd_node_free(bad_uri); @@ -609,8 +608,7 @@ main(void) // Write 1 valid statement serd_node_free(o); o = serd_node_new_string(SERD_LITERAL, "hello"); - if (serd_writer_write_statement(writer, 0, NULL, - s, p, o)) { + if (iface->statement(iface->handle, 0, NULL, s, p, o)) { FAIL("Failed to write valid statement\n"); } @@ -646,15 +644,11 @@ main(void) fseek(fd, 0, SEEK_SET); ReaderTest* rt = (ReaderTest*)calloc(1, sizeof(ReaderTest)); - SerdReader* reader = serd_reader_new( - SERD_TURTLE, rt, free, - NULL, NULL, test_sink, NULL); + SerdSink sink = { rt, NULL, NULL, test_sink, NULL }; + SerdReader* reader = serd_reader_new(SERD_TURTLE, &sink); if (!reader) { FAIL("Failed to create reader\n"); } - if (serd_reader_get_handle(reader) != rt) { - FAIL("Corrupt reader handle\n"); - } SerdNode* g = serd_node_new_string(SERD_URI, "http://example.org/"); serd_reader_set_default_graph(reader, g); |