diff options
author | David Robillard <d@drobilla.net> | 2021-02-20 19:18:28 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:07 -0500 |
commit | d62c7dc45af3256c6cd70d12a11e91b5b872c7db (patch) | |
tree | 63f9f1cc8f8900ad59b5bd8f07b70e6008522d21 /test/test_writer.c | |
parent | ab1aa43256fac3e017212abe6f9d845bf74c024c (diff) | |
download | serd-d62c7dc45af3256c6cd70d12a11e91b5b872c7db.tar.gz serd-d62c7dc45af3256c6cd70d12a11e91b5b872c7db.tar.bz2 serd-d62c7dc45af3256c6cd70d12a11e91b5b872c7db.zip |
Replace multiple stream callbacks with SerdEvent
This makes plumbing easier since everything goes through the same "stream" and
only one callback is required to handling everything. It's also more easily
extensible in case more event types need to be added in the future.
Diffstat (limited to 'test/test_writer.c')
-rw-r--r-- | test/test_writer.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/test/test_writer.c b/test/test_writer.c index db68454f..d2f59af0 100644 --- a/test/test_writer.c +++ b/test/test_writer.c @@ -5,6 +5,7 @@ #include "serd/buffer.h" #include "serd/env.h" +#include "serd/event.h" #include "serd/memory.h" #include "serd/node.h" #include "serd/sink.h" @@ -21,6 +22,31 @@ #include <string.h> static void +test_write_bad_event(void) +{ + SerdWorld* world = serd_world_new(); + SerdEnv* env = serd_env_new(serd_empty_string()); + SerdBuffer buffer = {NULL, 0}; + SerdWriter* writer = + serd_writer_new(world, SERD_TURTLE, 0U, env, serd_buffer_sink, &buffer); + + assert(writer); + + const SerdEvent event = {(SerdEventType)42}; + assert(serd_sink_write_event(serd_writer_sink(writer), &event) == + SERD_BAD_ARG); + + char* const out = serd_buffer_sink_finish(&buffer); + + assert(!strcmp(out, "")); + serd_free(out); + + serd_writer_free(writer); + serd_env_free(env); + serd_world_free(world); +} + +static void test_write_bad_prefix(void) { SerdWorld* world = serd_world_new(); @@ -129,7 +155,6 @@ test_writer_cleanup(void) // Finish writing without terminating nodes assert(!(st = serd_writer_finish(writer))); - assert(!(st = serd_writer_set_base_uri(writer, NULL))); // Set the base to an empty URI SerdNode* empty_uri = serd_new_uri(serd_string("")); @@ -225,6 +250,7 @@ test_write_error(void) int main(void) { + test_write_bad_event(); test_write_bad_prefix(); test_write_long_literal(); test_writer_cleanup(); |