From 7b022006c47586dc00ed8bca85fcb0bdf5f9465d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 3 Mar 2012 20:55:00 +0000 Subject: Add serd_chunk_sink for easy writing to a string. git-svn-id: http://svn.drobilla.net/serd/trunk@329 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- tests/serd_test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/serd_test.c b/tests/serd_test.c index 12129280..1474c37d 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -443,6 +443,27 @@ main() } serd_writer_free(writer); + + // Test chunk sink + SerdChunk chunk = { NULL, 0 }; + writer = serd_writer_new( + SERD_TURTLE, (SerdStyle)0, env, NULL, serd_chunk_sink, &chunk); + + o = serd_node_from_string(SERD_URI, USTR("http://example.org/base")); + if (serd_writer_set_base_uri(writer, &o)) { + return failure("Failed to write to chunk sink\n"); + } + + serd_writer_free(writer); + uint8_t* out = serd_chunk_sink_finish(&chunk); + + if (strcmp((const char*)out, "@base .\n")) { + return failure("Incorrect chunk output:\n%s\n", chunk.buf); + } + + free(out); + + // Rewind and test reader fseek(fd, 0, SEEK_SET); SerdReader* reader = serd_reader_new( -- cgit v1.2.1