aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-01-13 14:31:00 +0100
committerDavid Robillard <d@drobilla.net>2023-12-02 16:27:02 -0500
commit82f8f804773b10c42b17a30872a59ed76b062794 (patch)
tree73b6ebdde09b41126f37f3f4fc7fbe44b07ec3fb /test
parent84bab08585dec858807a6130bd2d71f304b889f0 (diff)
downloadserd-82f8f804773b10c42b17a30872a59ed76b062794.tar.gz
serd-82f8f804773b10c42b17a30872a59ed76b062794.tar.bz2
serd-82f8f804773b10c42b17a30872a59ed76b062794.zip
Add SerdBuffer type for mutable buffers
This avoids const violations from abusing SerdChunk as a mutable buffer for string sinks.
Diffstat (limited to 'test')
-rw-r--r--test/test_reader_writer.c22
-rw-r--r--test/test_writer.c6
2 files changed, 14 insertions, 14 deletions
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 0555e7bb..bb27cf3e 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -514,16 +514,16 @@ test_writer(const char* const path)
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);
+ // Test buffer sink
+ SerdBuffer buffer = {NULL, 0};
+ writer = serd_writer_new(
+ SERD_TURTLE, (SerdStyle)0, env, NULL, serd_buffer_sink, &buffer);
o = serd_node_from_string(SERD_URI, "http://example.org/base");
assert(!serd_writer_set_base_uri(writer, &o));
serd_writer_free(writer);
- char* out = serd_chunk_sink_finish(&chunk);
+ char* out = serd_buffer_sink_finish(&buffer);
assert(!strcmp(out, "@base <http://example.org/base> .\n"));
serd_free(out);
@@ -531,19 +531,19 @@ test_writer(const char* const path)
// Test writing empty node
SerdNode nothing = serd_node_from_string(SERD_NOTHING, "");
- chunk.buf = NULL;
- chunk.len = 0;
- writer = serd_writer_new(
- SERD_TURTLE, (SerdStyle)0, env, NULL, serd_chunk_sink, &chunk);
+ buffer.buf = NULL;
+ buffer.len = 0;
+ writer = serd_writer_new(
+ SERD_TURTLE, (SerdStyle)0, env, NULL, serd_buffer_sink, &buffer);
assert(!serd_writer_write_statement(
writer, 0, NULL, &s, &p, &nothing, NULL, NULL));
assert(
- !strncmp((const char*)chunk.buf, "<>\n\t<http://example.org/pred> ", 30));
+ !strncmp((const char*)buffer.buf, "<>\n\t<http://example.org/pred> ", 30));
serd_writer_free(writer);
- out = serd_chunk_sink_finish(&chunk);
+ out = serd_buffer_sink_finish(&buffer);
assert(!strcmp((const char*)out, "<>\n\t<http://example.org/pred> .\n"));
serd_free(out);
diff --git a/test/test_writer.c b/test/test_writer.c
index 7033db76..aa1b05e7 100644
--- a/test/test_writer.c
+++ b/test/test_writer.c
@@ -14,9 +14,9 @@ static void
test_write_long_literal(void)
{
SerdEnv* env = serd_env_new(NULL);
- SerdChunk chunk = {NULL, 0};
+ SerdBuffer buffer = {NULL, 0};
SerdWriter* writer = serd_writer_new(
- SERD_TURTLE, (SerdStyle)0, env, NULL, serd_chunk_sink, &chunk);
+ SERD_TURTLE, (SerdStyle)0, env, NULL, serd_buffer_sink, &buffer);
assert(writer);
@@ -29,7 +29,7 @@ test_write_long_literal(void)
serd_writer_free(writer);
serd_env_free(env);
- char* out = serd_chunk_sink_finish(&chunk);
+ char* out = serd_buffer_sink_finish(&buffer);
static const char* const expected =
"<http://example.org/s>\n"