From 4711fdf527f416faee8ff19e15f050d4b48dcfb2 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 5 May 2023 09:43:57 -0400 Subject: [WIP] Generalize node construction API --- test/test_reader_writer.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'test/test_reader_writer.c') diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index d6a2675d..aea0976d 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -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(NULL, serd_string("hello")); + SerdNode* lit = serd_node_new(NULL, serd_a_string("hello")); const SerdSink* const iface = serd_writer_sink(writer); assert(serd_sink_write_base(iface, lit)); @@ -164,9 +164,10 @@ 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(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); + SerdNode* s = serd_node_new(NULL, serd_a_uri_string("http://example.org")); + SerdNode* p = + serd_node_new(NULL, serd_a_uri_string("http://example.org/pred")); + SerdNode* bad = serd_node_new(NULL, serd_a_string_view(bad_buf_view)); // Write 3 invalid statements (should write nothing) const SerdNode* junk[][3] = {{s, bad, bad}, {bad, p, bad}, {s, bad, p}}; @@ -179,13 +180,13 @@ test_writer(const char* const path) const SerdStringView urn_Type = serd_string("urn:Type"); const SerdStringView en = serd_string("en"); - SerdNode* const o = serd_new_string(NULL, serd_string("o")); + SerdNode* const o = serd_node_new(NULL, serd_a_string("o")); SerdNode* const t = - serd_new_literal(NULL, serd_string("t"), SERD_HAS_DATATYPE, urn_Type); + serd_node_new(NULL, serd_a_typed_literal(serd_string("t"), urn_Type)); SerdNode* const l = - serd_new_literal(NULL, serd_string("l"), SERD_HAS_LANGUAGE, en); + serd_node_new(NULL, serd_a_plain_literal(serd_string("l"), en)); const SerdNode* good[][3] = {{s, p, o}, {s, p, t}, {s, p, l}}; @@ -200,15 +201,15 @@ 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(NULL, serd_string(bad_lit_str)); - SerdNode* bad_uri = serd_new_uri(NULL, serd_string(bad_uri_str)); + SerdNode* bad_lit = serd_node_new(NULL, serd_a_string(bad_lit_str)); + SerdNode* bad_uri = serd_node_new(NULL, serd_a_uri_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(NULL, bad_uri); serd_node_free(NULL, bad_lit); // Write 1 valid statement - SerdNode* const hello = serd_new_string(NULL, serd_string("hello")); + SerdNode* const hello = serd_node_new(NULL, serd_a_string("hello")); assert(!serd_sink_write(iface, 0, s, p, hello, 0)); serd_node_free(NULL, hello); @@ -223,7 +224,7 @@ test_writer(const char* const path) // Test buffer sink SerdBuffer buffer = {NULL, NULL, 0}; SerdNode* const base = - serd_new_uri(NULL, serd_string("http://example.org/base")); + serd_node_new(NULL, serd_a_uri_string("http://example.org/base")); output = serd_open_output_buffer(&buffer); writer = serd_writer_new(world, SERD_TURTLE, 0, env, &output, 1U); -- cgit v1.2.1