diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_overflow.c | 4 | ||||
-rw-r--r-- | test/test_read_chunk.c | 4 | ||||
-rw-r--r-- | test/test_reader.c | 39 | ||||
-rw-r--r-- | test/test_reader_writer.c | 9 | ||||
-rw-r--r-- | test/test_writer.c | 30 |
5 files changed, 40 insertions, 46 deletions
diff --git a/test/test_overflow.c b/test/test_overflow.c index 335cd5c7..7f08112d 100644 --- a/test/test_overflow.c +++ b/test/test_overflow.c @@ -33,14 +33,16 @@ test_size(SerdWorld* const world, { SerdSink* sink = serd_sink_new(NULL, NULL, NULL); SerdByteSource* byte_source = serd_byte_source_new_string(str, NULL); + SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); SerdReader* const reader = - serd_reader_new(world, syntax, flags, sink, stack_size); + serd_reader_new(world, syntax, flags, env, sink, stack_size); assert(reader); serd_reader_start(reader, byte_source); const SerdStatus st = serd_reader_read_document(reader); serd_reader_free(reader); + serd_env_free(env); serd_byte_source_free(byte_source); serd_sink_free(sink); diff --git a/test/test_read_chunk.c b/test/test_read_chunk.c index f2681e32..52bb7804 100644 --- a/test/test_read_chunk.c +++ b/test/test_read_chunk.c @@ -106,7 +106,8 @@ main(void) "eg:s4 eg:p1 [ eg:p3 eg:o1 ] .\n", NULL); - SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0, sink, 4096); + SerdEnv* env = serd_env_new(SERD_EMPTY_STRING()); + SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0, env, sink, 4096); assert(reader); assert(!serd_reader_start(reader, byte_source)); @@ -123,6 +124,7 @@ main(void) assert(!serd_reader_finish(reader)); serd_reader_free(reader); + serd_env_free(env); serd_byte_source_free(byte_source); serd_sink_free(sink); serd_world_free(world); diff --git a/test/test_reader.c b/test/test_reader.c index 7bc8ab48..5cc8d634 100644 --- a/test/test_reader.c +++ b/test/test_reader.c @@ -64,7 +64,10 @@ test_prepare_error(void) SerdSink* const sink = serd_sink_new(&n_statements, count_statements, NULL); assert(sink); - SerdReader* const reader = serd_reader_new(world, SERD_TURTLE, 0, sink, 4096); + SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); + SerdReader* const reader = + serd_reader_new(world, SERD_TURTLE, 0, env, sink, 4096); + assert(reader); SerdByteSource* byte_source = serd_byte_source_new_function( @@ -77,6 +80,7 @@ test_prepare_error(void) serd_byte_source_free(byte_source); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); } @@ -90,7 +94,10 @@ test_read_string(void) SerdSink* sink = serd_sink_new(&n_statements, count_statements, NULL); assert(sink); - SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0u, sink, 4096); + SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); + SerdReader* const reader = + serd_reader_new(world, SERD_TURTLE, 0, env, sink, 4096); + assert(reader); SerdByteSource* byte_source = @@ -119,6 +126,7 @@ test_read_string(void) assert(!serd_reader_finish(reader)); serd_reader_free(reader); + serd_env_free(env); serd_byte_source_free(byte_source); serd_sink_free(sink); serd_world_free(world); @@ -179,10 +187,12 @@ test_read_eof_by_page(void) fflush(temp); fseek(temp, 0L, SEEK_SET); - SerdWorld* world = serd_world_new(); - size_t ignored = 0u; - SerdSink* sink = serd_sink_new(&ignored, count_statements, NULL); - SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0u, sink, 4096); + SerdWorld* world = serd_world_new(); + size_t ignored = 0u; + SerdSink* sink = serd_sink_new(&ignored, count_statements, NULL); + SerdEnv* env = serd_env_new(SERD_EMPTY_STRING()); + + SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0u, env, sink, 4096); SerdByteSource* byte_source = serd_byte_source_new_function( (SerdReadFunc)fread, (SerdStreamErrorFunc)ferror, NULL, temp, NULL, 4096); @@ -195,6 +205,7 @@ test_read_eof_by_page(void) serd_byte_source_free(byte_source); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); fclose(temp); @@ -204,10 +215,12 @@ test_read_eof_by_page(void) static void test_read_eof_by_byte(void) { - SerdWorld* world = serd_world_new(); - size_t ignored = 0u; - SerdSink* sink = serd_sink_new(&ignored, count_statements, NULL); - SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0u, sink, 4096); + SerdWorld* world = serd_world_new(); + size_t ignored = 0u; + SerdSink* sink = serd_sink_new(&ignored, count_statements, NULL); + SerdEnv* env = serd_env_new(SERD_EMPTY_STRING()); + + SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0u, env, sink, 4096); size_t n_reads = 0u; SerdByteSource* byte_source = @@ -227,6 +240,7 @@ test_read_eof_by_byte(void) serd_byte_source_free(byte_source); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); serd_world_free(world); } @@ -242,8 +256,10 @@ test_read_chunks(void) SerdSink* const sink = serd_sink_new(&n_statements, count_statements, NULL); assert(sink); + SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); SerdReader* const reader = - serd_reader_new(world, SERD_TURTLE, 0u, sink, 4096); + serd_reader_new(world, SERD_TURTLE, 0u, env, sink, 4096); + assert(reader); SerdByteSource* byte_source = serd_byte_source_new_function( @@ -292,6 +308,7 @@ test_read_chunks(void) serd_byte_source_free(byte_source); serd_reader_free(reader); + serd_env_free(env); serd_sink_free(sink); fclose(f); serd_world_free(world); diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index 3a9bf7c9..0124784c 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -142,10 +142,12 @@ test_reader(const char* path) SerdSink* const sink = serd_sink_new(&n_statements, count_statements, NULL); assert(sink); - // Test that too little stack space fails gracefully - assert(!serd_reader_new(world, SERD_TURTLE, 0u, sink, 32)); + SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING()); + assert(env); - SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0u, sink, 4096); + // Test that too little stack space fails gracefully + assert(!serd_reader_new(world, SERD_TURTLE, 0u, env, sink, 32)); + SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0u, env, sink, 4096); assert(reader); assert(serd_reader_read_document(reader) == SERD_ERR_BAD_CALL); @@ -170,6 +172,7 @@ test_reader(const char* path) serd_byte_source_free(byte_source); 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 df8ba520..dc1ebfcb 100644 --- a/test/test_writer.c +++ b/test/test_writer.c @@ -51,35 +51,6 @@ test_write_bad_event(void) } static void -test_write_bad_prefix(void) -{ - SerdWorld* world = serd_world_new(); - SerdNodes* nodes = serd_world_nodes(world); - SerdEnv* env = serd_env_new(SERD_EMPTY_STRING()); - SerdBuffer buffer = {NULL, 0}; - SerdByteSink* byte_sink = serd_byte_sink_new_buffer(&buffer); - - SerdWriter* writer = serd_writer_new(world, SERD_TURTLE, 0u, env, byte_sink); - assert(writer); - - const SerdNode* name = serd_nodes_string(nodes, SERD_STRING("eg")); - const SerdNode* uri = serd_nodes_uri(nodes, SERD_STRING("rel")); - - assert(serd_sink_write_prefix(serd_writer_sink(writer), name, uri) == - SERD_ERR_BAD_ARG); - - char* const out = serd_buffer_sink_finish(&buffer); - - assert(!strcmp(out, "")); - serd_free(out); - - serd_writer_free(writer); - serd_byte_sink_free(byte_sink); - serd_env_free(env); - serd_world_free(world); -} - -static void test_write_long_literal(void) { SerdWorld* world = serd_world_new(); @@ -319,7 +290,6 @@ int main(void) { test_write_bad_event(); - test_write_bad_prefix(); test_write_long_literal(); test_writer_stack_overflow(); test_strict_write(); |