aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/serd_test.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 15a205db..067f5e2e 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -198,13 +198,14 @@ test_read_string(void)
assert(reader);
// 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_world_free(world);
@@ -627,8 +628,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);
@@ -638,17 +639,16 @@ 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://"));
-
- const SerdStatus st = serd_reader_read_file(reader, path);
- assert(!st);
- assert(rt->n_statements == 13);
- assert(rt->graph && serd_node_string(rt->graph) &&
- !strcmp(serd_node_string(rt->graph), "http://example.org/"));
+ 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));
- 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_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
{
@@ -669,7 +669,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);
}
@@ -690,7 +690,6 @@ test_reader(const char* path)
}
serd_reader_free(reader);
- free(rt);
serd_world_free(world);
}