diff options
author | David Robillard <d@drobilla.net> | 2018-12-26 19:25:51 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-06-21 18:12:03 +0200 |
commit | 1a25e379b3dfcc8716cfbcbac58a7076cffddc3a (patch) | |
tree | 26bb34bdf1fb0fa98e327fb2a013d3104201491b /tests | |
parent | 8dbb1edfd28c73b02b3295a4f7a01869bd2237ec (diff) | |
download | serd-1a25e379b3dfcc8716cfbcbac58a7076cffddc3a.tar.gz serd-1a25e379b3dfcc8716cfbcbac58a7076cffddc3a.tar.bz2 serd-1a25e379b3dfcc8716cfbcbac58a7076cffddc3a.zip |
Hide fopen wrapper and use reader interface consistently
Diffstat (limited to 'tests')
-rw-r--r-- | tests/serd_test.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c index d46e01ba..002da68c 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -660,8 +660,8 @@ static void test_reader(const char* path) { SerdWorld* world = serd_world_new(); - ReaderTest* rt = (ReaderTest*)calloc(1, sizeof(ReaderTest)); - SerdSink sink = { rt, NULL, NULL, test_sink, NULL }; + ReaderTest rt = { 0, NULL }; + SerdSink sink = { &rt, NULL, NULL, test_sink, NULL }; SerdReader* reader = serd_reader_new(world, SERD_TURTLE, &sink); assert(reader); @@ -671,20 +671,18 @@ test_reader(const char* path) serd_reader_add_blank_prefix(reader, NULL); serd_node_free(g); - assert(serd_reader_read_file(reader, "http://notafile")); - assert(serd_reader_read_file(reader, "file:///better/not/exist")); - assert(serd_reader_read_file(reader, "file://")); + assert(serd_reader_start_file(reader, "http://notafile", false)); + assert(serd_reader_start_file(reader, "file://invalid", false)); + assert(serd_reader_start_file(reader, "file:///nonexistant", false)); - const SerdStatus st = serd_reader_read_file(reader, path); - assert(!st); - assert(rt->n_statements == 13); - assert(rt->graph && serd_node_get_string(rt->graph) && - !strcmp(serd_node_get_string(rt->graph), "http://example.org/")); - - assert(serd_reader_read_string(reader, "This isn't Turtle at all.")); + assert(!serd_reader_start_file(reader, path, true)); + assert(!serd_reader_read_document(reader)); + assert(rt.n_statements == 13); + assert(rt.graph && serd_node_get_string(rt.graph) && + !strcmp(serd_node_get_string(rt.graph), "http://example.org/")); + serd_reader_finish(reader); serd_reader_free(reader); - free(rt); serd_world_free(world); } |