diff options
author | David Robillard <d@drobilla.net> | 2011-12-25 07:09:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-12-25 07:09:29 +0000 |
commit | f3c95977f6c71b936e98f41c321265835c4fd623 (patch) | |
tree | ab275f04a3dd592c5572687230ba25f422359a36 | |
parent | b2effabfc5d02bab56bae00e7aa138a42bd7d3b6 (diff) | |
download | serd-f3c95977f6c71b936e98f41c321265835c4fd623.tar.gz serd-f3c95977f6c71b936e98f41c321265835c4fd623.tar.bz2 serd-f3c95977f6c71b936e98f41c321265835c4fd623.zip |
Near 100% branch coverage.
git-svn-id: http://svn.drobilla.net/serd/trunk@277 490d8e77-9747-427b-9fa3-0b8f29cee8a0
45 files changed, 375 insertions, 132 deletions
@@ -111,8 +111,6 @@ serd_env_add(SerdEnv* env, const SerdNode* name, const SerdNode* uri) { - assert(name && uri); - assert(name->n_bytes == strlen((const char*)name->buf)); SerdPrefix* const prefix = serd_env_find(env, name->buf, name->n_bytes); if (prefix) { SerdNode old_prefix_uri = prefix->uri; @@ -132,7 +130,7 @@ serd_env_set_prefix(SerdEnv* env, const SerdNode* name, const SerdNode* uri_node) { - if (!name->buf || !uri_node->buf || uri_node->type != SERD_URI) { + if (!name->buf || uri_node->type != SERD_URI) { return SERD_ERR_BAD_ARG; } else if (serd_uri_string_has_scheme(uri_node->buf)) { // Set prefix to absolute URI @@ -165,15 +163,9 @@ serd_env_set_prefix_from_strings(SerdEnv* env, } static inline bool -is_nameStartChar(const uint8_t c) -{ - return is_alpha(c) || is_digit(c) || c == '_'; -} - -static inline bool is_nameChar(const uint8_t c) { - return is_nameStartChar(c) || c == '.' || c == 0xB7; + return is_alpha(c) || is_digit(c) || c == '_'; } /** @@ -183,15 +175,12 @@ is_nameChar(const uint8_t c) static inline bool is_name(const uint8_t* buf, size_t len) { - if (is_nameStartChar(buf[0])) { - for (size_t i = 1; i < len; ++i) { - if (!is_nameChar(buf[i])) { - return false; - } + for (size_t i = 0; i < len; ++i) { + if (!is_nameChar(buf[i])) { + return false; } - return true; } - return false; + return true; } SERD_API @@ -248,23 +237,25 @@ SerdNode serd_env_expand_node(const SerdEnv* env, const SerdNode* node) { - if (node->type == SERD_CURIE) { + switch (node->type) { + case SERD_CURIE: { SerdChunk prefix; SerdChunk suffix; - serd_env_expand(env, node, &prefix, &suffix); - SerdNode ret = { NULL, - prefix.len + suffix.len + 1, - prefix.len + suffix.len, // FIXME: UTF-8 - 0, - SERD_URI }; + if (serd_env_expand(env, node, &prefix, &suffix)) { + return SERD_NODE_NULL; + } + const size_t len = prefix.len + suffix.len; // FIXME: UTF-8? + SerdNode ret = { NULL, len, len, 0, SERD_URI }; ret.buf = malloc(ret.n_bytes + 1); snprintf((char*)ret.buf, ret.n_bytes + 1, "%s%s", prefix.buf, suffix.buf); return ret; - } else if (node->type == SERD_URI) { + } + case SERD_URI: { SerdURI ignored; return serd_node_new_uri_from_node(node, &env->base_uri, &ignored); - } else { + } + default: return SERD_NODE_NULL; } } @@ -37,7 +37,7 @@ SERD_API SerdNode serd_node_copy(const SerdNode* node) { - if (!node || !node->buf) { + if (!node) { return SERD_NODE_NULL; } @@ -93,7 +93,9 @@ serd_node_new_uri_from_node(const SerdNode* uri_node, const SerdURI* base, SerdURI* out) { - return serd_node_new_uri_from_string(uri_node->buf, base, out); + return (uri_node->type == SERD_URI) + ? serd_node_new_uri_from_string(uri_node->buf, base, out) + : SERD_NODE_NULL; } SERD_API @@ -104,13 +106,10 @@ serd_node_new_uri_from_string(const uint8_t* str, { if (!str || str[0] == '\0') { return serd_node_new_uri(base, NULL, out); // Empty URI => Base URI - } else { - SerdURI uri; - if (!serd_uri_parse(str, &uri)) { - return serd_node_new_uri(&uri, base, out); // Resolve/Serialise - } } - return SERD_NODE_NULL; + SerdURI uri; + serd_uri_parse(str, &uri); + return serd_node_new_uri(&uri, base, out); // Resolve/Serialise } SERD_API @@ -134,7 +133,9 @@ serd_node_new_uri(const SerdURI* uri, const SerdURI* base, SerdURI* out) node.n_bytes = actual_len; node.n_chars = actual_len; - serd_uri_parse(buf, out); // TODO: cleverly avoid double parse + if (out) { + serd_uri_parse(buf, out); // TODO: cleverly avoid double parse + } return node; } @@ -177,7 +178,7 @@ serd_node_new_decimal(double d, unsigned frac_digits) unsigned i = 0; // Skip trailing zeros - for (; i < frac_digits && (frac % 10 == 0); ++i, --s, frac /= 10) {} + for (; i < frac_digits - 1 && !(frac % 10); ++i, --s, frac /= 10) {} node.n_bytes = node.n_chars = (s - buf) + 1; diff --git a/src/reader.c b/src/reader.c index fbc7a711..44f03997 100644 --- a/src/reader.c +++ b/src/reader.c @@ -112,7 +112,6 @@ warn(SerdReader* reader, const char* fmt, ...) static inline bool page(SerdReader* reader) { - assert(reader->from_file); reader->read_head = 0; const size_t n_read = fread(reader->read_buf, 1, SERD_PAGE_SIZE, reader->fd); if (n_read == 0) { @@ -143,8 +142,7 @@ eat_byte_safe(SerdReader* reader, const uint8_t byte) } if (reader->from_file && (reader->read_head == SERD_PAGE_SIZE)) { - TRY_RET(page(reader)); - assert(reader->read_head < SERD_PAGE_SIZE); + page(reader); } return byte; } @@ -220,7 +218,6 @@ push_byte(SerdReader* reader, Ref ref, const uint8_t c) if (!(c & 0x80)) { // Starts with 0 bit, start of new character ++node->n_chars; } - assert(node->n_bytes >= node->n_chars); *(s - 1) = c; *s = '\0'; } @@ -233,8 +230,7 @@ append_string(SerdReader* reader, Ref ref, const uint8_t* suffix, size_t len) #endif serd_stack_push(&reader->stack, len); SerdNode* const node = deref(reader, ref); - assert(node->n_bytes >= node->n_chars); - uint8_t* const buf = (uint8_t*)node + sizeof(SerdNode); + uint8_t* const buf = (uint8_t*)node + sizeof(SerdNode); memcpy(buf + node->n_bytes, suffix, len + 1); node->n_bytes += len; node->n_chars += len; @@ -266,7 +262,6 @@ emit_statement(SerdReader* reader, SerdStatementFlags* flags, Ref g, Ref s, Ref p, Ref o, Ref d, Ref l) { - assert(s && p && o); bool ret = !reader->statement_sink || !reader->statement_sink(reader->handle, *flags, deref(reader, g), @@ -302,7 +297,9 @@ read_hex_escape(SerdReader* reader, unsigned length, Ref dest) { uint8_t buf[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; for (unsigned i = 0; i < length; ++i) { - buf[i] = read_hex(reader); + if (!(buf[i] = read_hex(reader))) { + return false; + } } uint32_t c; @@ -478,11 +475,11 @@ read_character(SerdReader* reader, Ref dest) if (c == '\0') { error(reader, "unexpected end of file\n", c); return SERD_ERR_BAD_SYNTAX; - } else if (c < 0x20) {// || c == 0x7F) { + } else if (c < 0x20) { return bad_char(reader, dest, "unexpected control character 0x%X\n", eat_byte_safe(reader, c)); - } else if (reader->syntax == SERD_NTRIPLES || !(c & 0x80)) { + } else if (!(c & 0x80)) { push_byte(reader, dest, eat_byte_safe(reader, c)); return SERD_SUCCESS; } else { @@ -850,11 +847,12 @@ read_number(SerdReader* reader, Ref* dest, Ref* datatype) TRY_THROW(read_0_9(reader, ref, true)); } else { // all other cases ::= ( '-' | '+' ) [0-9]+ ( . )? ( [0-9]+ )? ... - TRY_THROW(read_0_9(reader, ref, true)); + assert(is_digit(c)); + read_0_9(reader, ref, true); if ((c = peek_byte(reader)) == '.') { has_decimal = true; push_byte(reader, ref, eat_byte_safe(reader, c)); - TRY_THROW(read_0_9(reader, ref, false)); + read_0_9(reader, ref, false); } } c = peek_byte(reader); @@ -925,11 +923,11 @@ except: } inline static bool -is_object_end(const uint8_t c) +is_token_end(const uint8_t c) { switch (c) { case 0x9: case 0xA: case 0xD: case 0x20: case '\0': - case '#': case '.': case ';': + case '#': case '.': case ';': case '<': return true; default: return false; @@ -950,8 +948,8 @@ read_verb(SerdReader* reader, Ref* dest) */ *dest = read_prefixName(reader, 0); node = deref(reader, *dest); - if (node && is_object_end(peek_byte(reader)) && - ((node->n_bytes == 1 && node->buf[0] == 'a'))) { + if (node && node->n_bytes == 1 && node->buf[0] == 'a' + && is_token_end(peek_byte(reader))) { pop_node(reader, *dest); return (*dest = push_node(reader, SERD_URI, NS_RDF "type", 47)); } else { @@ -1106,7 +1104,7 @@ read_object(SerdReader* reader, ReadContext ctx) */ o = read_prefixName(reader, 0); node = deref(reader, o); - if (node && is_object_end(peek_byte(reader)) && + if (node && is_token_end(peek_byte(reader)) && ((node->n_bytes == 4 && !memcmp(node->buf, "true", 4)) || (node->n_bytes == 5 && !memcmp(node->buf, "false", 5)))) { node->type = SERD_LITERAL; @@ -1154,14 +1152,14 @@ read_objectList(SerdReader* reader, ReadContext ctx, bool blank) // Spec: [7] predicateObjectList ::= verb objectList // (';' verb objectList)* (';')? -// Impl: [7] predicateObjectList ::= verb ws+ objectList +// Impl: [7] predicateObjectList ::= verb ws* objectList // (ws* ';' ws* verb ws+ objectList)* (';')? static bool read_predicateObjectList(SerdReader* reader, ReadContext ctx, bool blank) { Ref predicate = 0; TRY_RET(read_verb(reader, &predicate)); - TRY_THROW(read_ws_plus(reader)); + read_ws_star(reader); ctx.predicate = predicate; TRY_THROW(read_objectList(reader, ctx, blank)); pop_node(reader, predicate); @@ -1176,7 +1174,7 @@ read_predicateObjectList(SerdReader* reader, ReadContext ctx, bool blank) default: TRY_THROW(read_verb(reader, &predicate)); ctx.predicate = predicate; - TRY_THROW(read_ws_plus(reader)); + read_ws_star(reader); TRY_THROW(read_objectList(reader, ctx, blank)); pop_node(reader, predicate); predicate = 0; diff --git a/src/serd_internal.h b/src/serd_internal.h index 39f8d503..d81d0b34 100644 --- a/src/serd_internal.h +++ b/src/serd_internal.h @@ -157,10 +157,9 @@ serd_bulk_sink_flush(SerdBulkSink* bsink) static inline void serd_bulk_sink_free(SerdBulkSink* bsink) { - if (bsink) { - serd_bulk_sink_flush(bsink); - free(bsink->buf); - } + serd_bulk_sink_flush(bsink); + free(bsink->buf); + bsink->buf = NULL; } static inline size_t diff --git a/src/string.c b/src/string.c index 40828612..968a20e1 100644 --- a/src/string.c +++ b/src/string.c @@ -30,7 +30,7 @@ serd_strerror(SerdStatus st) case SERD_ERR_BAD_ARG: return (const uint8_t*)"Invalid argument"; case SERD_ERR_NOT_FOUND: return (const uint8_t*)"Not found"; } - return (const uint8_t*)"Success"; // never reached + return (const uint8_t*)"Unknown error code"; // never reached } SERD_API @@ -98,9 +98,6 @@ SerdStatus serd_uri_parse(const uint8_t* utf8, SerdURI* uri) { *uri = SERD_URI_NULL; - assert(uri->path_base.buf == NULL); - assert(uri->path_base.len == 0); - assert(uri->authority.len == 0); const uint8_t* ptr = utf8; @@ -137,7 +134,6 @@ maybe_authority: if (*ptr == '/' && *(ptr + 1) == '/') { ptr += 2; uri->authority.buf = ptr; - assert(uri->authority.len == 0); for (uint8_t c; (c = *ptr) != '\0'; ++ptr) { switch (c) { case '/': goto path; @@ -331,28 +327,18 @@ serd_uri_serialise(const SerdURI* uri, SerdSink sink, void* stream) size_t write_size = 0; #define WRITE(buf, len) \ write_size += len; \ - if (len) { \ - sink((const uint8_t*)buf, len, stream); \ - } -#define WRITE_CHAR(c) WRITE(&(c), 1) -#define WRITE_COMPONENT(prefix, field, suffix) \ - if ((field).len) { \ - for (const uint8_t* c = (const uint8_t*)prefix; *c != '\0'; ++c) { \ - WRITE(c, 1); \ - } \ - WRITE((field).buf, (field).len); \ - for (const uint8_t* c = (const uint8_t*)suffix; *c != '\0'; ++c) { \ - WRITE(c, 1); \ - } \ - } + sink((const uint8_t*)buf, len, stream); - WRITE_COMPONENT("", uri->scheme, ":"); + if (uri->scheme.buf) { + WRITE(uri->scheme.buf, uri->scheme.len); + WRITE(":", 1); + } if (uri->authority.buf) { WRITE("//", 2); WRITE(uri->authority.buf, uri->authority.len); } if (!uri->path.buf) { - WRITE_COMPONENT("", uri->path_base, ""); + WRITE(uri->path_base.buf, uri->path_base.len); } else { const uint8_t* begin = uri->path.buf; const uint8_t* const end = uri->path.buf + uri->path.len; @@ -377,16 +363,19 @@ serd_uri_serialise(const SerdURI* uri, SerdSink sink, void* stream) } else { // Relative path is just query or fragment, append to base URI - WRITE_COMPONENT("", uri->path_base, ""); + WRITE(uri->path_base.buf, uri->path_base.len); } // Write URI suffix WRITE(begin, end - begin); } - WRITE_COMPONENT("?", uri->query, ""); + if (uri->query.buf) { + WRITE("?", 1); + WRITE(uri->query.buf, uri->query.len); + } if (uri->fragment.buf) { // Note uri->fragment.buf includes the leading `#' - WRITE_COMPONENT("", uri->fragment, ""); + WRITE(uri->fragment.buf, uri->fragment.len); } return write_size; } diff --git a/src/writer.c b/src/writer.c index c388188e..a9209f80 100644 --- a/src/writer.c +++ b/src/writer.c @@ -176,12 +176,10 @@ write_text(SerdWriter* writer, TextContext ctx, continue; } -#define READ_BYTE() do { \ - assert(i < n_bytes); \ - in = utf8[i++] & 0x3f; \ - c <<= 6; \ - c |= in; \ - } while (0) +#define READ_BYTE() \ + in = utf8[i++] & 0x3f; \ + c <<= 6; \ + c |= in; switch (size) { case 4: READ_BYTE(); @@ -338,14 +336,13 @@ write_node(SerdWriter* writer, } else if ((writer->style & SERD_STYLE_RESOLVED) && !serd_uri_string_has_scheme(node->buf)) { SerdURI uri; - if (!serd_uri_parse(node->buf, &uri)) { - SerdURI abs_uri; - serd_uri_resolve(&uri, &writer->base_uri, &abs_uri); - sink("<", 1, writer); - serd_uri_serialise(&abs_uri, (SerdSink)sink, writer); - sink(">", 1, writer); - return true; - } + serd_uri_parse(node->buf, &uri); + SerdURI abs_uri; + serd_uri_resolve(&uri, &writer->base_uri, &abs_uri); + sink("<", 1, writer); + serd_uri_serialise(&abs_uri, (SerdSink)sink, writer); + sink(">", 1, writer); + return true; } sink("<", 1, writer); write_text(writer, WRITE_URI, node->buf, node->n_bytes, '>'); @@ -396,7 +393,7 @@ serd_writer_write_statement(SerdWriter* writer, } sink(" .\n", 3, writer); return SERD_SUCCESS; - case SERD_TURTLE: + default: break; } if (serd_node_equals(subject, &writer->context.subject)) { @@ -428,9 +425,8 @@ serd_writer_write_statement(SerdWriter* writer, } } else { if (writer->context.subject.type) { - if (writer->indent > 0) { - --writer->indent; - } + assert(writer->indent > 0); + --writer->indent; if (serd_stack_is_empty(&writer->anon_stack)) { serd_writer_write_delim(writer, '.'); serd_writer_write_delim(writer, '\n'); @@ -460,8 +456,7 @@ serd_writer_write_statement(SerdWriter* writer, FIELD_OBJECT, flags); } - if (writer->syntax != SERD_NTRIPLES - && ((flags & SERD_ANON_S_BEGIN) || (flags & SERD_ANON_O_BEGIN))) { + if ((flags & SERD_ANON_S_BEGIN) || (flags & SERD_ANON_O_BEGIN)) { WriteContext* ctx = (WriteContext*)serd_stack_push( &writer->anon_stack, sizeof(WriteContext)); *ctx = writer->context; diff --git a/tests/bad-base.ttl b/tests/bad-base.ttl new file mode 100644 index 00000000..85421999 --- /dev/null +++ b/tests/bad-base.ttl @@ -0,0 +1 @@ +@base "I'm quite certain this is not a URI" .
\ No newline at end of file diff --git a/tests/bad-datatype.ttl b/tests/bad-datatype.ttl new file mode 100644 index 00000000..0dd6018f --- /dev/null +++ b/tests/bad-datatype.ttl @@ -0,0 +1 @@ +<> <http://example.org/pred> "hello"^^"not-a-uri" .
\ No newline at end of file diff --git a/tests/bad-eof-in-lang-suffix.ttl b/tests/bad-eof-in-lang-suffix.ttl new file mode 100644 index 00000000..8e3002cb --- /dev/null +++ b/tests/bad-eof-in-lang-suffix.ttl @@ -0,0 +1,3 @@ +@prefix eg: <http://example.org> . + +<> eg:comment "That ain't no language"@en-x
\ No newline at end of file diff --git a/tests/bad-eof-in-lang.ttl b/tests/bad-eof-in-lang.ttl new file mode 100644 index 00000000..54db417f --- /dev/null +++ b/tests/bad-eof-in-lang.ttl @@ -0,0 +1,3 @@ +@prefix eg: <http://example.org> . + +<> eg:comment "That ain't no language"@a
\ No newline at end of file diff --git a/tests/bad-eof-in-object-list.ttl b/tests/bad-eof-in-object-list.ttl new file mode 100644 index 00000000..9bbcd17a --- /dev/null +++ b/tests/bad-eof-in-object-list.ttl @@ -0,0 +1,2 @@ +@prefix eg: <http://example.org/> . +<> eg:p eg:o ,
\ No newline at end of file diff --git a/tests/bad-eof-in-object-list2.ttl b/tests/bad-eof-in-object-list2.ttl new file mode 100644 index 00000000..9186fb9f --- /dev/null +++ b/tests/bad-eof-in-object-list2.ttl @@ -0,0 +1,2 @@ +@prefix eg: <http://example.org/> . +<> eg:p eg:o ; eg:p1 eg:o2 ,
\ No newline at end of file diff --git a/tests/bad-eof-in-predicate-list.ttl b/tests/bad-eof-in-predicate-list.ttl new file mode 100644 index 00000000..eab5b05b --- /dev/null +++ b/tests/bad-eof-in-predicate-list.ttl @@ -0,0 +1,2 @@ +@prefix eg: <http://example.org/> . +<> eg:p eg:o ;
\ No newline at end of file diff --git a/tests/bad-hex-digit.ttl b/tests/bad-hex-digit.ttl new file mode 100644 index 00000000..85816ced --- /dev/null +++ b/tests/bad-hex-digit.ttl @@ -0,0 +1 @@ +<http://example.org/thing> <http://example.org/comment> "\uABCG" . diff --git a/tests/bad-list.ttl b/tests/bad-list.ttl index 60e21351..5606658e 100644 --- a/tests/bad-list.ttl +++ b/tests/bad-list.ttl @@ -1 +1 @@ -<> <http://example.org/pred> (
\ No newline at end of file +<> <http://example.org/pred> <http://example.org/valid> , invalid .
\ No newline at end of file diff --git a/tests/bad-list2.ttl b/tests/bad-list2.ttl new file mode 100644 index 00000000..b5242de2 --- /dev/null +++ b/tests/bad-list2.ttl @@ -0,0 +1,3 @@ +@prefix eg: <http://example.org> . + +<> eg:thing ( .
\ No newline at end of file diff --git a/tests/bad-namespace.ttl b/tests/bad-namespace.ttl new file mode 100644 index 00000000..0dd78d33 --- /dev/null +++ b/tests/bad-namespace.ttl @@ -0,0 +1 @@ +@prefix eg: "what?" .
\ No newline at end of file diff --git a/tests/bad-object.ttl b/tests/bad-object.ttl new file mode 100644 index 00000000..9fc6da18 --- /dev/null +++ b/tests/bad-object.ttl @@ -0,0 +1,3 @@ +@prefix eg: <http://example.org/> . + +eg:thing a four . diff --git a/tests/bad-object2.ttl b/tests/bad-object2.ttl new file mode 100644 index 00000000..9293d168 --- /dev/null +++ b/tests/bad-object2.ttl @@ -0,0 +1,3 @@ +@prefix eg: <http://example.org/> . + +eg:thing a fives . diff --git a/tests/bad-verb.ttl b/tests/bad-verb.ttl new file mode 100644 index 00000000..56a134f3 --- /dev/null +++ b/tests/bad-verb.ttl @@ -0,0 +1,2 @@ +@prefix a: <http://example.org/> . +a:thing x a:Thing .
\ No newline at end of file diff --git a/tests/serd_test.c b/tests/serd_test.c index aca88127..7eb9a67e 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -82,7 +82,7 @@ main() }; const char* expt_test_strs[] = { - "02e18", "-5e019", "+8e20", "2E+34", "-5E-5", "8E0", "9e-0", "2e+0" + "02e18", "-5e019", "+8e20", "2E+34", "-5E-5", "8E0", "9e-0", " 2e+0" }; for (unsigned i = 0; i < sizeof(expt_test_nums) / sizeof(double); ++i) { @@ -99,11 +99,11 @@ main() // Test serd_node_new_decimal const double dbl_test_nums[] = { - 0.0, 42.0, .01, 8.0, 2.05, -16.00001, 5.000000005 + 0.0, 42.0, .01, 2.05, -16.00001, 5.000000005, 0.0000000001 }; const char* dbl_test_strs[] = { - "0.0", "42.0", "0.01", "8.0", "2.05", "-16.00001", "5.00000001" + "0.0", "42.0", "0.01", "2.05", "-16.00001", "5.00000001", "0.0" }; for (unsigned i = 0; i < sizeof(dbl_test_nums) / sizeof(double); ++i) { @@ -155,13 +155,19 @@ main() size_t n_bytes; SerdNodeFlags flags; - const size_t len = serd_strlen(str, &n_bytes, &flags); + size_t len = serd_strlen(str, &n_bytes, &flags); if (len != 5 || n_bytes != 7 || flags != (SERD_HAS_QUOTE|SERD_HAS_NEWLINE)) { fprintf(stderr, "Bad serd_strlen(%s) len=%zu n_bytes=%zu flags=%u\n", str, len, n_bytes, flags); return 1; } + len = serd_strlen(str, NULL, &flags); + if (len != 5) { + fprintf(stderr, "Bad serd_strlen(%s) len=%zu flags=%u\n", + str, len, flags); + return 1; + } // Test serd_strerror @@ -177,6 +183,7 @@ main() return 1; } } + msg = serd_strerror((SerdStatus)-1); // Test serd_uri_to_path @@ -200,6 +207,37 @@ main() fprintf(stderr, "Bad path %s for %s\n", serd_uri_to_path(uri), uri); return 1; } + uri = (const uint8_t*)"file:///c:awful/system"; + if (strcmp((const char*)serd_uri_to_path(uri), "/c:awful/system")) { + fprintf(stderr, "Bad path %s for %s\n", serd_uri_to_path(uri), uri); + return 1; + } + uri = (const uint8_t*)"file:///0/1"; + if (strcmp((const char*)serd_uri_to_path(uri), "/0/1")) { + fprintf(stderr, "Bad path %s for %s\n", serd_uri_to_path(uri), uri); + return 1; + } + + // Test serd_node_equals + + const uint8_t replacement_char_str[] = { 0xEF, 0xBF, 0xBD, 0 }; + SerdNode lhs = serd_node_from_string(SERD_LITERAL, replacement_char_str); + SerdNode rhs = serd_node_from_string(SERD_LITERAL, USTR("123")); + if (serd_node_equals(&lhs, &rhs)) { + fprintf(stderr, "%s == %s\n", lhs.buf, rhs.buf); + return 1; + } + + SerdNode qnode = serd_node_from_string(SERD_CURIE, USTR("foo:bar")); + if (serd_node_equals(&lhs, &qnode)) { + fprintf(stderr, "%s == %s\n", lhs.buf, qnode.buf); + return 1; + } + + if (!serd_node_equals(&lhs, &lhs)) { + fprintf(stderr, "%s != %s\n", lhs.buf, lhs.buf); + return 1; + } // Test serd_node_from_string @@ -211,13 +249,31 @@ main() return 1; } + // Test serd_node_new_uri_from_string + + SerdURI base_uri; + SerdNode base = serd_node_new_uri_from_string(USTR("http://example.org/"), + NULL, &base_uri); + SerdNode nil = serd_node_new_uri_from_string(NULL, &base_uri, NULL); + if (nil.type != SERD_URI || strcmp((const char*)nil.buf, (const char*)base.buf)) { + fprintf(stderr, "URI %s != base %s\n", nil.buf, base.buf); + return 1; + } + serd_node_free(&base); + serd_node_free(&nil); + // Test SerdEnv SerdNode u = serd_node_from_string(SERD_URI, USTR("http://example.org/foo")); SerdNode b = serd_node_from_string(SERD_CURIE, USTR("invalid")); - SerdNode c = serd_node_from_string(SERD_CURIE, USTR("eg:b")); + SerdNode c = serd_node_from_string(SERD_CURIE, USTR("eg.2:b")); SerdEnv* env = serd_env_new(NULL); - serd_env_set_prefix_from_strings(env, USTR("eg"), USTR("http://example.org/")); + serd_env_set_prefix_from_strings(env, USTR("eg.2"), USTR("http://example.org/")); + + if (!serd_env_set_base_uri(env, &node)) { + fprintf(stderr, "Set base URI to %s\n", node.buf); + return 1; + } SerdChunk prefix, suffix; if (!serd_env_expand(env, &b, &prefix, &suffix)) { @@ -225,6 +281,12 @@ main() return 1; } + SerdNode xnode = serd_env_expand_node(env, &node); + if (!serd_node_equals(&xnode, &SERD_NODE_NULL)) { + fprintf(stderr, "Expanded %s to %s\n", c.buf, xnode.buf); + return 1; + } + SerdNode xu = serd_env_expand_node(env, &u); if (strcmp((const char*)xu.buf, "http://example.org/foo")) { fprintf(stderr, "Expanded %s to %s\n", c.buf, xu.buf); @@ -232,6 +294,13 @@ main() } serd_node_free(&xu); + SerdNode badpre = serd_node_from_string(SERD_CURIE, USTR("hm:what")); + SerdNode xbadpre = serd_env_expand_node(env, &badpre); + if (!serd_node_equals(&xbadpre, &SERD_NODE_NULL)) { + fprintf(stderr, "Expanded invalid curie %s\n", badpre.buf); + return 1; + } + SerdNode xc = serd_env_expand_node(env, &c); if (strcmp((const char*)xc.buf, "http://example.org/b")) { fprintf(stderr, "Expanded %s to %s\n", c.buf, xc.buf); @@ -251,13 +320,20 @@ main() } int n_prefixes = 0; - serd_env_set_prefix_from_strings(env, USTR("eg"), USTR("http://example.org/")); + serd_env_set_prefix_from_strings(env, USTR("eg.2"), USTR("http://example.org/")); serd_env_foreach(env, count_prefixes, &n_prefixes); if (n_prefixes != 1) { fprintf(stderr, "Bad prefix count %d\n", n_prefixes); return 1; } + SerdNode shorter_uri = serd_node_from_string(SERD_URI, USTR("urn:foo")); + SerdNode prefix_name; + if (serd_env_qualify(env, &shorter_uri, &prefix_name, &suffix)) { + fprintf(stderr, "Qualified %s\n", shorter_uri.buf); + return 1; + } + // Test SerdReader and SerdWriter const char* path = tmpnam(NULL); @@ -277,6 +353,19 @@ main() return 1; } + serd_writer_chop_blank_prefix(writer, USTR("tmp")); + serd_writer_chop_blank_prefix(writer, NULL); + + if (!serd_writer_set_base_uri(writer, &lit)) { + fprintf(stderr, "Set base URI to %s\n", lit.buf); + return 1; + } + + if (!serd_writer_set_prefix(writer, &lit, &lit)) { + fprintf(stderr, "Set prefix %s to %s\n", lit.buf, lit.buf); + return 1; + } + if (!serd_writer_end_anon(writer, NULL)) { fprintf(stderr, "Ended non-existent anonymous node\n"); return 1; @@ -288,20 +377,43 @@ main() SerdNode o = serd_node_from_string(SERD_LITERAL, buf); // Write 3 invalid statements (should write nothing) - if (!serd_writer_write_statement(writer, 0, NULL, - &s, &p, NULL, NULL, NULL)) { - fprintf(stderr, "Successfully wrote junk statement 1\n"); - return 1; - } - if (!serd_writer_write_statement(writer, 0, NULL, - &s, &p, &SERD_NODE_NULL, NULL, NULL)) { - fprintf(stderr, "Successfully wrote junk statement 1\n"); + const SerdNode* junk[][5] = { { &s, &p, NULL, NULL, NULL }, + { &s, NULL, &o, NULL, NULL }, + { NULL, &p, &o, NULL, NULL }, + { &s, &p, &SERD_NODE_NULL, NULL, NULL }, + { &s, &SERD_NODE_NULL, &o, NULL, NULL }, + { &SERD_NODE_NULL, &p, &o, NULL, NULL }, + { &s, &o, &o, NULL, NULL }, + { &o, &p, &o, NULL, NULL }, + { NULL, NULL, NULL, NULL, NULL } }; + for (unsigned i = 0; i < sizeof(junk) / (sizeof(SerdNode*) * 5); ++i) { + if (!serd_writer_write_statement( + writer, 0, NULL, + junk[i][0], junk[i][1], junk[i][2], junk[i][3], junk[i][4])) { + fprintf(stderr, "Successfully wrote junk statement %d\n", i); return 1; + } } - if (!serd_writer_write_statement(writer, 0, NULL, - &s, &o, &o, NULL, NULL)) { - fprintf(stderr, "Successfully wrote junk statement 3\n"); - return 1; + + const SerdNode t = serd_node_from_string(SERD_URI, USTR("urn:Type")); + const SerdNode l = serd_node_from_string(SERD_LITERAL, USTR("en")); + const SerdNode* good[][5] = { { &s, &p, &o, NULL, NULL }, + { &s, &p, &o, &SERD_NODE_NULL, &SERD_NODE_NULL }, + { &s, &p, &o, &t, NULL }, + { &s, &p, &o, NULL, &l }, + { &s, &p, &o, &t, &l }, + { &s, &p, &o, &t, &SERD_NODE_NULL }, + { &s, &p, &o, &SERD_NODE_NULL, &l }, + { &s, &p, &o, NULL, &SERD_NODE_NULL }, + { &s, &p, &o, &SERD_NODE_NULL, NULL }, + { &s, &p, &o, &SERD_NODE_NULL, NULL } }; + for (unsigned i = 0; i < sizeof(good) / (sizeof(SerdNode*) * 5); ++i) { + if (serd_writer_write_statement( + writer, 0, NULL, + good[i][0], good[i][1], good[i][2], good[i][3], good[i][4])) { + fprintf(stderr, "Failed to write good statement %d\n", i); + return 1; + } } // Write 1 statement with bad UTF-8 (should be replaced) @@ -334,6 +446,9 @@ main() return 1; } + serd_reader_add_blank_prefix(reader, USTR("tmp")); + serd_reader_add_blank_prefix(reader, NULL); + if (!serd_reader_read_file(reader, USTR("http://notafile"))) { fprintf(stderr, "Apparently read an http URI\n"); return 1; @@ -348,11 +463,16 @@ main() return 1; } - if (*n_statements != 2) { + if (*n_statements != 12) { fprintf(stderr, "Bad statement count %d\n", *n_statements); return 1; } + if (!serd_reader_read_string(reader, USTR("This isn't Turtle at all."))) { + fprintf(stderr, "Parsed invalid string successfully.\n"); + return 1; + } + serd_reader_free(reader); fclose(fd); diff --git a/tests/test-backspace.out b/tests/test-backspace.out index ae8d3678..ad4806cf 100644 --- a/tests/test-backspace.out +++ b/tests/test-backspace.out @@ -1 +1,2 @@ <http://example.org/thing> <http://example.org/label> "\u0008" . +<http://example.org/thing> <http://example.org/label> "\uFFFD" . diff --git a/tests/test-backspace.ttl b/tests/test-backspace.ttl index 0e695a88..07375d76 100644 --- a/tests/test-backspace.ttl +++ b/tests/test-backspace.ttl @@ -1 +1,2 @@ -<http://example.org/thing> <http://example.org/label> "\u0008" .
\ No newline at end of file +<http://example.org/thing> <http://example.org/label> "\u0008" . +<http://example.org/thing> <http://example.org/label> "" .
\ No newline at end of file diff --git a/tests/test-cr.out b/tests/test-cr.out new file mode 100644 index 00000000..aea1655b --- /dev/null +++ b/tests/test-cr.out @@ -0,0 +1 @@ +<http://example.org/thing> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Thing> . diff --git a/tests/test-cr.ttl b/tests/test-cr.ttl new file mode 100644 index 00000000..5410648a --- /dev/null +++ b/tests/test-cr.ttl @@ -0,0 +1,2 @@ +#Test
<http://example.org/thing> a <http://example.org/Thing> .
+ diff --git a/tests/test-delete.out b/tests/test-delete.out new file mode 100644 index 00000000..41ac8062 --- /dev/null +++ b/tests/test-delete.out @@ -0,0 +1,2 @@ +<http://example.org/thing> <http://example.org/label> "\u007F" . +<http://example.org/thing> <http://example.org/label> "\u007F" . diff --git a/tests/test-delete.ttl b/tests/test-delete.ttl new file mode 100644 index 00000000..4bc97060 --- /dev/null +++ b/tests/test-delete.ttl @@ -0,0 +1,2 @@ +<http://example.org/thing> <http://example.org/label> "\u007F" . +<http://example.org/thing> <http://example.org/label> "" . diff --git a/tests/test-eof-at-page-end.out b/tests/test-eof-at-page-end.out new file mode 100644 index 00000000..64d24586 --- /dev/null +++ b/tests/test-eof-at-page-end.out @@ -0,0 +1 @@ +<http://example.org/thing> <http://example.org/comment> "\n0123456789012345678901234567890123456789\n\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567890123456789012345678901234567890123456789\n01234567" . diff --git a/tests/test-eof-at-page-end.ttl b/tests/test-eof-at-page-end.ttl new file mode 100644 index 00000000..d6d9af26 --- /dev/null +++ b/tests/test-eof-at-page-end.ttl @@ -0,0 +1,85 @@ +<http://example.org/thing> <http://example.org/comment> """ +0123456789012345678901234567890123456789 + +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 + +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 + +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 + +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789 +01234567""" .
\ No newline at end of file diff --git a/tests/test-lang.out b/tests/test-lang.out index c36dda42..61daecb3 100644 --- a/tests/test-lang.out +++ b/tests/test-lang.out @@ -2,3 +2,4 @@ <http://example.org/test-lang#thing> <http://example.org/test-lang#greeting> "Howdy"@en-us . <http://example.org/test-lang#thing> <http://example.org/test-lang#greeting> "Bonjour"@fr . <http://example.org/test-lang#thing> <http://example.org/test-lang#greeting> "Guten Tag"@de-latn-de . +<http://example.org/test-lang#thing> <http://example.org/test-lang#greeting> "HEY MAN"@en-crazy0place . diff --git a/tests/test-lang.ttl b/tests/test-lang.ttl index f7c2727f..b0616475 100644 --- a/tests/test-lang.ttl +++ b/tests/test-lang.ttl @@ -3,4 +3,5 @@ :thing :greeting "Hello"@en ; :greeting "Howdy"@en-us ; :greeting "Bonjour"@fr ; - :greeting "Guten Tag"@de-latn-de . + :greeting "Guten Tag"@de-latn-de ; + :greeting "HEY MAN"@en-crazy0place . diff --git a/tests/test-list.out b/tests/test-list.out new file mode 100644 index 00000000..3a27a5a6 --- /dev/null +++ b/tests/test-list.out @@ -0,0 +1 @@ +<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/List> . diff --git a/tests/test-list.ttl b/tests/test-list.ttl new file mode 100644 index 00000000..7f4c7699 --- /dev/null +++ b/tests/test-list.ttl @@ -0,0 +1 @@ +() a <http://example.org/List> .
\ No newline at end of file diff --git a/tests/test-no-spaces.out b/tests/test-no-spaces.out new file mode 100644 index 00000000..3619a5f0 --- /dev/null +++ b/tests/test-no-spaces.out @@ -0,0 +1,4 @@ +<http://example.org/s> <http://example.org/p> <http://example.org/o> . +<http://example.org/s> <http://example.org/p2> <http://example.org/o2> . +<http://example.org/s> <http://example.org/p2> <http://example.org/o3> . +<http://example.org/s> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Thing> . diff --git a/tests/test-no-spaces.ttl b/tests/test-no-spaces.ttl new file mode 100644 index 00000000..88171e71 --- /dev/null +++ b/tests/test-no-spaces.ttl @@ -0,0 +1,3 @@ +@prefix eg: <http://example.org/> . +eg:s eg:p eg:o;eg:p2 eg:o2,eg:o3 . +eg:s a<http://example.org/Thing> .
\ No newline at end of file diff --git a/tests/test-num.out b/tests/test-num.out index 2502580b..54263d46 100644 --- a/tests/test-num.out +++ b/tests/test-num.out @@ -7,3 +7,4 @@ <http://example.org/eg#thing> <http://example.org/eg#num> "1.58490e-05"^^<http://www.w3.org/2001/XMLSchema#double> . <http://example.org/eg#thing> <http://example.org/eg#num> "1.58490e+05"^^<http://www.w3.org/2001/XMLSchema#double> . <http://example.org/eg#thing> <http://example.org/eg#num> "1.58490e05"^^<http://www.w3.org/2001/XMLSchema#double> . +<http://example.org/eg#thing> <http://example.org/eg#num> "1.58490E05"^^<http://www.w3.org/2001/XMLSchema#double> . diff --git a/tests/test-num.ttl b/tests/test-num.ttl index 54a425ac..68ad290b 100644 --- a/tests/test-num.ttl +++ b/tests/test-num.ttl @@ -9,3 +9,4 @@ eg:thing eg:num -.6 . eg:thing eg:num 1.58490e-05 . eg:thing eg:num 1.58490e+05 . eg:thing eg:num 1.58490e05 . +eg:thing eg:num 1.58490E05 . diff --git a/tests/test-prefix.out b/tests/test-prefix.out index 9e166588..bcfdd4b6 100644 --- a/tests/test-prefix.out +++ b/tests/test-prefix.out @@ -1,2 +1,6 @@ <http://example.org/a/b> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Thing> . <http://example.org/a/b/c> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Thing> . +<http://example.org/a/num0num> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Thing> . +<http://example.org/a/under_under> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Thing> . +<http://example.org/a/dash-dash> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Thing> . +<http://example.org/a/.invalidname.> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Thing> . diff --git a/tests/test-prefix.ttl b/tests/test-prefix.ttl index a1d22122..f79896cb 100644 --- a/tests/test-prefix.ttl +++ b/tests/test-prefix.ttl @@ -1,4 +1,8 @@ @prefix eg: <http://example.org/a/> . <http://example.org/a/b> a <http://example.org/Thing> . -<http://example.org/a/b/c> a <http://example.org/Thing> .
\ No newline at end of file +<http://example.org/a/b/c> a <http://example.org/Thing> . +<http://example.org/a/num0num> a <http://example.org/Thing> . +<http://example.org/a/under_under> a <http://example.org/Thing> . +<http://example.org/a/dash-dash> a <http://example.org/Thing> . +<http://example.org/a/.invalidname.> a <http://example.org/Thing> . diff --git a/tests/test-uri.out b/tests/test-uri.out index 8c984f79..8fd5dd87 100644 --- a/tests/test-uri.out +++ b/tests/test-uri.out @@ -35,6 +35,7 @@ <http://a/b/c/g#s/./x> <http://www.w3.org/2002/07/owl#sameAs> <http://a/b/c/g#s/./x> . <http://a/b/c/g#s/../x> <http://www.w3.org/2002/07/owl#sameAs> <http://a/b/c/g#s/../x> . <http://a/.g> <http://www.w3.org/2002/07/owl#sameAs> <http://a/.g> . +<http://a/..g> <http://www.w3.org/2002/07/owl#sameAs> <http://a/..g> . <http://A?aquery> <http://www.w3.org/2002/07/owl#sameAs> <http://A?aquery> . <http://A#afragment> <http://www.w3.org/2002/07/owl#sameAs> <http://A#afragment> . <http://a/b/c/d;p?aquery> <http://www.w3.org/2002/07/owl#sameAs> <http://a/b/c/d;p?aquery> . diff --git a/tests/test-uri.ttl b/tests/test-uri.ttl index cbc699ab..8e4f5102 100644 --- a/tests/test-uri.ttl +++ b/tests/test-uri.ttl @@ -52,6 +52,7 @@ # Additional tests for Serd </.g> owl:sameAs <http://a/.g> . +</..g> owl:sameAs <http://a/..g> . <http://A?aquery> owl:sameAs <http://A?aquery> . <http://A#afragment> owl:sameAs <http://A#afragment> . <?aquery> owl:sameAs <http://a/b/c/d;p?aquery> . diff --git a/tests/test-utf8-uri.out b/tests/test-utf8-uri.out new file mode 100644 index 00000000..b8a73a88 --- /dev/null +++ b/tests/test-utf8-uri.out @@ -0,0 +1 @@ +<http://example.org/math/\u2200x\u2208\u211D> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Thing> . diff --git a/tests/test-utf8-uri.ttl b/tests/test-utf8-uri.ttl new file mode 100644 index 00000000..51f26ff2 --- /dev/null +++ b/tests/test-utf8-uri.ttl @@ -0,0 +1 @@ +<http://example.org/math/∀x∈ℝ> a <http://example.org/Thing> .
\ No newline at end of file @@ -327,15 +327,18 @@ def test(ctx): thru_tests.remove('tests/test-id.ttl') # IDs are mapped so files won't be identical commands = [] - bulk = False + num = 0 for test in thru_tests: + num += 1 + bulk = (num % 2 == 0) + full = (num % 5 == 0) base_uri = 'http://www.w3.org/2001/sw/DataAccess/df1/' + test out_filename = test + '.thru' commands += [ - '%s %s -o turtle -p foo %s/%s \'%s\' | %s -i turtle -o ntriples -c foo - \'%s\' | sed \'s/_:docid/_:genid/g\' > %s.thru' % ( - 'serdi_static', '-b' if bulk else ' ', srcdir, test, base_uri, + '%s %s %s -i ntriples -o turtle -p foo %s/%s \'%s\' | %s -i turtle -o ntriples -c foo - \'%s\' | sed \'s/_:docid/_:genid/g\' > %s.thru' % ( + 'serdi_static', '-b' if bulk else ' ', '-f' if full else ' ', + srcdir, test, base_uri, 'serdi_static', base_uri, test) ] - bulk = not bulk autowaf.run_tests(ctx, APPNAME, commands, 0, name='turtle-round-trip') Logs.pprint('BOLD', '\nVerifying ntriples => turtle => ntriples') |