aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-06-23 16:21:08 -0400
committerDavid Robillard <d@drobilla.net>2024-06-23 16:22:38 -0400
commitb6c9214d2077c87fa19cc5431732f1b496797bed (patch)
tree2efdf473f7bf238b1c96113305569f872d39eb68 /test
parent9a88802ed56c4500f596647e9aa1ef5d93ecfd73 (diff)
downloadserd-b6c9214d2077c87fa19cc5431732f1b496797bed.tar.gz
serd-b6c9214d2077c87fa19cc5431732f1b496797bed.tar.bz2
serd-b6c9214d2077c87fa19cc5431732f1b496797bed.zip
Fix writer cleanup test
Because nodes are shallow, this wasn't actually writing a stack of nested objects. Fix the blank node ping-pong algorithm so that it does.
Diffstat (limited to 'test')
-rw-r--r--test/test_writer.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/test/test_writer.c b/test/test_writer.c
index b02aba7e..75b311cf 100644
--- a/test/test_writer.c
+++ b/test/test_writer.c
@@ -134,7 +134,9 @@ test_writer_cleanup(void)
SerdNode s = serd_node_from_string(SERD_URI, USTR("http://example.org/s"));
SerdNode p = serd_node_from_string(SERD_URI, USTR("http://example.org/p"));
- SerdNode o = serd_node_from_string(SERD_BLANK, USTR("http://example.org/o"));
+
+ char o_buf[12] = {'b', '0', '\0'};
+ SerdNode o = serd_node_from_string(SERD_BLANK, USTR(o_buf));
st = serd_writer_write_statement(
writer, SERD_ANON_O_BEGIN, NULL, &s, &p, &o, NULL, NULL);
@@ -142,16 +144,24 @@ test_writer_cleanup(void)
assert(!st);
// Write the start of several nested anonymous objects
- for (unsigned i = 0U; !st && i < 8U; ++i) {
- char buf[12] = {0};
- snprintf(buf, sizeof(buf), "b%u", i);
+ for (unsigned i = 1U; !st && i < 9U; ++i) {
+ char next_o_buf[12] = {'\0'};
+ snprintf(next_o_buf, sizeof(next_o_buf), "b%u", i);
+
+ SerdNode next_o = serd_node_from_string(SERD_BLANK, USTR(next_o_buf));
- SerdNode next_o = serd_node_from_string(SERD_BLANK, USTR(buf));
+ st = serd_writer_write_statement(writer,
+ SERD_ANON_O_BEGIN | SERD_ANON_CONT,
+ NULL,
+ &o,
+ &p,
+ &next_o,
+ NULL,
+ NULL);
- st = serd_writer_write_statement(
- writer, SERD_ANON_O_BEGIN, NULL, &o, &p, &next_o, NULL, NULL);
+ assert(!st);
- o = next_o;
+ memcpy(o_buf, next_o_buf, sizeof(o_buf));
}
// Finish writing without terminating nodes