aboutsummaryrefslogtreecommitdiffstats
path: root/tests/serd_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/serd_test.c')
-rw-r--r--tests/serd_test.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 82126c0c..a0fbb234 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -175,16 +175,16 @@ test_get_blank(void)
static int
test_strict_write(void)
{
- SerdWorld* world = serd_world_new();
- const char* path = "serd_strict_write_test.ttl";
- FILE* fd = fopen(path, "wb");
- SerdEnv* env = serd_env_new(NULL);
- SerdWriter* writer = serd_writer_new(world,
- SERD_TURTLE,
- 0,
- env,
- (SerdWriteFunc)fwrite,
- fd);
+ SerdWorld* world = serd_world_new();
+ const char* path = "serd_strict_write_test.ttl";
+ FILE* fd = fopen(path, "wb");
+ SerdEnv* env = serd_env_new(NULL);
+
+ SerdByteSink* byte_sink =
+ serd_byte_sink_new_function((SerdWriteFunc)fwrite, fd, 1);
+
+ SerdWriter* writer = serd_writer_new(world, SERD_TURTLE, 0, env, byte_sink);
+
assert(fd);
assert(writer);
@@ -202,6 +202,7 @@ test_strict_write(void)
serd_node_free(p);
serd_writer_free(writer);
+ serd_byte_sink_free(byte_sink);
serd_env_free(env);
fclose(fd);
serd_world_free(world);
@@ -559,12 +560,12 @@ test_writer(const char* const path)
SerdWorld* world = serd_world_new();
- SerdWriter* writer = serd_writer_new(world,
- SERD_TURTLE,
- SERD_WRITE_LAX,
- env,
- (SerdWriteFunc)fwrite,
- fd);
+ SerdByteSink* byte_sink =
+ serd_byte_sink_new_function((SerdWriteFunc)fwrite, fd, 1);
+
+ SerdWriter* writer =
+ serd_writer_new(world, SERD_TURTLE, SERD_WRITE_LAX, env, byte_sink);
+
assert(writer);
serd_writer_chop_blank_prefix(writer, "tmp");
@@ -633,6 +634,7 @@ test_writer(const char* const path)
assert(!serd_sink_write(iface, 0, s, p, o, 0));
serd_writer_free(writer);
+ serd_byte_sink_free(byte_sink);
serd_node_free(lit);
serd_node_free(o);
serd_node_free(t);
@@ -640,16 +642,10 @@ test_writer(const char* const path)
serd_node_free(urn_Type);
// Test buffer sink
- SerdBuffer buffer = { NULL, 0 };
- SerdByteSink* byte_sink =
- serd_byte_sink_new((SerdWriteFunc)serd_buffer_sink, &buffer, 1);
-
- writer = serd_writer_new(world,
- SERD_TURTLE,
- 0,
- env,
- (SerdWriteFunc)serd_byte_sink_write,
- byte_sink);
+ SerdBuffer buffer = {NULL, 0};
+
+ byte_sink = serd_byte_sink_new_buffer(&buffer);
+ writer = serd_writer_new(world, SERD_TURTLE, 0, env, byte_sink);
o = serd_new_uri("http://example.org/base");
assert(!serd_writer_set_base_uri(writer, o));