diff options
author | David Robillard <d@drobilla.net> | 2018-04-29 15:24:05 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:58 +0100 |
commit | 3bdf4986884e26b40b0c9d010634a0c572c84122 (patch) | |
tree | 666235b035bf0d637d15c6461393508f90660801 /tests | |
parent | 79bd5c789631ea51071564813046e34b304e1bc7 (diff) | |
download | serd-3bdf4986884e26b40b0c9d010634a0c572c84122.tar.gz serd-3bdf4986884e26b40b0c9d010634a0c572c84122.tar.bz2 serd-3bdf4986884e26b40b0c9d010634a0c572c84122.zip |
Add SerdWorld for shared library state
Diffstat (limited to 'tests')
-rw-r--r-- | tests/free_null_test.c | 1 | ||||
-rw-r--r-- | tests/read_chunk_test.c | 6 | ||||
-rw-r--r-- | tests/serd_test.c | 26 |
3 files changed, 25 insertions, 8 deletions
diff --git a/tests/free_null_test.c b/tests/free_null_test.c index 121a66cd..08f2b513 100644 --- a/tests/free_null_test.c +++ b/tests/free_null_test.c @@ -25,6 +25,7 @@ main(void) { serd_free(NULL); serd_node_free(NULL); + serd_world_free(NULL); serd_env_free(NULL); serd_reader_free(NULL); serd_writer_free(NULL); diff --git a/tests/read_chunk_test.c b/tests/read_chunk_test.c index 3cc32bd9..decfe829 100644 --- a/tests/read_chunk_test.c +++ b/tests/read_chunk_test.c @@ -79,9 +79,10 @@ on_end(void* handle, const SerdNode* node) int main(void) { - const SerdSink sink = {NULL, on_base, on_prefix, on_statement, on_end}; + SerdWorld* world = serd_world_new(); + const SerdSink sink = {NULL, on_base, on_prefix, on_statement, on_end}; - SerdReader* reader = serd_reader_new(SERD_TURTLE, &sink); + SerdReader* reader = serd_reader_new(world, SERD_TURTLE, &sink); assert(reader); assert(!serd_reader_start_string(reader, @@ -106,5 +107,6 @@ main(void) assert(serd_reader_read_chunk(reader) == SERD_FAILURE); serd_reader_free(reader); + serd_world_free(world); return 0; } 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 |