aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_canon.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-05-10 21:06:16 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commite750f4b6734d086e433e3c9c05b2252f43f4be8f (patch)
tree6eb84ef00642ac32f40bca8a242a9b0d2a6ef3f3 /test/test_canon.c
parent8346ac7f529f5aeb8d8b0e48837e680ea14e8893 (diff)
downloadserd-e750f4b6734d086e433e3c9c05b2252f43f4be8f.tar.gz
serd-e750f4b6734d086e433e3c9c05b2252f43f4be8f.tar.bz2
serd-e750f4b6734d086e433e3c9c05b2252f43f4be8f.zip
Add SerdNodes for storing a cache of interned nodes
Diffstat (limited to 'test/test_canon.c')
-rw-r--r--test/test_canon.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/test/test_canon.c b/test/test_canon.c
index 7d7fbf28..89d1312b 100644
--- a/test/test_canon.c
+++ b/test/test_canon.c
@@ -8,6 +8,7 @@
#include "serd/canon.h"
#include "serd/event.h"
#include "serd/node.h"
+#include "serd/nodes.h"
#include "serd/sink.h"
#include "serd/status.h"
#include "serd/string_view.h"
@@ -30,6 +31,7 @@ test_new_failed_alloc(void)
SerdFailingAllocator allocator = serd_failing_allocator();
SerdWorld* const world = serd_world_new(&allocator.base);
+ SerdNodes* const nodes = serd_nodes_new(&allocator.base);
SerdSink* target = serd_sink_new(&allocator.base, NULL, ignore_event, NULL);
const size_t n_setup_allocs = allocator.n_allocations;
@@ -47,6 +49,7 @@ test_new_failed_alloc(void)
serd_sink_free(canon);
serd_sink_free(target);
+ serd_nodes_free(nodes);
serd_world_free(world);
}
@@ -60,13 +63,13 @@ test_write_failed_alloc(void)
serd_string("http://www.w3.org/2001/XMLSchema#float");
SerdFailingAllocator allocator = serd_failing_allocator();
+ SerdWorld* const world = serd_world_new(&allocator.base);
+ SerdNodes* const nodes = serd_nodes_new(&allocator.base);
- SerdWorld* const world = serd_world_new(&allocator.base);
-
- SerdNode* const s = serd_node_new(&allocator.base, serd_a_uri(s_string));
- SerdNode* const p = serd_node_new(&allocator.base, serd_a_uri(p_string));
- SerdNode* const o =
- serd_node_new(&allocator.base, serd_a_typed_literal(o_string, xsd_float));
+ const SerdNode* const s = serd_nodes_get(nodes, serd_a_uri(s_string));
+ const SerdNode* const p = serd_nodes_get(nodes, serd_a_uri(p_string));
+ const SerdNode* const o =
+ serd_nodes_get(nodes, serd_a_typed_literal(o_string, xsd_float));
SerdSink* target = serd_sink_new(&allocator.base, NULL, ignore_event, NULL);
SerdSink* canon = serd_canon_new(world, target, 0U);
@@ -87,9 +90,7 @@ test_write_failed_alloc(void)
serd_sink_free(canon);
serd_sink_free(target);
- serd_node_free(&allocator.base, o);
- serd_node_free(&allocator.base, p);
- serd_node_free(&allocator.base, s);
+ serd_nodes_free(nodes);
serd_world_free(world);
}