diff options
author | David Robillard <d@drobilla.net> | 2021-08-08 20:00:43 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-28 21:57:07 -0500 |
commit | 9547c806dbf76d6afd1e324fc924abdf944c4bda (patch) | |
tree | 012ecf59cac892711d5bcf8f717f0ca579bbf7cd /test/test_model.c | |
parent | dc01b7e301e91d0d7bfc358f569f4f3849471c52 (diff) | |
download | serd-9547c806dbf76d6afd1e324fc924abdf944c4bda.tar.gz serd-9547c806dbf76d6afd1e324fc924abdf944c4bda.tar.bz2 serd-9547c806dbf76d6afd1e324fc924abdf944c4bda.zip |
Add a close function to SerdByteSink
This simplifies everything by replacing special cases with a more general close
function. A type is no longer stored in the structure, so the other
constructors are now essentially syntactic sugar for the universal
serd_byte_sink_new_function().
Diffstat (limited to 'test/test_model.c')
-rw-r--r-- | test/test_model.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/test/test_model.c b/test/test_model.c index 4cedfb2b..d5b5eb8c 100644 --- a/test/test_model.c +++ b/test/test_model.c @@ -1062,16 +1062,18 @@ test_write_flat_range(SerdWorld* world, const unsigned n_quads) serd_cursor_free(all); serd_writer_finish(writer); - const char* str = serd_buffer_sink_finish(&buffer); - const char* expected = "<urn:s>\n" - " <urn:p> _:b1 ,\n" - " _:b2 .\n" - "\n" - "_:b1\n" - " <urn:p> <urn:o> .\n" - "\n" - "_:b2\n" - " <urn:p> <urn:o> .\n"; + serd_byte_sink_close(out); + + const char* const str = (const char*)buffer.buf; + static const char* const expected = "<urn:s>\n" + "\t<urn:p> _:b1 ,\n" + "\t\t_:b2 .\n" + "\n" + "_:b1\n" + "\t<urn:p> <urn:o> .\n" + "\n" + "_:b2\n" + "\t<urn:p> <urn:o> .\n"; assert(!strcmp(str, expected)); @@ -1126,7 +1128,9 @@ test_write_bad_list(SerdWorld* world, const unsigned n_quads) serd_cursor_free(all); serd_writer_finish(writer); - const char* str = serd_buffer_sink_finish(&buffer); + serd_byte_sink_close(out); + + const char* str = (const char*)buffer.buf; const char* expected = "<urn:s>\n" " <urn:p> (\n" " \"a\"\n" @@ -1188,7 +1192,8 @@ test_write_infinite_list(SerdWorld* world, const unsigned n_quads) serd_cursor_free(all); serd_writer_finish(writer); - const char* str = serd_buffer_sink_finish(&buffer); + serd_byte_sink_close(out); + const char* str = (const char*)buffer.buf; const char* expected = "<urn:s>\n" " <urn:p> _:l1 .\n" "\n" @@ -1265,7 +1270,8 @@ test_write_error_in_list_subject(SerdWorld* world, const unsigned n_quads) for (size_t max_successes = 0; max_successes < 18; ++max_successes) { FailingWriteFuncState state = {0, max_successes}; SerdByteSink* out = - serd_byte_sink_new_function(failing_write_func, &state, 1); + serd_byte_sink_new_function(failing_write_func, NULL, &state, 1); + SerdWriter* writer = serd_writer_new(world, SERD_TURTLE, 0, env, out); const SerdSink* const sink = serd_writer_sink(writer); @@ -1320,7 +1326,8 @@ test_write_error_in_list_object(SerdWorld* world, const unsigned n_quads) for (size_t max_successes = 0; max_successes < 21; ++max_successes) { FailingWriteFuncState state = {0, max_successes}; SerdByteSink* out = - serd_byte_sink_new_function(failing_write_func, &state, 1); + serd_byte_sink_new_function(failing_write_func, NULL, &state, 1); + SerdWriter* writer = serd_writer_new(world, SERD_TURTLE, 0, env, out); const SerdSink* const sink = serd_writer_sink(writer); |