diff options
author | David Robillard <d@drobilla.net> | 2021-07-11 20:47:51 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:07 -0500 |
commit | 6eb1fa15a06ab7de08e33add1540a45b83c5f0d8 (patch) | |
tree | 86d3cfedbf2ff76878eba6d14dc7fc259d1cbf46 /test/test_overflow.c | |
parent | d1ba721d37af61f2b529faaa16bd20ba1e161b06 (diff) | |
download | serd-6eb1fa15a06ab7de08e33add1540a45b83c5f0d8.tar.gz serd-6eb1fa15a06ab7de08e33add1540a45b83c5f0d8.tar.bz2 serd-6eb1fa15a06ab7de08e33add1540a45b83c5f0d8.zip |
Add SerdWorld for shared library state
Diffstat (limited to 'test/test_overflow.c')
-rw-r--r-- | test/test_overflow.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/test/test_overflow.c b/test/test_overflow.c index ac4a490b..a304ae1c 100644 --- a/test/test_overflow.c +++ b/test/test_overflow.c @@ -12,12 +12,13 @@ static const size_t min_stack_size = 4U * sizeof(size_t) + 240U; static const size_t max_stack_size = 1024U; static SerdStatus -test_size(const char* const str, +test_size(SerdWorld* const world, + const char* const str, const SerdSyntax syntax, const size_t stack_size) { SerdSink* sink = serd_sink_new(NULL, NULL); - SerdReader* const reader = serd_reader_new(syntax, sink, stack_size); + SerdReader* const reader = serd_reader_new(world, syntax, sink, stack_size); if (!reader) { return SERD_BAD_STACK; } @@ -31,15 +32,17 @@ test_size(const char* const str, } static void -test_all_sizes(const char* const str, const SerdSyntax syntax) +test_all_sizes(SerdWorld* const world, + const char* const str, + const SerdSyntax syntax) { // Ensure reading with the maximum stack size succeeds - SerdStatus st = test_size(str, syntax, max_stack_size); + SerdStatus st = test_size(world, str, syntax, max_stack_size); assert(!st); // Test with an increasingly smaller stack for (size_t size = max_stack_size; size > min_stack_size; --size) { - if ((st = test_size(str, syntax, size))) { + if ((st = test_size(world, str, syntax, size))) { assert(st == SERD_BAD_STACK); } } @@ -55,9 +58,13 @@ test_ntriples_overflow(void) NULL, }; + SerdWorld* const world = serd_world_new(); + for (const char* const* t = test_strings; *t; ++t) { - test_all_sizes(*t, SERD_NTRIPLES); + test_all_sizes(world, *t, SERD_NTRIPLES); } + + serd_world_free(world); } static void @@ -138,9 +145,13 @@ test_turtle_overflow(void) NULL, }; + SerdWorld* const world = serd_world_new(); + for (const char* const* t = test_strings; *t; ++t) { - test_all_sizes(*t, SERD_TURTLE); + test_all_sizes(world, *t, SERD_TURTLE); } + + serd_world_free(world); } int |