diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_read_chunk.c | 2 | ||||
-rw-r--r-- | test/test_reader_writer.c | 40 |
2 files changed, 21 insertions, 21 deletions
diff --git a/test/test_read_chunk.c b/test/test_read_chunk.c index c4e267f3..df8b43c2 100644 --- a/test/test_read_chunk.c +++ b/test/test_read_chunk.c @@ -108,7 +108,7 @@ main(void) 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)); + assert(!serd_reader_finish(reader)); serd_reader_free(reader); serd_sink_free(sink); diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index 8f80deee..697469a9 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -19,6 +19,7 @@ #include "serd/serd.h" #include <assert.h> +#include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -150,13 +151,14 @@ test_read_string(void) serd_sink_set_statement_func(sink, test_sink); // Test reading a string that ends exactly at the end of input (no newline) - const SerdStatus st = - serd_reader_read_string(reader, - "<http://example.org/s> <http://example.org/p> " - "<http://example.org/o> ."); + assert( + !serd_reader_start_string(reader, + "<http://example.org/s> <http://example.org/p> " + "<http://example.org/o> .")); - assert(!st); + assert(!serd_reader_read_document(reader)); assert(rt->n_statements == 1); + assert(!serd_reader_finish(reader)); serd_reader_free(reader); serd_sink_free(sink); @@ -257,12 +259,12 @@ test_writer(const char* const path) static void test_reader(const char* path) { - ReaderTest* rt = (ReaderTest*)calloc(1, sizeof(ReaderTest)); - SerdSink* const sink = serd_sink_new(rt, NULL); + ReaderTest rt = {0, NULL}; + SerdSink* const sink = serd_sink_new(&rt, NULL); SerdReader* reader = serd_reader_new(SERD_TURTLE, sink); - assert(sink); assert(reader); + assert(sink); serd_sink_set_statement_func(sink, test_sink); SerdNode* g = serd_new_uri(SERD_STATIC_STRING("http://example.org/")); @@ -280,17 +282,16 @@ test_reader(const char* path) 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 == 6); - assert(rt->graph && serd_node_string(rt->graph) && - !strcmp(serd_node_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 == 6); + assert(rt.graph && serd_node_string(rt.graph) && + !strcmp(serd_node_string(rt.graph), "http://example.org/")); + serd_reader_finish(reader); // A read of a big page hits EOF then fails to read chunks immediately { @@ -311,7 +312,7 @@ test_reader(const char* path) assert(serd_reader_read_chunk(reader) == SERD_FAILURE); assert(serd_reader_read_chunk(reader) == SERD_FAILURE); - serd_reader_end_stream(reader); + serd_reader_finish(reader); fclose(temp); } @@ -333,7 +334,6 @@ test_reader(const char* path) serd_reader_free(reader); serd_sink_free(sink); - free(rt); } int |