aboutsummaryrefslogtreecommitdiffstats
path: root/tests/serd_test.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-12-26 19:25:51 -0500
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:58 +0100
commit36a418f0d8dfd10007e48d6e8cb796cfa8aa4d88 (patch)
treed498db3c1870a90e7ec91eba2ea4dcb9987f30e2 /tests/serd_test.c
parent5d65a0b7b687ffbbd624d75b42ac3336ce353c39 (diff)
downloadserd-36a418f0d8dfd10007e48d6e8cb796cfa8aa4d88.tar.gz
serd-36a418f0d8dfd10007e48d6e8cb796cfa8aa4d88.tar.bz2
serd-36a418f0d8dfd10007e48d6e8cb796cfa8aa4d88.zip
Hide fopen wrapper and use reader interface consistently
Diffstat (limited to 'tests/serd_test.c')
-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);
}