diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/bad/bad-blank-node-label.nt | 1 | ||||
-rw-r--r-- | test/bad/bad-trailing-garbage.nt | 1 | ||||
-rw-r--r-- | test/bad/manifest.ttl | 12 | ||||
-rw-r--r-- | test/good/manifest.ttl | 7 | ||||
-rw-r--r-- | test/lax/manifest.ttl | 7 | ||||
-rw-r--r-- | test/lax/test-out-of-range-unicode.nt (renamed from test/good/test-out-of-range-unicode.nt) | 0 | ||||
-rw-r--r-- | test/lax/test-out-of-range-unicode.ttl (renamed from test/good/test-out-of-range-unicode.ttl) | 0 | ||||
-rw-r--r-- | test/test_overflow.c | 3 | ||||
-rw-r--r-- | test/test_reader.c | 55 |
9 files changed, 79 insertions, 7 deletions
diff --git a/test/bad/bad-blank-node-label.nt b/test/bad/bad-blank-node-label.nt new file mode 100644 index 00000000..8f37fe13 --- /dev/null +++ b/test/bad/bad-blank-node-label.nt @@ -0,0 +1 @@ +<http://example.org/s> <http://example.org/p> _nocolon .
\ No newline at end of file diff --git a/test/bad/bad-trailing-garbage.nt b/test/bad/bad-trailing-garbage.nt new file mode 100644 index 00000000..b4e2f7cd --- /dev/null +++ b/test/bad/bad-trailing-garbage.nt @@ -0,0 +1 @@ +<http://example.org/s> <http://example.org/p> <http://example.org/o> . <http://example.org/error>
\ No newline at end of file diff --git a/test/bad/manifest.ttl b/test/bad/manifest.ttl index d024dccc..28841e82 100644 --- a/test/bad/manifest.ttl +++ b/test/bad/manifest.ttl @@ -24,6 +24,7 @@ <#bad-14> <#bad-base> <#bad-blank> + <#bad-blank-node-label> <#bad-bom> <#bad-char-in-local> <#bad-char-in-prefix> @@ -70,6 +71,7 @@ <#bad-semicolon-after-subject> <#bad-string> <#bad-subject> + <#bad-trailing-garbage> <#bad-uri-escape> <#bad-var> <#bad-verb> @@ -166,6 +168,11 @@ mf:name "bad-blank" ; mf:action <bad-blank.ttl> . +<#bad-blank-node-label> + rdf:type rdft:TestNTriplesNegativeSyntax ; + mf:name "bad-blank-node-label" ; + mf:action <bad-blank-node-label.nt> . + <#bad-bom> rdf:type rdft:TestTurtleNegativeSyntax ; mf:name "bad-bom" ; @@ -396,6 +403,11 @@ mf:name "bad-subject" ; mf:action <bad-subject.ttl> . +<#bad-trailing-garbage> + rdf:type rdft:TestNTriplesNegativeSyntax ; + mf:name "bad-trailing-garbage" ; + mf:action <bad-trailing-garbage.nt> . + <#bad-uri-escape> rdf:type rdft:TestTurtleNegativeSyntax ; mf:name "bad-uri-escape" ; diff --git a/test/good/manifest.ttl b/test/good/manifest.ttl index 2bf36caf..fe3e195e 100644 --- a/test/good/manifest.ttl +++ b/test/good/manifest.ttl @@ -43,7 +43,6 @@ <#test-no-spaces> <#test-non-curie-uri> <#test-num> - <#test-out-of-range-unicode> <#test-prefix> <#test-pretty> <#test-rel> @@ -257,12 +256,6 @@ mf:action <test-num.ttl> ; mf:result <test-num.nt> . -<#test-out-of-range-unicode> - rdf:type rdft:TestTurtleEval ; - mf:name "test-out-of-range-unicode" ; - mf:action <test-out-of-range-unicode.ttl> ; - mf:result <test-out-of-range-unicode.nt> . - <#test-prefix> rdf:type rdft:TestTurtleEval ; mf:name "test-prefix" ; diff --git a/test/lax/manifest.ttl b/test/lax/manifest.ttl index b63da6d4..0d370f42 100644 --- a/test/lax/manifest.ttl +++ b/test/lax/manifest.ttl @@ -16,6 +16,7 @@ <#test-bad-utf8-nt> <#test-bad-utf8-nq> <#test-lone-list> + <#test-out-of-range-unicode> ) . <#test-bad-string-ttl> @@ -71,3 +72,9 @@ mf:name "test-lone-list" ; mf:action <test-lone-list.ttl> ; mf:result <test-lone-list.nt> . + +<#test-out-of-range-unicode> + rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "test-out-of-range-unicode" ; + mf:action <test-out-of-range-unicode.ttl> ; + mf:result <test-out-of-range-unicode.nt> . diff --git a/test/good/test-out-of-range-unicode.nt b/test/lax/test-out-of-range-unicode.nt index 5def9e31..5def9e31 100644 --- a/test/good/test-out-of-range-unicode.nt +++ b/test/lax/test-out-of-range-unicode.nt diff --git a/test/good/test-out-of-range-unicode.ttl b/test/lax/test-out-of-range-unicode.ttl index 7e64785a..7e64785a 100644 --- a/test/good/test-out-of-range-unicode.ttl +++ b/test/lax/test-out-of-range-unicode.ttl diff --git a/test/test_overflow.c b/test/test_overflow.c index d94d7e90..2a77135c 100644 --- a/test/test_overflow.c +++ b/test/test_overflow.c @@ -74,6 +74,9 @@ test_ntriples_overflow(void) { static const char* const test_strings[] = { "<http://example.org/s> <http://example.org/p> <http://example.org/o> .", + "<http://example.org/s> <http://example.org/p> \"literal\" .", + "<http://example.org/s> <http://example.org/p> _:blank .", + "<http://example.org/s> <http://example.org/p> \"\"@en .", NULL, }; diff --git a/test/test_reader.c b/test/test_reader.c index 5cc8d634..3651e014 100644 --- a/test/test_reader.c +++ b/test/test_reader.c @@ -19,6 +19,7 @@ #include "serd/serd.h" #include <assert.h> +#include <stdbool.h> #include <stdio.h> #include <string.h> @@ -314,6 +315,59 @@ test_read_chunks(void) serd_world_free(world); } +static size_t +empty_test_read(void* buf, size_t size, size_t nmemb, void* stream) +{ + (void)buf; + (void)size; + (void)nmemb; + (void)stream; + + assert(false); + + return 0; +} + +static int +empty_test_error(void* stream) +{ + (void)stream; + return 0; +} + +/// Test that reading SERD_SYNTAX_EMPTY "succeeds" without reading any input +static void +test_read_empty(void) +{ + SerdWorld* const world = serd_world_new(); + size_t n_statements = 0; + FILE* const f = tmpfile(); + + SerdSink* const sink = serd_sink_new(&n_statements, count_statements, NULL); + assert(sink); + + SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); + SerdReader* const reader = + serd_reader_new(world, SERD_SYNTAX_EMPTY, 0, env, sink, 4096); + + assert(reader); + + SerdByteSource* byte_source = serd_byte_source_new_function( + empty_test_read, empty_test_error, NULL, f, NULL, 1); + + SerdStatus st = serd_reader_start(reader, byte_source); + assert(!st); + + assert(serd_reader_read_document(reader) == SERD_SUCCESS); + assert(n_statements == 0); + + serd_byte_source_free(byte_source); + serd_reader_free(reader); + serd_env_free(env); + serd_sink_free(sink); + serd_world_free(world); +} + int main(void) { @@ -322,5 +376,6 @@ main(void) test_read_eof_by_page(); test_read_eof_by_byte(); test_read_chunks(); + test_read_empty(); return 0; } |