aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_reader.c')
-rw-r--r--test/test_reader.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/test_reader.c b/test/test_reader.c
index a5595804..f33c3429 100644
--- a/test/test_reader.c
+++ b/test/test_reader.c
@@ -19,6 +19,7 @@
#endif
#include <assert.h>
+#include <stdbool.h>
#include <stdio.h>
#include <string.h>
@@ -365,6 +366,51 @@ test_read_turtle_chunks(const char* const path)
assert(!zix_remove(path));
}
+static size_t
+empty_test_read(void* buf, size_t size, size_t nmemb, void* stream)
+{
+ (void)buf;
+ (void)size;
+ (void)nmemb;
+ (void)stream;
+
+ assert(false);
+
+ return 0;
+}
+
+static int
+empty_test_error(void* stream)
+{
+ (void)stream;
+ return 0;
+}
+
+/// Test that reading SERD_SYNTAX_EMPTY "succeeds" without reading any input
+static void
+test_read_empty(void)
+{
+ SerdWorld* const world = serd_world_new();
+ ReaderTest rt = {0, 0, 0, 0};
+
+ SerdSink* const sink = serd_sink_new(&rt, test_sink, NULL);
+ assert(sink);
+
+ SerdReader* const reader = serd_reader_new(world, SERD_SYNTAX_EMPTY, 0, sink);
+ assert(reader);
+
+ SerdStatus st = serd_reader_start_stream(
+ reader, empty_test_read, empty_test_error, &rt, NULL, 1);
+ assert(st == SERD_SUCCESS);
+
+ assert(serd_reader_read_document(reader) == SERD_SUCCESS);
+ assert(rt.n_statement == 0);
+
+ serd_reader_free(reader);
+ serd_sink_free(sink);
+ serd_world_free(world);
+}
+
int
main(void)
{
@@ -379,6 +425,9 @@ main(void)
test_read_string();
test_read_eof_by_page(ttl_path);
test_read_eof_by_byte();
+ test_read_nquads_chunks(nq_path);
+ test_read_turtle_chunks(ttl_path);
+ test_read_empty();
assert(!zix_remove(dir));