summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/bad_syntax.lv2/test_bad_syntax.c13
-rw-r--r--test/failed_instantiation.lv2/test_failed_instantiation.c13
-rw-r--r--test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c13
-rw-r--r--test/lib_descriptor.lv2/test_lib_descriptor.c13
-rw-r--r--test/lilv_test_uri_map.h2
-rw-r--r--test/lilv_test_utils.c8
-rw-r--r--test/missing_descriptor.lv2/test_missing_descriptor.c13
-rw-r--r--test/missing_name.lv2/test_missing_name.c13
-rw-r--r--test/missing_plugin.lv2/test_missing_plugin.c13
-rw-r--r--test/missing_port.lv2/test_missing_port.c13
-rw-r--r--test/missing_port_name.lv2/test_missing_port_name.c13
-rw-r--r--test/test_state.c63
12 files changed, 82 insertions, 108 deletions
diff --git a/test/bad_syntax.lv2/test_bad_syntax.c b/test/bad_syntax.lv2/test_bad_syntax.c
index 5f10828..b1d7986 100644
--- a/test/bad_syntax.lv2/test_bad_syntax.c
+++ b/test/bad_syntax.lv2/test_bad_syntax.c
@@ -6,8 +6,6 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,13 +23,12 @@ main(int argc, char** argv)
LilvWorld* world = lilv_world_new();
// Load test plugin bundle
- uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
- SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
- LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
- lilv_world_load_bundle(world, bundle_uri);
+ char* abs_bundle = lilv_path_absolute(bundle_path);
+ SerdNode* bundle =
+ serd_new_file_uri(SERD_MEASURE_STRING(abs_bundle), SERD_EMPTY_STRING());
+ lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
+ serd_node_free(bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/failed_instantiation.lv2/test_failed_instantiation.c b/test/failed_instantiation.lv2/test_failed_instantiation.c
index 8dbefc3..846cdce 100644
--- a/test/failed_instantiation.lv2/test_failed_instantiation.c
+++ b/test/failed_instantiation.lv2/test_failed_instantiation.c
@@ -6,8 +6,6 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,13 +23,12 @@ main(int argc, char** argv)
LilvWorld* world = lilv_world_new();
// Load test plugin bundle
- uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
- SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
- LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
- lilv_world_load_bundle(world, bundle_uri);
+ char* abs_bundle = lilv_path_absolute(bundle_path);
+ SerdNode* bundle =
+ serd_new_file_uri(SERD_MEASURE_STRING(abs_bundle), SERD_EMPTY_STRING());
+ lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
+ serd_node_free(bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c b/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c
index 71a3b96..9d2c377 100644
--- a/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c
+++ b/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c
@@ -6,8 +6,6 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,13 +23,12 @@ main(int argc, char** argv)
LilvWorld* world = lilv_world_new();
// Load test plugin bundle
- uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
- SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
- LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
- lilv_world_load_bundle(world, bundle_uri);
+ char* abs_bundle = lilv_path_absolute(bundle_path);
+ SerdNode* bundle =
+ serd_new_file_uri(SERD_MEASURE_STRING(abs_bundle), SERD_EMPTY_STRING());
+ lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
+ serd_node_free(bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/lib_descriptor.lv2/test_lib_descriptor.c b/test/lib_descriptor.lv2/test_lib_descriptor.c
index bf79be8..650dd79 100644
--- a/test/lib_descriptor.lv2/test_lib_descriptor.c
+++ b/test/lib_descriptor.lv2/test_lib_descriptor.c
@@ -6,8 +6,6 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,13 +23,12 @@ main(int argc, char** argv)
LilvWorld* world = lilv_world_new();
// Load test plugin bundle
- uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
- SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
- LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
- lilv_world_load_bundle(world, bundle_uri);
+ char* abs_bundle = lilv_path_absolute(bundle_path);
+ SerdNode* bundle =
+ serd_new_file_uri(SERD_MEASURE_STRING(abs_bundle), SERD_EMPTY_STRING());
+ lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
+ serd_node_free(bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/lilv_test_uri_map.h b/test/lilv_test_uri_map.h
index 5f85c86..e976381 100644
--- a/test/lilv_test_uri_map.h
+++ b/test/lilv_test_uri_map.h
@@ -63,7 +63,7 @@ map_uri(LV2_URID_Map_Handle handle, const char* uri)
}
}
- assert(serd_uri_string_has_scheme((const uint8_t*)uri));
+ assert(serd_uri_string_has_scheme(uri));
map->uris = (char**)realloc(map->uris, ++map->n_uris * sizeof(char*));
map->uris[map->n_uris - 1] = lilv_strdup(uri);
diff --git a/test/lilv_test_utils.c b/test/lilv_test_utils.c
index bc6eb3d..7a494ce 100644
--- a/test/lilv_test_utils.c
+++ b/test/lilv_test_utils.c
@@ -94,15 +94,15 @@ create_bundle(LilvTestEnv* env,
return 1;
}
- SerdNode s = serd_node_new_file_uri(
- (const uint8_t*)env->test_bundle_path, NULL, NULL, true);
+ SerdNode* s = serd_new_file_uri(SERD_MEASURE_STRING(env->test_bundle_path),
+ SERD_EMPTY_STRING());
- env->test_bundle_uri = lilv_new_uri(env->world, (const char*)s.buf);
+ env->test_bundle_uri = lilv_new_uri(env->world, serd_node_string(s));
env->test_manifest_path =
lilv_path_join(env->test_bundle_path, "manifest.ttl");
env->test_content_path = lilv_path_join(env->test_bundle_path, "plugin.ttl");
- serd_node_free(&s);
+ serd_node_free(s);
FILE* const manifest_file = fopen(env->test_manifest_path, "w");
if (!manifest_file) {
diff --git a/test/missing_descriptor.lv2/test_missing_descriptor.c b/test/missing_descriptor.lv2/test_missing_descriptor.c
index 330e534..00ed8ae 100644
--- a/test/missing_descriptor.lv2/test_missing_descriptor.c
+++ b/test/missing_descriptor.lv2/test_missing_descriptor.c
@@ -6,8 +6,6 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,13 +23,12 @@ main(int argc, char** argv)
LilvWorld* world = lilv_world_new();
// Load test plugin bundle
- uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
- SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
- LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
- lilv_world_load_bundle(world, bundle_uri);
+ char* abs_bundle = lilv_path_absolute(bundle_path);
+ SerdNode* bundle =
+ serd_new_file_uri(SERD_MEASURE_STRING(abs_bundle), SERD_EMPTY_STRING());
+ lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
+ serd_node_free(bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/missing_name.lv2/test_missing_name.c b/test/missing_name.lv2/test_missing_name.c
index 5cb069a..78f1cab 100644
--- a/test/missing_name.lv2/test_missing_name.c
+++ b/test/missing_name.lv2/test_missing_name.c
@@ -6,8 +6,6 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,13 +23,12 @@ main(int argc, char** argv)
LilvWorld* world = lilv_world_new();
// Load test plugin bundle
- uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
- SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
- LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
- lilv_world_load_bundle(world, bundle_uri);
+ char* abs_bundle = lilv_path_absolute(bundle_path);
+ SerdNode* bundle =
+ serd_new_file_uri(SERD_MEASURE_STRING(abs_bundle), SERD_EMPTY_STRING());
+ lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
+ serd_node_free(bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/missing_plugin.lv2/test_missing_plugin.c b/test/missing_plugin.lv2/test_missing_plugin.c
index 861fcba..84e664d 100644
--- a/test/missing_plugin.lv2/test_missing_plugin.c
+++ b/test/missing_plugin.lv2/test_missing_plugin.c
@@ -6,8 +6,6 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,13 +23,12 @@ main(int argc, char** argv)
LilvWorld* world = lilv_world_new();
// Load test plugin bundle
- uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
- SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
- LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
- lilv_world_load_bundle(world, bundle_uri);
+ char* abs_bundle = lilv_path_absolute(bundle_path);
+ SerdNode* bundle =
+ serd_new_file_uri(SERD_MEASURE_STRING(abs_bundle), SERD_EMPTY_STRING());
+ lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
+ serd_node_free(bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/missing_port.lv2/test_missing_port.c b/test/missing_port.lv2/test_missing_port.c
index ec6713c..c752399 100644
--- a/test/missing_port.lv2/test_missing_port.c
+++ b/test/missing_port.lv2/test_missing_port.c
@@ -6,8 +6,6 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,13 +23,12 @@ main(int argc, char** argv)
LilvWorld* world = lilv_world_new();
// Load test plugin bundle
- uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
- SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
- LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
- lilv_world_load_bundle(world, bundle_uri);
+ char* const abs_bundle = lilv_path_absolute(bundle_path);
+ const SerdStringView abs_bundle_view = SERD_MEASURE_STRING(abs_bundle);
+ SerdNode* bundle = serd_new_file_uri(abs_bundle_view, SERD_EMPTY_STRING());
+ lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
+ serd_node_free(bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/missing_port_name.lv2/test_missing_port_name.c b/test/missing_port_name.lv2/test_missing_port_name.c
index 4d017d9..d61fa63 100644
--- a/test/missing_port_name.lv2/test_missing_port_name.c
+++ b/test/missing_port_name.lv2/test_missing_port_name.c
@@ -6,8 +6,6 @@
#include "serd/serd.h"
#include <assert.h>
-#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,13 +23,12 @@ main(int argc, char** argv)
LilvWorld* world = lilv_world_new();
// Load test plugin bundle
- uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(bundle_path);
- SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
- LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
- lilv_world_load_bundle(world, bundle_uri);
+ char* abs_bundle = lilv_path_absolute(bundle_path);
+ SerdNode* bundle =
+ serd_new_file_uri(SERD_MEASURE_STRING(abs_bundle), SERD_EMPTY_STRING());
+ lilv_world_load_bundle(world, bundle);
free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
+ serd_node_free(bundle);
LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
diff --git a/test/test_state.c b/test/test_state.c
index 533c3a9..e12bfdc 100644
--- a/test/test_state.c
+++ b/test/test_state.c
@@ -246,10 +246,12 @@ static const LilvPlugin*
load_test_plugin(const TestContext* const ctx)
{
LilvWorld* world = ctx->env->world;
- uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(LILV_TEST_BUNDLE);
- SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0, true);
- LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
- LilvNode* plugin_uri = lilv_new_uri(world, TEST_PLUGIN_URI);
+ char* abs_bundle = lilv_path_absolute(LILV_TEST_BUNDLE);
+ SerdNode* bundle =
+ serd_new_file_uri(SERD_MEASURE_STRING(abs_bundle), SERD_EMPTY_STRING());
+
+ LilvNode* bundle_uri = lilv_new_uri(world, serd_node_string(bundle));
+ LilvNode* plugin_uri = lilv_new_uri(world, TEST_PLUGIN_URI);
lilv_world_load_bundle(world, bundle_uri);
@@ -258,7 +260,7 @@ load_test_plugin(const TestContext* const ctx)
lilv_node_free(plugin_uri);
lilv_node_free(bundle_uri);
- serd_node_free(&bundle);
+ serd_node_free(bundle);
free(abs_bundle);
assert(plugin);
@@ -531,26 +533,13 @@ test_string_round_trip(void)
}
static SerdStatus
-count_sink(void* const handle,
- const SerdStatementFlags flags,
- const SerdNode* const graph,
- const SerdNode* const subject,
- const SerdNode* const predicate,
- const SerdNode* const object,
- const SerdNode* const object_datatype,
- const SerdNode* const object_lang)
+count_func(void* const handle, const SerdEvent* const event)
{
- (void)flags;
- (void)graph;
- (void)subject;
- (void)predicate;
- (void)object;
- (void)object_datatype;
- (void)object_lang;
-
size_t* const n_statements = (size_t*)handle;
- ++(*n_statements);
+ if (event->type == SERD_STATEMENT) {
+ ++(*n_statements);
+ }
return SERD_SUCCESS;
}
@@ -560,15 +549,27 @@ count_statements(const char* path)
{
size_t n_statements = 0;
- SerdReader* reader = serd_reader_new(
- SERD_TURTLE, &n_statements, NULL, NULL, NULL, count_sink, NULL);
+ SerdWorld* const world = serd_world_new();
+ const SerdStringView path_view = SERD_MEASURE_STRING(path);
+ SerdNode* const base = serd_new_file_uri(path_view, SERD_EMPTY_STRING());
+
+ SerdEnv* const env = serd_env_new(serd_node_string_view(base));
+ SerdSink* const sink = serd_sink_new(&n_statements, count_func, NULL);
+ SerdReader* const reader =
+ serd_reader_new(world, SERD_TURTLE, 0, env, sink, 4096);
- SerdNode uri = serd_node_new_file_uri((const uint8_t*)path, NULL, NULL, true);
+ SerdByteSource* const source = serd_byte_source_new_filename(path, 4096);
- assert(!serd_reader_read_file(reader, uri.buf));
+ SerdStatus st = SERD_SUCCESS;
+ assert(!(st = serd_reader_start(reader, source)));
+ assert(!(st = serd_reader_read_document(reader)));
- serd_node_free(&uri);
+ serd_byte_source_free(source);
serd_reader_free(reader);
+ serd_sink_free(sink);
+ serd_env_free(env);
+ serd_node_free(base);
+ serd_world_free(world);
return n_statements;
}
@@ -917,10 +918,10 @@ test_world_round_trip(void)
"state.ttl"));
// Load state bundle into world
- SerdNode bundle_uri =
- serd_node_new_file_uri((const uint8_t*)bundle_path, 0, 0, true);
+ SerdNode* bundle_uri =
+ serd_new_file_uri(SERD_MEASURE_STRING(bundle_path), SERD_EMPTY_STRING());
LilvNode* const bundle_node =
- lilv_new_uri(world, (const char*)bundle_uri.buf);
+ lilv_new_uri(world, serd_node_string(bundle_uri));
LilvNode* const state_node = lilv_new_uri(world, state_uri);
lilv_world_load_bundle(world, bundle_node);
lilv_world_load_resource(world, state_node);
@@ -944,7 +945,7 @@ test_world_round_trip(void)
lilv_state_free(restored);
lilv_node_free(state_node);
lilv_node_free(bundle_node);
- serd_node_free(&bundle_uri);
+ serd_node_free(bundle_uri);
lilv_state_free(start_state);
free(bundle_path);
test_context_free(ctx);