diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_overflow.c | 4 | ||||
-rw-r--r-- | test/test_reader.c | 49 | ||||
-rw-r--r-- | test/test_reader_writer.c | 11 | ||||
-rw-r--r-- | test/test_writer.c | 32 |
4 files changed, 48 insertions, 48 deletions
diff --git a/test/test_overflow.c b/test/test_overflow.c index b81d4367..db20f734 100644 --- a/test/test_overflow.c +++ b/test/test_overflow.c @@ -23,7 +23,8 @@ test_size(SerdWorld* const world, serd_world_set_limits(world, limits); SerdSink* sink = serd_sink_new(NULL, NULL, NULL); - SerdReader* const reader = serd_reader_new(world, syntax, flags, sink); + SerdEnv* const env = serd_env_new(serd_empty_string()); + SerdReader* const reader = serd_reader_new(world, syntax, flags, env, sink); if (!reader) { return SERD_BAD_STACK; } @@ -38,6 +39,7 @@ test_size(SerdWorld* const world, serd_close_input(&in); serd_node_free(string_name); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); return st; diff --git a/test/test_reader.c b/test/test_reader.c index b5cefbe1..f1ec1d35 100644 --- a/test/test_reader.c +++ b/test/test_reader.c @@ -4,6 +4,7 @@ #undef NDEBUG #include "serd/caret.h" +#include "serd/env.h" #include "serd/event.h" #include "serd/input_stream.h" #include "serd/node.h" @@ -96,7 +97,9 @@ test_prepare_error(const char* const path) SerdSink* const sink = serd_sink_new(&rt, test_sink, NULL); assert(sink); - SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0, sink); + SerdEnv* const env = serd_env_new(serd_empty_string()); + SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0, env, sink); + assert(reader); SerdInputStream in = @@ -111,6 +114,7 @@ test_prepare_error(const char* const path) serd_close_input(&in); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); fclose(f); @@ -125,7 +129,9 @@ test_read_string(void) SerdSink* sink = serd_sink_new(&rt, test_sink, NULL); assert(sink); - SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, sink); + SerdEnv* const env = serd_env_new(serd_empty_string()); + SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink); + assert(reader); static const char* const string1 = @@ -162,6 +168,7 @@ test_read_string(void) assert(!serd_close_input(&in)); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); } @@ -221,11 +228,11 @@ test_read_eof_by_page(const char* const path) fflush(f); fseek(f, 0L, SEEK_SET); - SerdWorld* world = serd_world_new(); - ReaderTest ignored = {0, 0, 0, 0}; - SerdSink* sink = serd_sink_new(&ignored, test_sink, NULL); - SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, sink); - + SerdWorld* world = serd_world_new(); + ReaderTest ignored = {0, 0, 0, 0}; + SerdSink* sink = serd_sink_new(&ignored, test_sink, NULL); + SerdEnv* env = serd_env_new(serd_empty_string()); + SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink); SerdInputStream in = serd_open_input_stream((SerdReadFunc)fread, (SerdErrorFunc)ferror, NULL, f); @@ -237,6 +244,7 @@ test_read_eof_by_page(const char* const path) assert(!serd_close_input(&in)); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); fclose(f); @@ -250,7 +258,8 @@ test_read_eof_by_byte(void) SerdWorld* world = serd_world_new(); ReaderTest ignored = {0, 0, 0, 0}; SerdSink* sink = serd_sink_new(&ignored, test_sink, NULL); - SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, sink); + SerdEnv* env = serd_env_new(serd_empty_string()); + SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink); size_t n_reads = 0U; SerdInputStream in = serd_open_input_stream( @@ -265,6 +274,7 @@ test_read_eof_by_byte(void) assert(!serd_close_input(&in)); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); } @@ -300,7 +310,10 @@ test_read_nquads_chunks(const char* const path) SerdSink* const sink = serd_sink_new(&rt, test_sink, NULL); assert(sink); - SerdReader* const reader = serd_reader_new(world, SERD_NQUADS, 0U, sink); + SerdEnv* const env = serd_env_new(serd_empty_string()); + assert(env); + + SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink); assert(reader); SerdInputStream in = @@ -353,6 +366,7 @@ test_read_nquads_chunks(const char* const path) assert(!serd_close_input(&in)); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); fclose(f); @@ -382,7 +396,10 @@ test_read_turtle_chunks(const char* const path) SerdSink* sink = serd_sink_new(&rt, test_sink, NULL); assert(sink); - SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, sink); + SerdEnv* const env = serd_env_new(serd_empty_string()); + assert(env); + + SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink); assert(reader); SerdInputStream in = @@ -451,6 +468,7 @@ test_read_turtle_chunks(const char* const path) assert(!serd_close_input(&in)); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); fclose(f); @@ -467,7 +485,11 @@ test_read_empty(const char* const path) SerdSink* const sink = serd_sink_new(&rt, test_sink, NULL); assert(sink); - SerdReader* const reader = serd_reader_new(world, SERD_SYNTAX_EMPTY, 0, sink); + SerdEnv* const env = serd_env_new(serd_empty_string()); + assert(env); + + SerdReader* const reader = + serd_reader_new(world, SERD_SYNTAX_EMPTY, 0U, env, sink); assert(reader); FILE* const f = fopen(path, "w+b"); @@ -487,6 +509,7 @@ test_read_empty(const char* const path) fclose(f); assert(!zix_remove(path)); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); } @@ -516,7 +539,8 @@ test_error_cursor(void) SerdWorld* world = serd_world_new(); bool called = false; SerdSink* sink = serd_sink_new(&called, check_cursor, NULL); - SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0, sink); + SerdEnv* const env = serd_env_new(serd_empty_string()); + SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink); assert(sink); assert(reader); @@ -537,6 +561,7 @@ test_error_cursor(void) serd_node_free(string_name); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); } diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index df2c3957..3a20bb7a 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -117,7 +117,8 @@ test_write_errors(void) serd_writer_new(world, syntax, 0U, env, &out, 1U); const SerdSink* const sink = serd_writer_sink(writer); - SerdReader* const reader = serd_reader_new(world, SERD_TRIG, 0U, sink); + SerdReader* const reader = + serd_reader_new(world, SERD_TRIG, 0U, env, sink); const char* position = doc_string; SerdInputStream in = serd_open_input_string(&position); @@ -251,16 +252,19 @@ test_reader(const char* path) SerdSink* const sink = serd_sink_new(&rt, test_sink, NULL); assert(sink); + SerdEnv* const env = serd_env_new(serd_empty_string()); + assert(env); + // Test that too little stack space fails gracefully const SerdLimits old_limits = serd_world_limits(world); SerdLimits limits = old_limits; limits.reader_stack_size = 32U; serd_world_set_limits(world, limits); - assert(!serd_reader_new(world, SERD_TURTLE, 0U, sink)); + assert(!serd_reader_new(world, SERD_TURTLE, 0U, env, sink)); // Restore limits and successfully create reader serd_world_set_limits(world, old_limits); - SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, sink); + SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0U, env, sink); assert(reader); assert(serd_reader_read_chunk(reader) == SERD_BAD_CALL); @@ -285,6 +289,7 @@ test_reader(const char* path) serd_close_input(&in); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); } diff --git a/test/test_writer.c b/test/test_writer.c index 9ce69c55..f76cc800 100644 --- a/test/test_writer.c +++ b/test/test_writer.c @@ -66,37 +66,6 @@ test_write_bad_event(void) } static void -test_write_bad_prefix(void) -{ - SerdWorld* world = serd_world_new(); - SerdEnv* env = serd_env_new(serd_empty_string()); - SerdBuffer buffer = {NULL, 0}; - SerdOutputStream output = serd_open_output_buffer(&buffer); - SerdWriter* writer = - serd_writer_new(world, SERD_TURTLE, 0U, env, &output, 1U); - - assert(writer); - - SerdNode* name = serd_new_string(serd_string("eg")); - SerdNode* uri = serd_new_uri(serd_string("rel")); - - assert(serd_sink_write_prefix(serd_writer_sink(writer), name, uri) == - SERD_BAD_ARG); - - serd_buffer_close(&buffer); - - char* const out = (char*)buffer.buf; - assert(!strcmp(out, "")); - serd_free(out); - - serd_node_free(uri); - serd_node_free(name); - serd_writer_free(writer); - serd_env_free(env); - serd_world_free(world); -} - -static void test_write_long_literal(void) { SerdWorld* world = serd_world_new(); @@ -442,7 +411,6 @@ main(void) { test_writer_new(); test_write_bad_event(); - test_write_bad_prefix(); test_write_long_literal(); test_writer_cleanup(); test_strict_write(); |