diff options
author | David Robillard <d@drobilla.net> | 2020-08-16 12:42:58 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-07 15:32:24 -0500 |
commit | 9a8e06aa5bdc62ed589bd8ed5789bd059cec0700 (patch) | |
tree | ba5263262fad84c5f58bd60f3c6f6fcba30d6516 /test/test_read_chunk.c | |
parent | d4ae57afbd7da668dbf89f7b7e66e2f064437a98 (diff) | |
download | serd-9a8e06aa5bdc62ed589bd8ed5789bd059cec0700.tar.gz serd-9a8e06aa5bdc62ed589bd8ed5789bd059cec0700.tar.bz2 serd-9a8e06aa5bdc62ed589bd8ed5789bd059cec0700.zip |
Simplify reader interface
Diffstat (limited to 'test/test_read_chunk.c')
-rw-r--r-- | test/test_read_chunk.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/test/test_read_chunk.c b/test/test_read_chunk.c index dd2961ac..76e9b642 100644 --- a/test/test_read_chunk.c +++ b/test/test_read_chunk.c @@ -19,8 +19,7 @@ #include "serd/serd.h" #include <assert.h> -#include <stdbool.h> -#include <stdio.h> +#include <stddef.h> static size_t n_base = 0; static size_t n_prefix = 0; @@ -80,39 +79,32 @@ on_end(void* handle, const SerdNode* node) int main(void) { - FILE* file = tmpfile(); - - fprintf(file, - "@prefix eg: <http://example.org/> .\n" - "@base <http://example.org/base> .\n" - "eg:s1 eg:p1 eg:o1 ;\n" - " eg:p2 eg:o2 ,\n" - " eg:o3 .\n" - "eg:s2 eg:p1 eg:o1 ;\n" - " eg:p2 eg:o2 .\n" - "eg:s3 eg:p1 eg:o1 .\n" - "eg:s4 eg:p1 [ eg:p3 eg:o1 ] .\n"); - - fseek(file, 0, SEEK_SET); - SerdReader* reader = serd_reader_new( SERD_TURTLE, NULL, NULL, on_base, on_prefix, on_statement, on_end); - assert(reader); - assert(!serd_reader_start_stream(reader, file, NULL, true)); + + assert(!serd_reader_start_string(reader, + "@prefix eg: <http://example.org/> .\n" + "@base <http://example.org/base> .\n" + "eg:s1 eg:p1 eg:o1 ;\n" + " eg:p2 eg:o2 ,\n" + " eg:o3 .\n" + "eg:s2 eg:p1 eg:o1 ;\n" + " eg:p2 eg:o2 .\n" + "eg:s3 eg:p1 eg:o1 .\n" + "eg:s4 eg:p1 [ eg:p3 eg:o1 ] .\n")); assert(!serd_reader_read_chunk(reader) && n_prefix == 1); assert(!serd_reader_read_chunk(reader) && n_base == 1); assert(!serd_reader_read_chunk(reader) && n_statement == 3); assert(!serd_reader_read_chunk(reader) && n_statement == 5); assert(!serd_reader_read_chunk(reader) && n_statement == 6); - assert(!serd_reader_read_chunk(reader) && n_statement == 8 && n_end == 1); + assert(!serd_reader_read_chunk(reader) && n_statement == 8); assert(serd_reader_read_chunk(reader) == SERD_FAILURE); + assert(n_end == 1); assert(serd_reader_read_chunk(reader) == SERD_FAILURE); - assert(!serd_reader_end_stream(reader)); - serd_reader_free(reader); - fclose(file); + serd_reader_free(reader); return 0; } |