From 3bdf4986884e26b40b0c9d010634a0c572c84122 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 29 Apr 2018 15:24:05 +0200 Subject: Add SerdWorld for shared library state --- tests/serd_test.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'tests/serd_test.c') diff --git a/tests/serd_test.c b/tests/serd_test.c index acfd1a7b..2171710b 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -126,11 +126,12 @@ test_file_uri(const char* hostname, static void test_read_chunks(void) { + SerdWorld* world = serd_world_new(); ReaderTest* const rt = (ReaderTest*)calloc(1, sizeof(ReaderTest)); FILE* const f = tmpfile(); static const char null = 0; SerdSink sink = {rt, NULL, NULL, test_sink, NULL}; - SerdReader* reader = serd_reader_new(SERD_TURTLE, &sink); + SerdReader* reader = serd_reader_new(world, SERD_TURTLE, &sink); assert(reader); assert(f); @@ -184,14 +185,16 @@ test_read_chunks(void) serd_reader_free(reader); fclose(f); free(rt); + serd_world_free(world); } static void test_read_string(void) { + SerdWorld* world = serd_world_new(); ReaderTest* rt = (ReaderTest*)calloc(1, sizeof(ReaderTest)); SerdSink sink = {rt, NULL, NULL, test_sink, NULL}; - SerdReader* reader = serd_reader_new(SERD_TURTLE, &sink); + SerdReader* reader = serd_reader_new(world, SERD_TURTLE, &sink); assert(reader); // Test reading a string that ends exactly at the end of input (no newline) @@ -204,6 +207,7 @@ test_read_string(void) assert(rt->n_statements == 1); serd_reader_free(reader); + serd_world_free(world); } static void @@ -501,8 +505,15 @@ test_writer(const char* const path) SerdEnv* env = serd_env_new(NULL); assert(fd); - SerdWriter* writer = serd_writer_new( - SERD_TURTLE, (SerdStyle)0, env, NULL, (SerdWriteFunc)fwrite, fd); + SerdWorld* world = serd_world_new(); + + SerdWriter* writer = serd_writer_new(world, + SERD_TURTLE, + (SerdStyle)0, + env, + NULL, + (SerdWriteFunc)fwrite, + fd); assert(writer); serd_writer_chop_blank_prefix(writer, "tmp"); @@ -578,7 +589,7 @@ test_writer(const char* const path) // Test buffer sink SerdBuffer buffer = { NULL, 0 }; writer = serd_writer_new( - SERD_TURTLE, (SerdStyle)0, env, NULL, serd_buffer_sink, &buffer); + world, SERD_TURTLE, (SerdStyle)0, env, NULL, serd_buffer_sink, &buffer); o = serd_node_new_string(SERD_URI, "http://example.org/base"); assert(!serd_writer_set_base_uri(writer, o)); @@ -591,15 +602,17 @@ test_writer(const char* const path) serd_free(out); serd_env_free(env); + serd_world_free(world); fclose(fd); } static void test_reader(const char* path) { + SerdWorld* world = serd_world_new(); ReaderTest* rt = (ReaderTest*)calloc(1, sizeof(ReaderTest)); SerdSink sink = { rt, NULL, NULL, test_sink, NULL }; - SerdReader* reader = serd_reader_new(SERD_TURTLE, &sink); + SerdReader* reader = serd_reader_new(world, SERD_TURTLE, &sink); assert(reader); SerdNode* g = serd_node_new_string(SERD_URI, "http://example.org/"); @@ -661,6 +674,7 @@ test_reader(const char* path) serd_reader_free(reader); free(rt); + serd_world_free(world); } int -- cgit v1.2.1