diff options
author | David Robillard <d@drobilla.net> | 2023-03-31 10:50:12 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:07 -0500 |
commit | d22653dfe356e3da1354cdb0f7915e29c4a33e3b (patch) | |
tree | 496e678ba61a436e2bf0b11b079bf6115ba630fa /test/test_reader.c | |
parent | 469034ec4ae5c0b5230ca30c40aaa9b1432c13a2 (diff) | |
download | serd-d22653dfe356e3da1354cdb0f7915e29c4a33e3b.tar.gz serd-d22653dfe356e3da1354cdb0f7915e29c4a33e3b.tar.bz2 serd-d22653dfe356e3da1354cdb0f7915e29c4a33e3b.zip |
Factor out NTriples reader
Diffstat (limited to 'test/test_reader.c')
-rw-r--r-- | test/test_reader.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/test_reader.c b/test/test_reader.c index a5595804..f33c3429 100644 --- a/test/test_reader.c +++ b/test/test_reader.c @@ -19,6 +19,7 @@ #endif #include <assert.h> +#include <stdbool.h> #include <stdio.h> #include <string.h> @@ -365,6 +366,51 @@ test_read_turtle_chunks(const char* const path) assert(!zix_remove(path)); } +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(); + ReaderTest rt = {0, 0, 0, 0}; + + SerdSink* const sink = serd_sink_new(&rt, test_sink, NULL); + assert(sink); + + SerdReader* const reader = serd_reader_new(world, SERD_SYNTAX_EMPTY, 0, sink); + assert(reader); + + SerdStatus st = serd_reader_start_stream( + reader, empty_test_read, empty_test_error, &rt, NULL, 1); + assert(st == SERD_SUCCESS); + + assert(serd_reader_read_document(reader) == SERD_SUCCESS); + assert(rt.n_statement == 0); + + serd_reader_free(reader); + serd_sink_free(sink); + serd_world_free(world); +} + int main(void) { @@ -379,6 +425,9 @@ main(void) test_read_string(); test_read_eof_by_page(ttl_path); test_read_eof_by_byte(); + test_read_nquads_chunks(nq_path); + test_read_turtle_chunks(ttl_path); + test_read_empty(); assert(!zix_remove(dir)); |