diff options
author | David Robillard <d@drobilla.net> | 2020-06-28 19:46:47 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:23:06 -0500 |
commit | f7b993d5aff1274e010d45304b12109f6de7e120 (patch) | |
tree | 6fadbff8f2e696ce62ba1237bee16c07776cd03e /test/test_reader_writer.c | |
parent | 2fb247d2beb71539ceba8f2841d7c1bad933ab36 (diff) | |
download | serd-f7b993d5aff1274e010d45304b12109f6de7e120.tar.gz serd-f7b993d5aff1274e010d45304b12109f6de7e120.tar.bz2 serd-f7b993d5aff1274e010d45304b12109f6de7e120.zip |
WIP: Make Writer always write to a ByteSink
Diffstat (limited to 'test/test_reader_writer.c')
-rw-r--r-- | test/test_reader_writer.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index a3e99fa4..a4f57a0f 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -152,8 +152,11 @@ test_strict_write(void) const char* path = "serd_strict_write_test.ttl"; FILE* fd = fopen(path, "wb"); SerdEnv* env = serd_env_new(SERD_EMPTY_STRING()); - SerdWriter* writer = - serd_writer_new(world, SERD_TURTLE, 0, env, (SerdWriteFunc)fwrite, fd); + + SerdByteSink* byte_sink = + serd_byte_sink_new_function((SerdWriteFunc)fwrite, fd, 1); + + SerdWriter* writer = serd_writer_new(world, SERD_TURTLE, 0, env, byte_sink); assert(fd); assert(writer); @@ -175,6 +178,7 @@ test_strict_write(void) serd_node_free(p); serd_writer_free(writer); + serd_byte_sink_free(byte_sink); serd_env_free(env); fclose(fd); serd_world_free(world); @@ -218,8 +222,12 @@ test_writer(const char* const path) SerdWorld* world = serd_world_new(); - SerdWriter* writer = serd_writer_new( - world, SERD_TURTLE, SERD_WRITE_LAX, env, (SerdWriteFunc)fwrite, fd); + SerdByteSink* byte_sink = + serd_byte_sink_new_function((SerdWriteFunc)fwrite, fd, 1); + + SerdWriter* writer = + serd_writer_new(world, SERD_TURTLE, SERD_WRITE_LAX, env, byte_sink); + assert(writer); serd_writer_chop_blank_prefix(writer, "tmp"); @@ -280,6 +288,7 @@ test_writer(const char* const path) serd_node_free(hello); serd_writer_free(writer); + serd_byte_sink_free(byte_sink); serd_node_free(lit); serd_node_free(o); @@ -287,12 +296,10 @@ test_writer(const char* const path) serd_node_free(l); // Test buffer sink - SerdBuffer buffer = {NULL, 0}; - SerdByteSink* byte_sink = - serd_byte_sink_new((SerdWriteFunc)serd_buffer_sink, &buffer, 1); + SerdBuffer buffer = {NULL, 0}; - writer = serd_writer_new( - world, SERD_TURTLE, 0, env, (SerdWriteFunc)serd_byte_sink_write, byte_sink); + byte_sink = serd_byte_sink_new_buffer(&buffer); + writer = serd_writer_new(world, SERD_TURTLE, 0, env, byte_sink); SerdNode* const base = serd_new_uri(SERD_STATIC_STRING("http://example.org/base")); |