aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/serd_test.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index b206886b..503b4ef1 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -671,8 +671,8 @@ main(void)
// Rewind and test reader
fseek(fd, 0, SEEK_SET);
- 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);
if (!reader) {
FAIL("Failed to create reader\n");
@@ -684,27 +684,25 @@ main(void)
serd_reader_add_blank_prefix(reader, NULL);
serd_node_free(g);
- if (!serd_reader_read_file(reader, "http://notafile")) {
- FAIL("Apparently read an http URI\n");
- } else if (!serd_reader_read_file(reader, "file:///better/not/exist")) {
- FAIL("Apparently read a non-existent file\n");
- } else if (!serd_reader_read_file(reader, "file://")) {
- FAIL("Apparently read a file with no path\n");
- }
-
- const SerdStatus st = serd_reader_read_file(reader, path);
- if (st) {
- FAILF("Error reading file (%s)\n", serd_strerror(st));
- } else if (rt->n_statements != 13) {
- FAILF("Bad statement count %d\n", rt->n_statements);
- } else if (!rt->graph || !serd_node_get_string(rt->graph) ||
- strcmp(serd_node_get_string(rt->graph), "http://example.org/")) {
- FAILF("Bad graph %p\n", rt->graph);
- }
-
- if (!serd_reader_read_string(reader, "This isn't Turtle at all.")) {
- FAIL("Parsed invalid string successfully.\n");
- }
+ if (!serd_reader_start_file(reader, "http://notafile", false)) {
+ FAIL("Apparently can read an http URI\n");
+ } else if (!serd_reader_start_file(reader, "file://invalid", false)) {
+ FAIL("Apparently can read an invalid file URI\n");
+ } else if (!serd_reader_start_file(reader, "file:///nonexistant", false)) {
+ FAIL("Apparently can read a non-existent file\n");
+ }
+
+ if (serd_reader_start_file(reader, path, true)) {
+ FAIL("Failed to open test file\n");
+ } else if (serd_reader_read_document(reader)) {
+ FAIL("Failed reading test document\n");
+ } else if (rt.n_statements != 13) {
+ FAILF("Bad statement count %d\n", rt.n_statements);
+ } else if (!rt.graph || !serd_node_get_string(rt.graph) ||
+ strcmp(serd_node_get_string(rt.graph), "http://example.org/")) {
+ FAILF("Bad graph %p\n", rt.graph);
+ }
+ serd_reader_finish(reader);
serd_reader_free(reader);
fclose(fd);