aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-07-11 20:47:51 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:07 -0500
commit6eb1fa15a06ab7de08e33add1540a45b83c5f0d8 (patch)
tree86d3cfedbf2ff76878eba6d14dc7fc259d1cbf46 /test/test_writer.c
parentd1ba721d37af61f2b529faaa16bd20ba1e161b06 (diff)
downloadserd-6eb1fa15a06ab7de08e33add1540a45b83c5f0d8.tar.gz
serd-6eb1fa15a06ab7de08e33add1540a45b83c5f0d8.tar.bz2
serd-6eb1fa15a06ab7de08e33add1540a45b83c5f0d8.zip
Add SerdWorld for shared library state
Diffstat (limited to 'test/test_writer.c')
-rw-r--r--test/test_writer.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/test/test_writer.c b/test/test_writer.c
index 5a4e5ab0..db68454f 100644
--- a/test/test_writer.c
+++ b/test/test_writer.c
@@ -12,6 +12,7 @@
#include "serd/status.h"
#include "serd/string_view.h"
#include "serd/syntax.h"
+#include "serd/world.h"
#include "serd/writer.h"
#include <assert.h>
@@ -22,10 +23,11 @@
static void
test_write_bad_prefix(void)
{
+ SerdWorld* world = serd_world_new();
SerdEnv* env = serd_env_new(serd_empty_string());
SerdBuffer buffer = {NULL, 0};
SerdWriter* writer =
- serd_writer_new(SERD_TURTLE, 0U, env, serd_buffer_sink, &buffer);
+ serd_writer_new(world, SERD_TURTLE, 0U, env, serd_buffer_sink, &buffer);
assert(writer);
@@ -44,15 +46,17 @@ test_write_bad_prefix(void)
serd_node_free(name);
serd_writer_free(writer);
serd_env_free(env);
+ serd_world_free(world);
}
static void
test_write_long_literal(void)
{
+ SerdWorld* world = serd_world_new();
SerdEnv* env = serd_env_new(serd_empty_string());
SerdBuffer buffer = {NULL, 0};
SerdWriter* writer =
- serd_writer_new(SERD_TURTLE, 0U, env, serd_buffer_sink, &buffer);
+ serd_writer_new(world, SERD_TURTLE, 0U, env, serd_buffer_sink, &buffer);
assert(writer);
@@ -76,6 +80,8 @@ test_write_long_literal(void)
assert(!strcmp((char*)out, expected));
serd_free(out);
+
+ serd_world_free(world);
}
static size_t
@@ -93,9 +99,11 @@ null_sink(const void* const buf,
static void
test_writer_cleanup(void)
{
- SerdStatus st = SERD_SUCCESS;
- SerdEnv* env = serd_env_new(serd_empty_string());
- SerdWriter* writer = serd_writer_new(SERD_TURTLE, 0U, env, null_sink, NULL);
+ SerdStatus st = SERD_SUCCESS;
+ SerdWorld* world = serd_world_new();
+ SerdEnv* env = serd_env_new(serd_empty_string());
+ SerdWriter* writer =
+ serd_writer_new(world, SERD_TURTLE, 0U, env, null_sink, NULL);
const SerdSink* sink = serd_writer_sink(writer);
@@ -134,6 +142,7 @@ test_writer_cleanup(void)
serd_node_free(s);
serd_writer_free(writer);
serd_env_free(env);
+ serd_world_free(world);
}
static void
@@ -143,9 +152,10 @@ test_strict_write(void)
FILE* const fd = fopen(path, "wb");
assert(fd);
+ SerdWorld* world = serd_world_new();
SerdEnv* const env = serd_env_new(serd_empty_string());
SerdWriter* const writer = serd_writer_new(
- SERD_TURTLE, (SerdWriterFlags)SERD_WRITE_STRICT, env, null_sink, fd);
+ world, SERD_TURTLE, (SerdWriterFlags)SERD_WRITE_STRICT, env, null_sink, fd);
assert(writer);
@@ -168,6 +178,7 @@ test_strict_write(void)
serd_node_free(s);
serd_writer_free(writer);
serd_env_free(env);
+ serd_world_free(world);
fclose(fd);
remove(path);
}
@@ -189,14 +200,15 @@ error_sink(const void* const buf,
static void
test_write_error(void)
{
- SerdEnv* const env = serd_env_new(serd_empty_string());
- SerdWriter* writer = NULL;
- SerdStatus st = SERD_SUCCESS;
+ SerdWorld* const world = serd_world_new();
+ SerdEnv* const env = serd_env_new(serd_empty_string());
+ SerdWriter* writer = NULL;
+ SerdStatus st = SERD_SUCCESS;
SerdNode* u = serd_new_uri(serd_string("http://example.com/u"));
- writer =
- serd_writer_new(SERD_TURTLE, (SerdWriterFlags)0, env, error_sink, NULL);
+ writer = serd_writer_new(
+ world, SERD_TURTLE, (SerdWriterFlags)0, env, error_sink, NULL);
assert(writer);
const SerdSink* const sink = serd_writer_sink(writer);
@@ -207,6 +219,7 @@ test_write_error(void)
serd_node_free(u);
serd_env_free(env);
+ serd_world_free(world);
}
int