aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_reader_writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-07-08 16:15:46 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 16:27:02 -0500
commitfb95ceca3b744e47e973585aa682515365ac9eb0 (patch)
tree264e30801d634ea580478a10095938448b4962c8 /test/test_reader_writer.c
parent8978501e5cf06f366eb14f6ef5f5f7f2f8e34986 (diff)
downloadserd-fb95ceca3b744e47e973585aa682515365ac9eb0.tar.gz
serd-fb95ceca3b744e47e973585aa682515365ac9eb0.tar.bz2
serd-fb95ceca3b744e47e973585aa682515365ac9eb0.zip
Use a fixed-size reader stack
Diffstat (limited to 'test/test_reader_writer.c')
-rw-r--r--test/test_reader_writer.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 1c028080..0ef8a96b 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -186,7 +186,7 @@ test_read_nquads_chunks(const char* const path)
ReaderTest* const rt = (ReaderTest*)calloc(1, sizeof(ReaderTest));
SerdSink* const sink = serd_sink_new(rt, NULL);
- SerdReader* const reader = serd_reader_new(SERD_NQUADS, sink);
+ SerdReader* const reader = serd_reader_new(SERD_NQUADS, sink, 4096);
assert(reader);
assert(sink);
@@ -268,7 +268,7 @@ test_read_turtle_chunks(const char* const path)
ReaderTest* const rt = (ReaderTest*)calloc(1, sizeof(ReaderTest));
SerdSink* const sink = serd_sink_new(rt, NULL);
- SerdReader* const reader = serd_reader_new(SERD_TURTLE, sink);
+ SerdReader* const reader = serd_reader_new(SERD_TURTLE, sink, 4096);
assert(reader);
assert(sink);
@@ -352,7 +352,7 @@ test_read_string(void)
{
ReaderTest* rt = (ReaderTest*)calloc(1, sizeof(ReaderTest));
SerdSink* sink = serd_sink_new(rt, NULL);
- SerdReader* reader = serd_reader_new(SERD_TURTLE, sink);
+ SerdReader* reader = serd_reader_new(SERD_TURTLE, sink, 4096);
assert(reader);
assert(sink);
@@ -433,7 +433,7 @@ test_write_errors(void)
serd_writer_new(syntax, style, env, faulty_sink, &ctx);
const SerdSink* const sink = serd_writer_sink(writer);
- SerdReader* const reader = serd_reader_new(SERD_TRIG, sink);
+ SerdReader* const reader = serd_reader_new(SERD_TRIG, sink, 4096U);
serd_reader_set_error_sink(reader, quiet_error_sink, NULL);
serd_writer_set_error_sink(writer, quiet_error_sink, NULL);
@@ -542,17 +542,21 @@ test_writer(const char* const path)
static void
test_reader(const char* path)
{
- ReaderTest rt = {0, 0, 0, 0, NULL};
- SerdSink* const sink = serd_sink_new(&rt, NULL);
- SerdReader* reader = serd_reader_new(SERD_TURTLE, sink);
+ ReaderTest rt = {0, 0, 0, 0, NULL};
+ SerdSink* const sink = serd_sink_new(&rt, NULL);
assert(sink);
- assert(reader);
serd_sink_set_base_func(sink, test_base_sink);
serd_sink_set_prefix_func(sink, test_prefix_sink);
serd_sink_set_statement_func(sink, test_statement_sink);
serd_sink_set_end_func(sink, test_end_sink);
+ // Test that too little stack space fails gracefully
+ assert(!serd_reader_new(SERD_TURTLE, sink, 32));
+
+ SerdReader* reader = serd_reader_new(SERD_TURTLE, sink, 4096);
+ assert(reader);
+
assert(serd_reader_read_chunk(reader) == SERD_FAILURE);
assert(serd_reader_read_document(reader) == SERD_FAILURE);