aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-12-02 17:11:23 -0500
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commitb13ad41a4d65b577b4db67660a9edf3056bdf7af (patch)
treee89535f6098a1b860f38ec8a7a1b698b30a72545 /test/test_writer.c
parent0db18e483f11ac2f9518d96e137d217040ed1339 (diff)
downloadserd-b13ad41a4d65b577b4db67660a9edf3056bdf7af.tar.gz
serd-b13ad41a4d65b577b4db67660a9edf3056bdf7af.tar.bz2
serd-b13ad41a4d65b577b4db67660a9edf3056bdf7af.zip
Use SerdNodes instead of manual memory management in tests
Diffstat (limited to 'test/test_writer.c')
-rw-r--r--test/test_writer.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/test/test_writer.c b/test/test_writer.c
index a80783f6..60f50308 100644
--- a/test/test_writer.c
+++ b/test/test_writer.c
@@ -237,7 +237,7 @@ test_writer_cleanup(void)
const SerdNode* const p =
serd_nodes_get(nodes, serd_a_uri_string("http://example.org/p"));
- const SerdNode* o = serd_nodes_get(nodes, serd_a_string("start"));
+ const SerdNode* o = serd_nodes_get(nodes, serd_a_blank(serd_string("start")));
st = serd_sink_write(sink, SERD_ANON_O, s, p, o, NULL);
assert(!st);
@@ -257,9 +257,8 @@ test_writer_cleanup(void)
assert(!(st = serd_writer_finish(writer)));
// Set the base to an empty URI
- const SerdNode* const empty_uri =
- serd_nodes_get(nodes, serd_a_uri_string(""));
- assert(!(st = serd_sink_write_base(sink, empty_uri)));
+ assert(!(st = serd_sink_write_base(
+ sink, serd_nodes_get(nodes, serd_a_uri_string("")))));
// Free (which could leak if the writer doesn't clean up the stack properly)
serd_writer_free(writer);
@@ -275,6 +274,7 @@ test_strict_write(void)
assert(fd);
SerdWorld* world = serd_world_new(NULL);
+ SerdNodes* nodes = serd_world_nodes(world);
SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
SerdOutputStream out = serd_open_output_stream(null_sink, NULL, NULL, fd);
SerdWriter* const writer =
@@ -286,21 +286,23 @@ test_strict_write(void)
const uint8_t bad_str[] = {0xFF, 0x90, 'h', 'i', 0};
- SerdNode* s = serd_node_new(NULL, serd_a_uri_string("http://example.org/s"));
- SerdNode* p = serd_node_new(NULL, serd_a_uri_string("http://example.org/p"));
+ const SerdNode* const s =
+ serd_nodes_get(nodes, serd_a_uri_string("http://example.org/s"));
+
+ const SerdNode* const p =
+ serd_nodes_get(nodes, serd_a_uri_string("http://example.org/p"));
+
+ const SerdNode* const bad_lit =
+ serd_nodes_get(nodes, serd_a_string((const char*)bad_str));
- SerdNode* bad_lit = serd_node_new(NULL, serd_a_string((const char*)bad_str));
- SerdNode* bad_uri =
- serd_node_new(NULL, serd_a_uri_string((const char*)bad_str));
+ const SerdNode* const bad_uri =
+ serd_nodes_get(nodes, serd_a_uri_string((const char*)bad_str));
assert(serd_sink_write(sink, 0, s, p, bad_lit, NULL) == SERD_BAD_TEXT);
assert(serd_sink_write(sink, 0, s, p, bad_uri, NULL) == SERD_BAD_TEXT);
- serd_node_free(NULL, bad_uri);
- serd_node_free(NULL, bad_lit);
- serd_node_free(NULL, p);
- serd_node_free(NULL, s);
serd_writer_free(writer);
+ serd_close_output(&out);
serd_env_free(env);
serd_world_free(world);
fclose(fd);
@@ -325,11 +327,13 @@ static void
test_write_error(void)
{
SerdWorld* const world = serd_world_new(NULL);
+ SerdNodes* const nodes = serd_world_nodes(world);
SerdEnv* const env = serd_env_new(NULL, serd_empty_string());
SerdOutputStream out = serd_open_output_stream(error_sink, NULL, NULL, NULL);
SerdStatus st = SERD_SUCCESS;
- SerdNode* u = serd_node_new(NULL, serd_a_uri_string("http://example.com/u"));
+ const SerdNode* const u =
+ serd_nodes_get(nodes, serd_a_uri_string("http://example.com/u"));
SerdWriter* const writer =
serd_writer_new(world, SERD_TURTLE, (SerdWriterFlags)0, env, &out, 1U);
@@ -341,7 +345,6 @@ test_write_error(void)
assert(st == SERD_BAD_WRITE);
serd_writer_free(writer);
- serd_node_free(NULL, u);
serd_env_free(env);
serd_world_free(world);
}