aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_reader_writer.c5
-rw-r--r--test/test_terse_write.c9
-rw-r--r--test/test_writer.c25
3 files changed, 22 insertions, 17 deletions
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 3cf7cf5d..acd43ad1 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -210,7 +210,7 @@ test_writer(const char* const path)
// Test buffer sink
SerdBuffer buffer = {NULL, 0};
writer =
- serd_writer_new(world, SERD_TURTLE, 0, env, serd_buffer_sink, &buffer);
+ serd_writer_new(world, SERD_TURTLE, 0, env, serd_buffer_write, &buffer);
SerdNode* const base = serd_new_uri(serd_string("http://example.org/base"));
@@ -218,8 +218,9 @@ test_writer(const char* const path)
serd_node_free(base);
serd_writer_free(writer);
- char* out = serd_buffer_sink_finish(&buffer);
+ serd_buffer_close(&buffer);
+ char* const 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 277f025e..17bacc13 100644
--- a/test/test_terse_write.c
+++ b/test/test_terse_write.c
@@ -8,7 +8,6 @@
#include "serd/node.h"
#include "serd/sink.h"
#include "serd/statement.h"
-#include "serd/stream.h"
#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/world.h"
@@ -25,7 +24,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;
@@ -54,8 +53,8 @@ test(void)
serd_env_set_prefix(env, serd_string("rdf"), serd_string(NS_RDF));
- SerdWriter* writer = serd_writer_new(
- world, SERD_TURTLE, 0, env, (SerdWriteFunc)serd_buffer_sink, &buffer);
+ SerdWriter* writer =
+ serd_writer_new(world, SERD_TURTLE, 0, env, serd_buffer_write, &buffer);
const SerdSink* sink = serd_writer_sink(writer);
@@ -87,7 +86,7 @@ test(void)
serd_sink_write(sink, 0, l2, rdf_rest, rdf_nil, NULL);
check_output(writer, &buffer, "[] rdf:value ( \"s1\" \"s2\" ) .\n");
- serd_buffer_sink_finish(&buffer);
+ serd_buffer_close(&buffer);
serd_writer_free(writer);
serd_node_free(rdf_nil);
serd_node_free(rdf_rest);
diff --git a/test/test_writer.c b/test/test_writer.c
index a4d92c5b..fe685437 100644
--- a/test/test_writer.c
+++ b/test/test_writer.c
@@ -29,7 +29,7 @@ test_write_bad_event(void)
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);
+ serd_writer_new(world, SERD_TURTLE, 0U, env, serd_buffer_write, &buffer);
assert(writer);
@@ -37,8 +37,9 @@ test_write_bad_event(void)
assert(serd_sink_write_event(serd_writer_sink(writer), &event) ==
SERD_BAD_ARG);
- char* const out = serd_buffer_sink_finish(&buffer);
+ serd_buffer_close(&buffer);
+ char* const out = (char*)buffer.buf;
assert(!strcmp(out, ""));
serd_free(out);
@@ -54,7 +55,7 @@ test_write_bad_prefix(void)
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);
+ serd_writer_new(world, SERD_TURTLE, 0U, env, serd_buffer_write, &buffer);
assert(writer);
@@ -64,8 +65,9 @@ test_write_bad_prefix(void)
assert(serd_sink_write_prefix(serd_writer_sink(writer), name, uri) ==
SERD_BAD_ARG);
- char* const out = serd_buffer_sink_finish(&buffer);
+ serd_buffer_close(&buffer);
+ char* const out = (char*)buffer.buf;
assert(!strcmp(out, ""));
serd_free(out);
@@ -83,7 +85,7 @@ test_write_long_literal(void)
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);
+ serd_writer_new(world, SERD_TURTLE, 0U, env, serd_buffer_write, &buffer);
assert(writer);
@@ -98,8 +100,9 @@ test_write_long_literal(void)
serd_node_free(s);
serd_writer_free(writer);
serd_env_free(env);
+ serd_buffer_close(&buffer);
- char* out = serd_buffer_sink_finish(&buffer);
+ char* const out = (char*)buffer.buf;
static const char* const expected =
"<http://example.org/s>\n"
@@ -307,14 +310,15 @@ test_write_empty_syntax(void)
SerdBuffer buffer = {NULL, 0};
SerdWriter* writer = serd_writer_new(
- world, SERD_SYNTAX_EMPTY, 0U, env, serd_buffer_sink, &buffer);
+ world, SERD_SYNTAX_EMPTY, 0U, env, serd_buffer_write, &buffer);
assert(writer);
assert(!serd_sink_write(serd_writer_sink(writer), 0U, s, p, o, NULL));
- char* out = serd_buffer_sink_finish(&buffer);
+ serd_buffer_close(&buffer);
+ char* const out = (char*)buffer.buf;
assert(strlen(out) == 0);
serd_free(out);
@@ -334,7 +338,7 @@ check_pname_escape(const char* const lname, const char* const expected)
SerdBuffer buffer = {NULL, 0};
SerdWriter* writer =
- serd_writer_new(world, SERD_TURTLE, 0U, env, serd_buffer_sink, &buffer);
+ serd_writer_new(world, SERD_TURTLE, 0U, env, serd_buffer_write, &buffer);
assert(writer);
@@ -359,8 +363,9 @@ check_pname_escape(const char* const lname, const char* const expected)
serd_node_free(s);
serd_writer_free(writer);
serd_env_free(env);
+ serd_buffer_close(&buffer);
- char* out = serd_buffer_sink_finish(&buffer);
+ char* const out = (char*)buffer.buf;
assert(!strcmp((char*)out, expected));
serd_free(out);