From 5edfa72b81b46866a87d4f3c118492ee99bc0476 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 11 Jul 2021 18:44:03 -0400 Subject: Remove SERD_CURIE node datatype entirely --- test/test_env.c | 77 ++++++++++++++-------------------------------------- test/test_node.c | 4 --- test/test_nodes.c | 19 ------------- test/test_overflow.c | 4 +++ test/test_writer.c | 4 ++- 5 files changed, 27 insertions(+), 81 deletions(-) (limited to 'test') diff --git a/test/test_env.c b/test/test_env.c index 9e60104d..41e2060b 100644 --- a/test/test_env.c +++ b/test/test_env.c @@ -67,20 +67,15 @@ test_comparison(void) static void test_null(void) { - SerdNode* const eg = serd_new_uri(SERD_STRING(NS_EG)); - // "Copying" NULL returns null assert(!serd_env_copy(NULL)); // Accessors are tolerant to a NULL env for convenience assert(!serd_env_base_uri(NULL)); - assert(!serd_env_expand(NULL, NULL)); - assert(!serd_env_qualify(NULL, eg)); + assert(!serd_env_expand_node(NULL, NULL)); // Only null is equal to null assert(serd_env_equals(NULL, NULL)); - - serd_node_free(eg); } static SerdStatus @@ -158,7 +153,7 @@ test_expand_untyped_literal(void) SerdNode* const untyped = serd_new_string(SERD_STRING("data")); SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); - assert(!serd_env_expand(env, untyped)); + assert(!serd_env_expand_node(env, untyped)); serd_env_free(env); serd_node_free(untyped); @@ -172,7 +167,7 @@ test_expand_bad_uri_datatype(void) SerdNode* const typed = serd_new_typed_literal(SERD_STRING("data"), type); SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); - assert(!serd_env_expand(env, typed)); + assert(!serd_env_expand_node(env, typed)); serd_env_free(env); serd_node_free(typed); @@ -185,9 +180,9 @@ test_expand_uri(void) SerdEnv* const env = serd_env_new(base); SerdNode* const rel = serd_new_uri(SERD_STRING("rel")); - SerdNode* const rel_out = serd_env_expand(env, rel); + SerdNode* const rel_out = serd_env_expand_node(env, rel); SerdNode* const empty = serd_new_uri(SERD_EMPTY_STRING()); - SerdNode* const empty_out = serd_env_expand(env, empty); + SerdNode* const empty_out = serd_env_expand_node(env, empty); assert(!strcmp(serd_node_string(rel_out), "http://example.org/b/rel")); assert(!strcmp(serd_node_string(empty_out), "http://example.org/b/")); @@ -206,7 +201,7 @@ test_expand_empty_uri_ref(void) SerdNode* const rel = serd_new_uri(SERD_STRING("rel")); SerdEnv* const env = serd_env_new(base); - SerdNode* const rel_out = serd_env_expand(env, rel); + SerdNode* const rel_out = serd_env_expand_node(env, rel); assert(!strcmp(serd_node_string(rel_out), "http://example.org/b/rel")); serd_node_free(rel_out); @@ -221,7 +216,7 @@ test_expand_bad_uri(void) SerdNode* const bad_uri = serd_new_uri(SERD_STRING("rel")); SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); - assert(!serd_env_expand(env, bad_uri)); + assert(!serd_env_expand_node(env, bad_uri)); serd_env_free(env); serd_node_free(bad_uri); @@ -233,30 +228,31 @@ test_expand_curie(void) static const SerdStringView name = SERD_STRING("eg.1"); static const SerdStringView eg = SERD_STRING(NS_EG); - SerdNode* const curie = serd_new_curie(SERD_STRING("eg.1:foo")); - SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); + SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); assert(!serd_env_set_prefix(env, name, eg)); - SerdNode* const curie_out = serd_env_expand(env, curie); - assert(curie_out); - assert(!strcmp(serd_node_string(curie_out), "http://example.org/foo")); - serd_node_free(curie_out); + SerdNode* const expanded = + serd_env_expand_curie(env, SERD_STRING("eg.1:foo")); + + assert(expanded); + assert(!strcmp(serd_node_string(expanded), "http://example.org/foo")); + serd_node_free(expanded); serd_env_free(env); - serd_node_free(curie); } static void test_expand_bad_curie(void) { - SerdNode* const curie = serd_new_curie(SERD_STRING("eg.1:foo")); - SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); + SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); - assert(!serd_env_expand(env, curie)); + assert(!serd_env_expand_curie(NULL, SERD_EMPTY_STRING())); + assert(!serd_env_expand_curie(NULL, SERD_STRING("what:ever"))); + assert(!serd_env_expand_curie(env, SERD_STRING("eg.1:foo"))); + assert(!serd_env_expand_curie(env, SERD_STRING("nocolon"))); serd_env_free(env); - serd_node_free(curie); } static void @@ -265,44 +261,12 @@ test_expand_blank(void) SerdNode* const blank = serd_new_blank(SERD_STRING("b1")); SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); - assert(!serd_env_expand(env, blank)); + assert(!serd_env_expand_node(env, blank)); serd_env_free(env); serd_node_free(blank); } -static void -test_qualify(void) -{ - static const SerdStringView eg = SERD_STRING(NS_EG); - - SerdNodes* const nodes = serd_nodes_new(); - - const SerdNode* const name = serd_nodes_string(nodes, SERD_STRING("eg")); - const SerdNode* const c1 = serd_nodes_curie(nodes, SERD_STRING("eg:foo")); - - const SerdNode* const u1 = - serd_nodes_uri(nodes, SERD_STRING("http://example.org/foo")); - - const SerdNode* const u2 = - serd_nodes_uri(nodes, SERD_STRING("http://drobilla.net/bar")); - - SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); - - assert(!serd_env_set_prefix(env, serd_node_string_view(name), eg)); - - assert(!serd_env_expand(env, name)); - - SerdNode* const u1_out = serd_env_qualify(env, u1); - assert(serd_node_equals(u1_out, c1)); - serd_node_free(u1_out); - - assert(!serd_env_qualify(env, u2)); - - serd_env_free(env); - serd_nodes_free(nodes); -} - static void test_equals(void) { @@ -355,7 +319,6 @@ main(void) test_expand_curie(); test_expand_bad_curie(); test_expand_blank(); - test_qualify(); test_equals(); return 0; } diff --git a/test/test_node.c b/test/test_node.c index 1775a669..8de81e08 100644 --- a/test/test_node.c +++ b/test/test_node.c @@ -422,10 +422,6 @@ test_node_equals(void) assert(serd_node_equals(lhs, lhs)); assert(!serd_node_equals(lhs, rhs)); - SerdNode* const qnode = serd_new_curie(SERD_STRING("foo:bar")); - assert(!serd_node_equals(lhs, qnode)); - serd_node_free(qnode); - assert(!serd_node_copy(NULL)); serd_node_free(lhs); diff --git a/test/test_nodes.c b/test/test_nodes.c index 9605f3b1..7e67eb30 100644 --- a/test/test_nodes.c +++ b/test/test_nodes.c @@ -149,24 +149,6 @@ test_uri(void) serd_nodes_free(nodes); } -static void -test_curie(void) -{ - static const SerdStringView string = SERD_STRING("eg:name"); - - SerdNodes* const nodes = serd_nodes_new(); - const SerdNode* const node = serd_nodes_curie(nodes, string); - - assert(node); - assert(serd_node_type(node) == SERD_CURIE); - assert(!serd_node_datatype(node)); - assert(!serd_node_language(node)); - assert(serd_node_length(node) == string.len); - assert(!strcmp(serd_node_string(node), string.buf)); - - serd_nodes_free(nodes); -} - static void test_blank(void) { @@ -228,7 +210,6 @@ main(void) test_plain_literal(); test_typed_literal(); test_uri(); - test_curie(); test_blank(); test_deref(); test_get(); diff --git a/test/test_overflow.c b/test/test_overflow.c index 02b71008..d94d7e90 100644 --- a/test/test_overflow.c +++ b/test/test_overflow.c @@ -196,6 +196,10 @@ test_turtle_overflow(void) "@base .\n" " .", + // NOLINTNEXTLINE(bugprone-suspicious-missing-comma) + "@base .\n" + " .", + NULL, }; diff --git a/test/test_writer.c b/test/test_writer.c index 0ced87d6..c9a77354 100644 --- a/test/test_writer.c +++ b/test/test_writer.c @@ -263,7 +263,8 @@ test_write_empty_syntax(void) const SerdNode* p = serd_nodes_uri(nodes, SERD_STRING("http://example.org/p")); - const SerdNode* o = serd_nodes_curie(nodes, SERD_STRING("eg:o")); + const SerdNode* o = + serd_nodes_uri(nodes, SERD_STRING("http://example.org/o")); SerdBuffer buffer = {NULL, 0}; SerdByteSink* byte_sink = serd_byte_sink_new_buffer(&buffer); @@ -311,6 +312,7 @@ test_write_bad_uri(void) const SerdStatus st = serd_sink_write(serd_writer_sink(writer), 0u, s, p, rel, NULL); + assert(st); assert(st == SERD_ERR_BAD_ARG); -- cgit v1.2.1