diff options
author | David Robillard <d@drobilla.net> | 2021-07-11 18:44:03 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | 3a4bd5f1b31cb5c1522d9e6c7222414342682467 (patch) | |
tree | f4d7f87260cdcdd39ad4051c113cadf149c4fa43 /test | |
parent | 8c67f9eba47d30913749e607c440b170a5cbd804 (diff) | |
download | serd-3a4bd5f1b31cb5c1522d9e6c7222414342682467.tar.gz serd-3a4bd5f1b31cb5c1522d9e6c7222414342682467.tar.bz2 serd-3a4bd5f1b31cb5c1522d9e6c7222414342682467.zip |
[WIP] Remove SERD_CURIE node datatype entirely
Diffstat (limited to 'test')
-rw-r--r-- | test/test_env.c | 74 | ||||
-rw-r--r-- | test/test_node.c | 4 | ||||
-rw-r--r-- | test/test_overflow.c | 4 | ||||
-rw-r--r-- | test/test_statement.c | 14 | ||||
-rw-r--r-- | test/test_writer.c | 3 |
5 files changed, 32 insertions, 67 deletions
diff --git a/test/test_env.c b/test/test_env.c index d45f2ef6..33e41af4 100644 --- a/test/test_env.c +++ b/test/test_env.c @@ -59,20 +59,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 @@ -150,7 +145,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); @@ -166,7 +161,7 @@ test_expand_bad_uri_datatype(void) 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); @@ -179,9 +174,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/")); @@ -200,7 +195,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); @@ -215,7 +210,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); @@ -227,30 +222,31 @@ test_expand_curie(void) const SerdStringView name = serd_string("eg.1"); 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 @@ -259,42 +255,13 @@ 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) -{ - const SerdStringView eg = serd_string(NS_EG); - - SerdNode* const name = serd_new_string(serd_string("eg")); - SerdNode* const c1 = serd_new_curie(serd_string("eg:foo")); - SerdNode* const u1 = serd_new_uri(serd_string("http://example.org/foo")); - SerdNode* const u2 = serd_new_uri(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_node_free(u2); - serd_node_free(u1); - serd_node_free(c1); - serd_node_free(name); -} - -static void test_equals(void) { const SerdStringView name1 = serd_string("n1"); @@ -346,7 +313,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 7bdc83ec..07ea4973 100644 --- a/test/test_node.c +++ b/test/test_node.c @@ -414,10 +414,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_overflow.c b/test/test_overflow.c index 9b1a6fb7..6272e807 100644 --- a/test/test_overflow.c +++ b/test/test_overflow.c @@ -195,6 +195,10 @@ test_turtle_overflow(void) "@base <http://example.org/ns/test> .\n" "<http://example.org/s> <http://example.org/p> <rel> .", + // NOLINTNEXTLINE(bugprone-suspicious-missing-comma) + "@base <http://example.org/ns/test> .\n" + "<http://example.org/s> <http://example.org/p> <rel> .", + NULL, }; diff --git a/test/test_statement.c b/test/test_statement.c index 844955f8..d70542f1 100644 --- a/test/test_statement.c +++ b/test/test_statement.c @@ -17,21 +17,19 @@ static void test_new(void) { SerdNode* const u = serd_new_uri(serd_string(NS_EG "s")); - SerdNode* const c = serd_new_curie(serd_string("eg:c")); SerdNode* const b = serd_new_blank(serd_string("b0")); SerdNode* const l = serd_new_string(serd_string("str")); - assert(!serd_statement_new(c, b, u, NULL, NULL)); - assert(!serd_statement_new(l, c, u, NULL, NULL)); - assert(!serd_statement_new(l, u, c, u, NULL)); - assert(!serd_statement_new(u, l, c, NULL, NULL)); - assert(!serd_statement_new(u, l, u, u, NULL)); - assert(!serd_statement_new(u, l, u, u, NULL)); + assert(!serd_statement_new(u, b, u, NULL, NULL)); + assert(!serd_statement_new(l, u, u, NULL, NULL)); + assert(!serd_statement_new(l, u, b, u, NULL)); + assert(!serd_statement_new(u, l, b, NULL, NULL)); + assert(!serd_statement_new(u, l, b, u, NULL)); + assert(!serd_statement_new(u, u, u, l, NULL)); serd_node_free(l); serd_node_free(b); serd_node_free(u); - serd_node_free(c); } static void diff --git a/test/test_writer.c b/test/test_writer.c index ee602044..655f79e9 100644 --- a/test/test_writer.c +++ b/test/test_writer.c @@ -305,7 +305,7 @@ test_write_empty_syntax(void) SerdNode* s = serd_new_uri(serd_string("http://example.org/s")); SerdNode* p = serd_new_uri(serd_string("http://example.org/p")); - SerdNode* o = serd_new_curie(serd_string("eg:o")); + SerdNode* o = serd_new_uri(serd_string("http://example.org/o")); SerdBuffer buffer = {NULL, 0}; SerdOutputStream output = serd_open_output_buffer(&buffer); @@ -423,6 +423,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_BAD_ARG); |