aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_reader_writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-06-28 23:26:48 +0200
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commita083c64f506175029280ff76defa0ad7d7ae2ea0 (patch)
tree5e666749e352659d225d9c45c60bee06bd2bfe5c /test/test_reader_writer.c
parent20eb7727954f9d8b7164146895904bbe595f5932 (diff)
downloadserd-a083c64f506175029280ff76defa0ad7d7ae2ea0.tar.gz
serd-a083c64f506175029280ff76defa0ad7d7ae2ea0.tar.bz2
serd-a083c64f506175029280ff76defa0ad7d7ae2ea0.zip
Simplify input stream API
Diffstat (limited to 'test/test_reader_writer.c')
-rw-r--r--test/test_reader_writer.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index acd43ad1..1c4a415b 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -6,6 +6,7 @@
#include "serd/buffer.h"
#include "serd/env.h"
#include "serd/event.h"
+#include "serd/input_stream.h"
#include "serd/memory.h"
#include "serd/node.h"
#include "serd/reader.h"
@@ -22,7 +23,6 @@
#include <assert.h>
#include <errno.h>
-#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -116,11 +116,15 @@ test_write_errors(void)
const SerdSink* const sink = serd_writer_sink(writer);
SerdReader* const reader = serd_reader_new(world, SERD_TRIG, 0U, sink);
- SerdStatus st = serd_reader_start_string(reader, doc_string, NULL);
+ const char* position = doc_string;
+ SerdInputStream in = serd_open_input_string(&position);
+
+ SerdStatus st = serd_reader_start(reader, &in, NULL, 1);
assert(!st);
st = serd_reader_read_document(reader);
assert(st == SERD_BAD_WRITE);
+ assert(!serd_close_input(&in));
serd_reader_free(reader);
serd_writer_free(writer);
serd_env_free(env);
@@ -252,8 +256,8 @@ test_reader(const char* path)
SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, sink);
assert(reader);
- assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
- assert(serd_reader_read_document(reader) == SERD_FAILURE);
+ assert(serd_reader_read_chunk(reader) == SERD_BAD_CALL);
+ assert(serd_reader_read_document(reader) == SERD_BAD_CALL);
serd_reader_add_blank_prefix(reader, "tmp");
@@ -266,14 +270,12 @@ test_reader(const char* path)
# pragma GCC diagnostic pop
#endif
- 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_start_file(reader, path, true));
+ SerdInputStream in = serd_open_input_file(path);
+ assert(!serd_reader_start(reader, &in, NULL, 4096));
assert(!serd_reader_read_document(reader));
assert(rt.n_statement == 6);
assert(!serd_reader_finish(reader));
+ serd_close_input(&in);
serd_reader_free(reader);
serd_sink_free(sink);