aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_reader_writer.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_reader_writer.c')
-rw-r--r--test/test_reader_writer.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 55c4b584..d6a2675d 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -97,7 +97,7 @@ faulty_sink(const void* const buf,
static void
test_write_errors(void)
{
- SerdWorld* const world = serd_world_new();
+ SerdWorld* const world = serd_world_new(NULL);
ErrorContext ctx = {0U, 0U};
const size_t max_offsets[] = {0, 368, 1900, 1992, 413};
@@ -109,7 +109,7 @@ test_write_errors(void)
ctx.n_written = 0;
ctx.error_offset = o;
- SerdEnv* const env = serd_env_new(serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
SerdOutputStream out =
serd_open_output_stream(faulty_sink, NULL, NULL, &ctx);
@@ -141,8 +141,8 @@ test_write_errors(void)
static void
test_writer(const char* const path)
{
- SerdWorld* world = serd_world_new();
- SerdEnv* env = serd_env_new(serd_empty_string());
+ SerdWorld* world = serd_world_new(NULL);
+ SerdEnv* env = serd_env_new(NULL, serd_empty_string());
SerdOutputStream output = serd_open_output_file(path);
@@ -154,7 +154,7 @@ test_writer(const char* const path)
serd_writer_chop_blank_prefix(writer, "tmp");
serd_writer_chop_blank_prefix(writer, NULL);
- SerdNode* lit = serd_new_string(serd_string("hello"));
+ SerdNode* lit = serd_new_string(NULL, serd_string("hello"));
const SerdSink* const iface = serd_writer_sink(writer);
assert(serd_sink_write_base(iface, lit));
@@ -164,9 +164,9 @@ test_writer(const char* const path)
static const uint8_t bad_buf[] = {0xEF, 0xBF, 0xBD, 0};
const SerdStringView bad_buf_view = {(const char*)bad_buf, 3};
- SerdNode* s = serd_new_uri(serd_string("http://example.org"));
- SerdNode* p = serd_new_uri(serd_string("http://example.org/pred"));
- SerdNode* bad = serd_new_string(bad_buf_view);
+ SerdNode* s = serd_new_uri(NULL, serd_string("http://example.org"));
+ SerdNode* p = serd_new_uri(NULL, serd_string("http://example.org/pred"));
+ SerdNode* bad = serd_new_string(NULL, bad_buf_view);
// Write 3 invalid statements (should write nothing)
const SerdNode* junk[][3] = {{s, bad, bad}, {bad, p, bad}, {s, bad, p}};
@@ -174,17 +174,18 @@ test_writer(const char* const path)
assert(serd_sink_write(iface, 0, junk[i][0], junk[i][1], junk[i][2], NULL));
}
- serd_node_free(bad);
+ serd_node_free(NULL, bad);
const SerdStringView urn_Type = serd_string("urn:Type");
const SerdStringView en = serd_string("en");
- SerdNode* const o = serd_new_string(serd_string("o"));
+ SerdNode* const o = serd_new_string(NULL, serd_string("o"));
SerdNode* const t =
- serd_new_literal(serd_string("t"), SERD_HAS_DATATYPE, urn_Type);
+ serd_new_literal(NULL, serd_string("t"), SERD_HAS_DATATYPE, urn_Type);
- SerdNode* const l = serd_new_literal(serd_string("l"), SERD_HAS_LANGUAGE, en);
+ SerdNode* const l =
+ serd_new_literal(NULL, serd_string("l"), SERD_HAS_LANGUAGE, en);
const SerdNode* good[][3] = {{s, p, o}, {s, p, t}, {s, p, l}};
@@ -199,46 +200,47 @@ test_writer(const char* const path)
static const char* const bad_uri_str = (const char*)bad_uri_buf;
// Write statements with bad UTF-8 (should be replaced)
- SerdNode* bad_lit = serd_new_string(serd_string(bad_lit_str));
- SerdNode* bad_uri = serd_new_uri(serd_string(bad_uri_str));
+ SerdNode* bad_lit = serd_new_string(NULL, serd_string(bad_lit_str));
+ SerdNode* bad_uri = serd_new_uri(NULL, serd_string(bad_uri_str));
assert(!serd_sink_write(iface, 0, s, p, bad_lit, 0));
assert(!serd_sink_write(iface, 0, s, p, bad_uri, 0));
- serd_node_free(bad_uri);
- serd_node_free(bad_lit);
+ serd_node_free(NULL, bad_uri);
+ serd_node_free(NULL, bad_lit);
// Write 1 valid statement
- SerdNode* const hello = serd_new_string(serd_string("hello"));
+ SerdNode* const hello = serd_new_string(NULL, serd_string("hello"));
assert(!serd_sink_write(iface, 0, s, p, hello, 0));
- serd_node_free(hello);
+ serd_node_free(NULL, hello);
serd_writer_free(writer);
serd_close_output(&output);
- serd_node_free(lit);
- serd_node_free(o);
- serd_node_free(t);
- serd_node_free(l);
+ serd_node_free(NULL, lit);
+ serd_node_free(NULL, o);
+ serd_node_free(NULL, t);
+ serd_node_free(NULL, l);
// Test buffer sink
- SerdBuffer buffer = {NULL, 0};
- SerdNode* const base = serd_new_uri(serd_string("http://example.org/base"));
+ SerdBuffer buffer = {NULL, NULL, 0};
+ SerdNode* const base =
+ serd_new_uri(NULL, serd_string("http://example.org/base"));
output = serd_open_output_buffer(&buffer);
writer = serd_writer_new(world, SERD_TURTLE, 0, env, &output, 1U);
serd_sink_write_base(serd_writer_sink(writer), base);
- serd_node_free(base);
+ serd_node_free(NULL, base);
serd_writer_free(writer);
serd_close_output(&output);
char* const out = (char*)buffer.buf;
assert(out);
assert(!strcmp(out, "@base <http://example.org/base> .\n"));
- serd_free(out);
+ serd_free(NULL, buffer.buf);
- serd_node_free(p);
- serd_node_free(s);
+ serd_node_free(NULL, p);
+ serd_node_free(NULL, s);
serd_env_free(env);
serd_world_free(world);
@@ -247,12 +249,12 @@ test_writer(const char* const path)
static void
test_reader(const char* path)
{
- SerdWorld* world = serd_world_new();
- ReaderTest rt = {0};
- SerdSink* const sink = serd_sink_new(&rt, test_sink, NULL);
+ SerdWorld* const world = serd_world_new(NULL);
+ ReaderTest rt = {0};
+ SerdSink* const sink = serd_sink_new(NULL, &rt, test_sink, NULL);
assert(sink);
- SerdEnv* const env = serd_env_new(serd_empty_string());
+ SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
assert(env);
// Test that too little stack space fails gracefully