aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-08-13 19:31:26 -0400
committerDavid Robillard <d@drobilla.net>2022-01-28 21:57:07 -0500
commit63e7e57237a79d0447b0450a7fd3148c43052299 (patch)
treeb4c45eca1c208f8bd70a7a50632d423aec39e118 /test
parent547ef6e0600b703dcd42a10622563d7b91434669 (diff)
downloadserd-63e7e57237a79d0447b0450a7fd3148c43052299.tar.gz
serd-63e7e57237a79d0447b0450a7fd3148c43052299.tar.bz2
serd-63e7e57237a79d0447b0450a7fd3148c43052299.zip
Provide a full output stream implementation for SerdBuffer
Essentially replaces serd_buffer_sink_finish() with serd_buffer_close(), which makes writing to a buffer consistent with writing to a file or anything else.
Diffstat (limited to 'test')
-rw-r--r--test/test_reader_writer.c2
-rw-r--r--test/test_terse_write.c3
-rw-r--r--test/test_writer.c10
3 files changed, 8 insertions, 7 deletions
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 1bad22cd..b8afd649 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -121,7 +121,7 @@ test_writer(const char* const path)
serd_writer_free(writer);
serd_byte_sink_free(byte_sink);
- char* out = serd_buffer_sink_finish(&buffer);
+ char* out = (char*)buffer.buf;
assert(!strcmp(out, "@base <http://example.org/base> .\n"));
serd_free(out);
diff --git a/test/test_terse_write.c b/test/test_terse_write.c
index 59227332..aeb264ea 100644
--- a/test/test_terse_write.c
+++ b/test/test_terse_write.c
@@ -29,7 +29,7 @@ static void
check_output(SerdWriter* writer, SerdBuffer* buffer, const char* expected)
{
serd_writer_finish(writer);
- serd_buffer_sink_finish(buffer);
+ serd_buffer_close(buffer);
const char* output = (const char*)buffer->buf;
@@ -98,7 +98,6 @@ test(void)
serd_sink_write(sink, 0, l2, rdf_rest, rdf_nil, NULL);
check_output(writer, &buffer, "[]\n\trdf:value ( \"s1\" \"s2\" ) .\n");
- serd_buffer_sink_finish(&buffer);
serd_writer_free(writer);
serd_byte_sink_free(byte_sink);
serd_nodes_free(nodes);
diff --git a/test/test_writer.c b/test/test_writer.c
index 89531eee..83d4087c 100644
--- a/test/test_writer.c
+++ b/test/test_writer.c
@@ -83,14 +83,15 @@ test_write_long_literal(void)
serd_writer_free(writer);
serd_byte_sink_free(byte_sink);
serd_env_free(env);
+ serd_buffer_close(&buffer);
- char* out = serd_buffer_sink_finish(&buffer);
+ char* out = (char*)buffer.buf;
static const char* const expected =
"<http://example.org/s>\n"
"\t<http://example.org/p> \"\"\"hello \"\"\\\"world\"\"\\\"!\"\"\" .\n";
- assert(!strcmp((char*)out, expected));
+ assert(!strcmp(out, expected));
serd_free(out);
serd_world_free(world);
@@ -369,10 +370,11 @@ check_pname_escape(const char* const lname, const char* const expected)
serd_writer_free(writer);
serd_byte_sink_free(byte_sink);
serd_env_free(env);
+ serd_buffer_close(&buffer);
- char* out = serd_buffer_sink_finish(&buffer);
+ char* out = (char*)buffer.buf;
- assert(!strcmp((char*)out, expected));
+ assert(!strcmp(out, expected));
serd_free(out);
free(uri);