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 | |
parent | 8c67f9eba47d30913749e607c440b170a5cbd804 (diff) | |
download | serd-3a4bd5f1b31cb5c1522d9e6c7222414342682467.tar.gz serd-3a4bd5f1b31cb5c1522d9e6c7222414342682467.tar.bz2 serd-3a4bd5f1b31cb5c1522d9e6c7222414342682467.zip |
[WIP] Remove SERD_CURIE node datatype entirely
-rw-r--r-- | include/serd/env.h | 39 | ||||
-rw-r--r-- | include/serd/node.h | 16 | ||||
-rw-r--r-- | src/env.c | 99 | ||||
-rw-r--r-- | src/env.h | 10 | ||||
-rw-r--r-- | src/node.c | 8 | ||||
-rw-r--r-- | src/read_turtle.c | 10 | ||||
-rw-r--r-- | src/statement.c | 3 | ||||
-rw-r--r-- | src/writer.c | 55 | ||||
-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 |
13 files changed, 119 insertions, 220 deletions
diff --git a/include/serd/env.h b/include/serd/env.h index bfbda520..b4f908a9 100644 --- a/include/serd/env.h +++ b/include/serd/env.h @@ -61,32 +61,47 @@ serd_env_set_prefix(SerdEnv* ZIX_NONNULL env, SerdStringView uri); /** - Qualify `uri` into a CURIE if possible. + Qualify `uri` into a prefix and suffix (like a CURIE) if possible. - Returns null if `uri` can not be qualified (usually because no corresponding - prefix is defined). + @param env Environment with prefixes to use. + + @param uri URI to qualify. + + @param prefix On success, pointed to a prefix string slice, which is only + valid until the next time `env` is mutated. + + @param suffix On success, pointed to a suffix string slice, which is only + valid until the next time `env` is mutated. + + @return #SERD_SUCCESS, or #SERD_FAILURE if `uri` can not be qualified with + `env`. */ -SERD_API SerdNode* ZIX_ALLOCATED -serd_env_qualify(const SerdEnv* ZIX_NULLABLE env, - const SerdNode* ZIX_NULLABLE uri); +SERD_API SerdStatus +serd_env_qualify(const SerdEnv* ZIX_NULLABLE env, + SerdStringView uri, + SerdStringView* ZIX_NONNULL prefix, + SerdStringView* ZIX_NONNULL suffix); /** - Expand `node`, which must be a CURIE or URI, to a full URI. + Expand `curie` to an absolute URI if possible. + + For example, if `env` has the prefix "rdf" set to + <http://www.w3.org/1999/02/22-rdf-syntax-ns#>, then calling this with curie + "rdf:type" will produce <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>. Returns null if `node` can not be expanded. */ SERD_API SerdNode* ZIX_ALLOCATED -serd_env_expand(const SerdEnv* ZIX_NULLABLE env, - const SerdNode* ZIX_NULLABLE node); +serd_env_expand_curie(const SerdEnv* ZIX_NULLABLE env, SerdStringView curie); /** - Expand `node`, which must be a CURIE or URI, to a full URI. + Expand `node` to an absolute URI if possible. Returns null if `node` can not be expanded. */ SERD_API SerdNode* ZIX_ALLOCATED -serd_env_expand_node(const SerdEnv* ZIX_NULLABLE env, - const SerdNode* ZIX_NONNULL node); +serd_env_expand_node(const SerdEnv* ZIX_NULLABLE env, + const SerdNode* ZIX_NULLABLE node); /// Write all prefixes in `env` to `sink` SERD_API SerdStatus diff --git a/include/serd/node.h b/include/serd/node.h index 90ecde71..b0b14a24 100644 --- a/include/serd/node.h +++ b/include/serd/node.h @@ -69,14 +69,6 @@ typedef enum { SERD_URI = 2, /** - CURIE, a shortened URI. - - Value is an unquoted CURIE string relative to the current environment, - e.g. "rdf:type". @see [CURIE Syntax 1.0](http://www.w3.org/TR/curie) - */ - SERD_CURIE = 3, - - /** A blank node. A blank node is a resource that has no URI. The identifier of a blank @@ -86,7 +78,7 @@ typedef enum { @see [RDF 1.1 Turtle](http://www.w3.org/TR/turtle/#grammar-production-BLANK_NODE_LABEL) */ - SERD_BLANK = 4, + SERD_BLANK = 3, /** A variable node. @@ -99,7 +91,7 @@ typedef enum { @see [SPARQL 1.1 Query Language](https://www.w3.org/TR/sparql11-query/#rVar) */ - SERD_VARIABLE = 5, + SERD_VARIABLE = 4, } SerdNodeType; /// Node flags, which ORed together make a #SerdNodeFlags @@ -165,10 +157,6 @@ serd_new_literal(SerdStringView string, SERD_API SerdNode* ZIX_ALLOCATED serd_new_blank(SerdStringView string); -/// Create a new CURIE node -SERD_API SerdNode* ZIX_ALLOCATED -serd_new_curie(SerdStringView string); - /** Create a new URI node from a parsed URI. */ @@ -218,51 +218,29 @@ serd_env_set_prefix(SerdEnv* const env, return SERD_SUCCESS; } -bool -serd_env_qualify_in_place(const SerdEnv* const env, - const SerdNode* const uri, - const SerdNode** const prefix, - SerdStringView* const suffix) +SerdStatus +serd_env_qualify(const SerdEnv* const env, + const SerdStringView uri, + SerdStringView* const prefix, + SerdStringView* const suffix) { for (size_t i = 0; i < env->n_prefixes; ++i) { - const SerdNode* const prefix_uri = env->prefixes[i].uri; - if (uri->length >= prefix_uri->length) { + const SerdNode* const prefix_uri = env->prefixes[i].uri; + const size_t prefix_uri_len = serd_node_length(prefix_uri); + if (uri.data && uri.length >= prefix_uri_len) { const char* prefix_str = serd_node_string(prefix_uri); - const char* uri_str = serd_node_string(uri); + const char* uri_str = uri.data; - if (!strncmp(uri_str, prefix_str, prefix_uri->length)) { - *prefix = env->prefixes[i].name; - suffix->data = uri_str + prefix_uri->length; - suffix->length = uri->length - prefix_uri->length; - return true; + if (!strncmp(uri_str, prefix_str, prefix_uri_len)) { + *prefix = serd_node_string_view(env->prefixes[i].name); + suffix->data = uri_str + prefix_uri_len; + suffix->length = uri.length - prefix_uri_len; + return SERD_SUCCESS; } } } - return false; -} -SerdNode* -serd_env_qualify(const SerdEnv* const env, const SerdNode* const uri) -{ - if (!env || !uri) { - return NULL; - } - - const SerdNode* prefix = NULL; - SerdStringView suffix = {NULL, 0}; - if (serd_env_qualify_in_place(env, uri, &prefix, &suffix)) { - const size_t prefix_len = serd_node_length(prefix); - const size_t length = prefix_len + 1 + suffix.length; - SerdNode* node = serd_node_malloc(length, 0, SERD_CURIE); - - memcpy(serd_node_buffer(node), serd_node_string(prefix), prefix_len); - serd_node_buffer(node)[prefix_len] = ':'; - memcpy(serd_node_buffer(node) + 1 + prefix_len, suffix.data, suffix.length); - node->length = length; - return node; - } - - return NULL; + return SERD_FAILURE; } SerdStatus @@ -280,14 +258,15 @@ serd_env_expand_in_place(const SerdEnv* const env, const size_t name_len = (size_t)(colon - str); const SerdPrefix* const prefix = serd_env_find(env, str, name_len); - if (prefix) { - uri_prefix->data = serd_node_string(prefix->uri); - uri_prefix->length = prefix->uri ? prefix->uri->length : 0; - uri_suffix->data = colon + 1; - uri_suffix->length = curie.length - name_len - 1; - return SERD_SUCCESS; + if (!prefix || !prefix->uri) { + return SERD_BAD_CURIE; } - return SERD_BAD_CURIE; + + uri_prefix->data = serd_node_string(prefix->uri); + uri_prefix->length = prefix->uri ? prefix->uri->length : 0; + uri_suffix->data = colon + 1; + uri_suffix->length = curie.length - name_len - 1; + return SERD_SUCCESS; } static SerdNode* @@ -298,29 +277,33 @@ expand_uri(const SerdEnv* env, const SerdNode* node) return serd_new_resolved_uri(serd_node_string_view(node), env->base_uri); } -static SerdNode* -expand_curie(const SerdEnv* env, const SerdNode* node) +SerdNode* +serd_env_expand_curie(const SerdEnv* const env, const SerdStringView curie) { - assert(serd_node_type(node) == SERD_CURIE); + if (!env) { + return NULL; + } - SerdStringView prefix; - SerdStringView suffix; - if (serd_env_expand_in_place( - env, serd_node_string_view(node), &prefix, &suffix)) { + SerdStringView prefix = serd_empty_string(); + SerdStringView suffix = serd_empty_string(); + SerdStatus st = serd_env_expand_in_place(env, curie, &prefix, &suffix); + if (st || !prefix.data || !suffix.data) { return NULL; } - const size_t len = prefix.length + suffix.length; - SerdNode* ret = serd_node_malloc(len, 0, SERD_URI); - char* buf = serd_node_buffer(ret); + const size_t len = prefix.length + suffix.length; + SerdNode* const ret = serd_node_malloc(len, 0U, SERD_URI); + if (ret) { + char* const string = serd_node_buffer(ret); + memcpy(string, prefix.data, prefix.length); + memcpy(string + prefix.length, suffix.data, suffix.length); + } - snprintf(buf, len + 1, "%s%s", prefix.data, suffix.data); - ret->length = len; return ret; } SerdNode* -serd_env_expand(const SerdEnv* env, const SerdNode* node) +serd_env_expand_node(const SerdEnv* const env, const SerdNode* const node) { if (!env || !node) { return NULL; @@ -331,8 +314,6 @@ serd_env_expand(const SerdEnv* env, const SerdNode* node) break; case SERD_URI: return expand_uri(env, node); - case SERD_CURIE: - return expand_curie(env, node); case SERD_BLANK: case SERD_VARIABLE: break; @@ -5,21 +5,11 @@ #define SERD_SRC_ENV_H #include "serd/env.h" -#include "serd/node.h" #include "serd/status.h" #include "serd/string_view.h" #include "serd/uri.h" #include "zix/attributes.h" -#include <stdbool.h> - -/// Qualify `uri` into a CURIE if possible -bool -serd_env_qualify_in_place(const SerdEnv* env, - const SerdNode* uri, - const SerdNode** prefix, - SerdStringView* suffix); - /** Return the URI for the prefix with the given name. @@ -291,12 +291,6 @@ serd_new_blank(const SerdStringView str) return serd_new_token(SERD_BLANK, str); } -SerdNode* -serd_new_curie(const SerdStringView str) -{ - return serd_new_token(SERD_CURIE, str); -} - ExessResult serd_node_get_value_as(const SerdNode* const node, const ExessDatatype value_type, @@ -738,7 +732,7 @@ serd_node_datatype(const SerdNode* const node) } const SerdNode* const datatype = serd_node_meta_c(node); - assert(datatype->type == SERD_URI || datatype->type == SERD_CURIE); + assert(datatype->type == SERD_URI); return datatype; } diff --git a/src/read_turtle.c b/src/read_turtle.c index fa7b9731..042393e0 100644 --- a/src/read_turtle.c +++ b/src/read_turtle.c @@ -513,7 +513,7 @@ read_turtle_iri(SerdReader* const reader, return read_IRIREF(reader, dest); } - if (!(*dest = push_node(reader, SERD_CURIE, "", 0))) { + if (!(*dest = push_node(reader, SERD_LITERAL, "", 0))) { return SERD_BAD_STACK; } @@ -567,7 +567,7 @@ read_verb(SerdReader* reader, SerdNode** const dest) /* Either a qname, or "a". Read the prefix first, and if it is in fact "a", produce that instead. */ - if (!(*dest = push_node(reader, SERD_CURIE, "", 0))) { + if (!(*dest = push_node(reader, SERD_URI, "", 0))) { return SERD_BAD_STACK; } @@ -671,7 +671,7 @@ read_named_object(SerdReader* const reader, Deal with this here by trying to read a prefixed node, then if it turns out to actually be "true" or "false", switch it to a boolean literal. */ - if (!(*dest = push_node(reader, SERD_CURIE, "", 0))) { + if (!(*dest = push_node(reader, SERD_URI, "", 0))) { return SERD_BAD_STACK; } @@ -935,7 +935,9 @@ read_turtle_subject(SerdReader* const reader, st = read_BLANK_NODE_LABEL(reader, dest, &ate_dot); break; default: - TRY(st, read_turtle_iri(reader, dest, &ate_dot)); + if ((st = read_turtle_iri(reader, dest, &ate_dot))) { + return r_err(reader, st, "expected subject"); + } } if (ate_dot) { diff --git a/src/statement.c b/src/statement.c index 9d2d4229..418e999e 100644 --- a/src/statement.c +++ b/src/statement.c @@ -17,8 +17,7 @@ static bool is_resource(const SerdNode* const node) { const SerdNodeType type = node ? serd_node_type(node) : (SerdNodeType)0; - return type == SERD_URI || type == SERD_CURIE || type == SERD_BLANK || - type == SERD_VARIABLE; + return type == SERD_URI || type == SERD_BLANK || type == SERD_VARIABLE; } bool diff --git a/src/writer.c b/src/writer.c index 05be0500..31daa71c 100644 --- a/src/writer.c +++ b/src/writer.c @@ -840,24 +840,23 @@ write_uri_node(SerdWriter* const writer, const SerdNode* const node, const SerdField field) { - SerdStatus st = SERD_SUCCESS; - const char* const node_str = serd_node_string(node); - const bool has_scheme = serd_uri_string_has_scheme(node_str); + SerdStatus st = SERD_SUCCESS; + const SerdStringView string = serd_node_string_view(node); + const bool has_scheme = serd_uri_string_has_scheme(string.data); if (supports_abbrev(writer)) { - const SerdNode* prefix_node = NULL; - SerdStringView suffix = {NULL, 0}; - if (field == SERD_PREDICATE && !strcmp(node_str, NS_RDF "type")) { + if (field == SERD_PREDICATE && !strcmp(string.data, NS_RDF "type")) { return esink("a", 1, writer); } - if (!strcmp(node_str, NS_RDF "nil")) { + if (!strcmp(string.data, NS_RDF "nil")) { return esink("()", 2, writer); } + SerdStringView prefix = {NULL, 0}; + SerdStringView suffix = {NULL, 0}; if (has_scheme && !(writer->flags & SERD_WRITE_UNQUALIFIED) && - serd_env_qualify_in_place(writer->env, node, &prefix_node, &suffix)) { - const SerdStringView prefix = serd_node_string_view(prefix_node); + !serd_env_qualify(writer->env, string, &prefix, &suffix)) { TRY(st, write_lname(writer, prefix.data, prefix.length)); TRY(st, esink(":", 1, writer)); return write_lname(writer, suffix.data, suffix.length); @@ -868,45 +867,14 @@ write_uri_node(SerdWriter* const writer, !serd_env_base_uri(writer->env)) { return w_err(writer, SERD_BAD_ARG, - "URI reference <%s> in unsupported syntax", - node_str); + "syntax does not support URI reference <%s>", + string.data); } return write_full_uri_node(writer, node); } SERD_NODISCARD static SerdStatus -write_curie(SerdWriter* const writer, const SerdNode* const node) -{ - const char* const node_str = serd_node_string(node); - SerdStringView prefix = {NULL, 0}; - SerdStringView suffix = {NULL, 0}; - SerdStatus st = SERD_SUCCESS; - - // In fast-and-loose Turtle/TriG mode CURIEs are simply passed through - const bool fast = - (writer->flags & (SERD_WRITE_UNQUALIFIED | SERD_WRITE_UNRESOLVED)); - - if (!supports_abbrev(writer) || !fast) { - const SerdStringView curie = serd_node_string_view(node); - if ((st = serd_env_expand_in_place(writer->env, curie, &prefix, &suffix))) { - return w_err(writer, st, "undefined namespace prefix '%s'", node_str); - } - } - - if (!supports_abbrev(writer)) { - TRY(st, esink("<", 1, writer)); - TRY(st, ewrite_uri(writer, prefix.data, prefix.length)); - TRY(st, ewrite_uri(writer, suffix.data, suffix.length)); - TRY(st, esink(">", 1, writer)); - } else { - TRY(st, write_lname(writer, node_str, node->length)); - } - - return st; -} - -SERD_NODISCARD static SerdStatus write_blank(SerdWriter* const writer, const SerdNode* node, const SerdField field, @@ -974,9 +942,6 @@ write_node(SerdWriter* const writer, case SERD_URI: st = write_uri_node(writer, node, field); break; - case SERD_CURIE: - st = write_curie(writer, node); - break; case SERD_BLANK: st = write_blank(writer, node, field, flags); break; 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); |