aboutsummaryrefslogtreecommitdiffstats
path: root/tests/serd_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/serd_test.c')
-rw-r--r--tests/serd_test.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 5b60a03c..f5761fe7 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -632,8 +632,8 @@ main(void)
// Rewind and test reader
fseek(fd, 0, SEEK_SET);
- ReaderTest* rt = (ReaderTest*)calloc(1, sizeof(ReaderTest));
- SerdSinkInterface sink = { rt, NULL, NULL, test_sink, NULL };
+ ReaderTest rt = { 0, NULL };
+ SerdSinkInterface sink = { &rt, NULL, NULL, test_sink, NULL };
SerdReader* reader = serd_reader_new(world, SERD_TURTLE, &sink);
if (!reader) {
FAIL("Failed to create reader\n");
@@ -645,23 +645,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_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_end_stream(reader);
if (!serd_reader_read_string(reader, "This isn't Turtle at all.")) {
FAIL("Parsed invalid string successfully.\n");