aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-03-03 20:55:00 +0000
committerDavid Robillard <d@drobilla.net>2012-03-03 20:55:00 +0000
commit7b022006c47586dc00ed8bca85fcb0bdf5f9465d (patch)
treea8aa0a2be9ee7341ff02730130b3291ab2dcaace /tests
parent5d73ff3a0b529954e5192f892c21a4ad068905c9 (diff)
downloadserd-7b022006c47586dc00ed8bca85fcb0bdf5f9465d.tar.gz
serd-7b022006c47586dc00ed8bca85fcb0bdf5f9465d.tar.bz2
serd-7b022006c47586dc00ed8bca85fcb0bdf5f9465d.zip
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
Diffstat (limited to 'tests')
-rw-r--r--tests/serd_test.c21
1 files changed, 21 insertions, 0 deletions
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 <http://example.org/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(