summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-12-26 19:22:03 +0100
committerDavid Robillard <d@drobilla.net>2020-12-31 14:15:00 +0100
commit31cc05d5ef6e840ebe2b4c265f374f913f4758cc (patch)
tree87302811f8df1f16e0bd4785ff405906a993b7d0 /test
parent7a51f0b8e95d29b5e053db97bf72094e847ee7ef (diff)
downloadlilv-31cc05d5ef6e840ebe2b4c265f374f913f4758cc.tar.gz
lilv-31cc05d5ef6e840ebe2b4c265f374f913f4758cc.tar.bz2
lilv-31cc05d5ef6e840ebe2b4c265f374f913f4758cc.zip
Format all code with clang-format
Diffstat (limited to 'test')
-rw-r--r--test/bad_syntax.lv2/bad_syntax.c68
-rw-r--r--test/bad_syntax.lv2/test_bad_syntax.c57
-rw-r--r--test/failed_instantiation.lv2/failed_instantiation.c32
-rw-r--r--test/failed_instantiation.lv2/test_failed_instantiation.c57
-rw-r--r--test/failed_lib_descriptor.lv2/failed_lib_descriptor.c5
-rw-r--r--test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c59
-rw-r--r--test/lib_descriptor.lv2/lib_descriptor.c89
-rw-r--r--test/lib_descriptor.lv2/test_lib_descriptor.c85
-rw-r--r--test/lilv_cxx_test.cpp4
-rw-r--r--test/lilv_test_uri_map.h53
-rw-r--r--test/lilv_test_utils.c234
-rw-r--r--test/lilv_test_utils.h33
-rw-r--r--test/missing_descriptor.lv2/test_missing_descriptor.c59
-rw-r--r--test/missing_name.lv2/missing_name.c68
-rw-r--r--test/missing_name.lv2/test_missing_name.c61
-rw-r--r--test/missing_plugin.lv2/missing_plugin.c28
-rw-r--r--test/missing_plugin.lv2/test_missing_plugin.c59
-rw-r--r--test/missing_port.lv2/missing_port.c68
-rw-r--r--test/missing_port.lv2/test_missing_port.c57
-rw-r--r--test/missing_port_name.lv2/missing_port_name.c68
-rw-r--r--test/missing_port_name.lv2/test_missing_port_name.c65
-rw-r--r--test/new_version.lv2/new_version.c68
-rw-r--r--test/old_version.lv2/old_version.c68
-rw-r--r--test/test.lv2/test.c676
-rw-r--r--test/test_bad_port_index.c24
-rw-r--r--test/test_bad_port_symbol.c24
-rw-r--r--test/test_classes.c54
-rw-r--r--test/test_discovery.c76
-rw-r--r--test/test_filesystem.c675
-rw-r--r--test/test_get_symbol.c70
-rw-r--r--test/test_no_author.c34
-rw-r--r--test/test_no_verify.c25
-rw-r--r--test/test_plugin.c423
-rw-r--r--test/test_port.c501
-rw-r--r--test/test_preset.c32
-rw-r--r--test/test_project.c41
-rw-r--r--test/test_project_no_author.c34
-rw-r--r--test/test_prototype.c36
-rw-r--r--test/test_reload_bundle.c125
-rw-r--r--test/test_replace_version.c144
-rw-r--r--test/test_state.c1723
-rw-r--r--test/test_string.c40
-rw-r--r--test/test_ui.c130
-rw-r--r--test/test_util.c52
-rw-r--r--test/test_value.c242
-rw-r--r--test/test_verify.c25
-rw-r--r--test/test_world.c30
47 files changed, 3301 insertions, 3380 deletions
diff --git a/test/bad_syntax.lv2/bad_syntax.c b/test/bad_syntax.lv2/bad_syntax.c
index fc4a210..72166c0 100644
--- a/test/bad_syntax.lv2/bad_syntax.c
+++ b/test/bad_syntax.lv2/bad_syntax.c
@@ -22,36 +22,33 @@
#define PLUGIN_URI "http://example.org/bad-syntax"
-enum {
- TEST_INPUT = 0,
- TEST_OUTPUT = 1
-};
+enum { TEST_INPUT = 0, TEST_OUTPUT = 1 };
typedef struct {
- float* input;
- float* output;
+ float* input;
+ float* output;
} Test;
static void
cleanup(LV2_Handle instance)
{
- free((Test*)instance);
+ free((Test*)instance);
}
static void
connect_port(LV2_Handle instance, uint32_t port, void* data)
{
- Test* test = (Test*)instance;
- switch (port) {
- case TEST_INPUT:
- test->input = (float*)data;
- break;
- case TEST_OUTPUT:
- test->output = (float*)data;
- break;
- default:
- break;
- }
+ Test* test = (Test*)instance;
+ switch (port) {
+ case TEST_INPUT:
+ test->input = (float*)data;
+ break;
+ case TEST_OUTPUT:
+ test->output = (float*)data;
+ break;
+ default:
+ break;
+ }
}
static LV2_Handle
@@ -60,35 +57,36 @@ instantiate(const LV2_Descriptor* descriptor,
const char* path,
const LV2_Feature* const* features)
{
- Test* test = (Test*)calloc(1, sizeof(Test));
- if (!test) {
- return NULL;
- }
+ Test* test = (Test*)calloc(1, sizeof(Test));
+ if (!test) {
+ return NULL;
+ }
- return (LV2_Handle)test;
+ return (LV2_Handle)test;
}
static void
run(LV2_Handle instance, uint32_t sample_count)
{
- Test* test = (Test*)instance;
+ Test* test = (Test*)instance;
- *test->output = *test->input;
+ *test->output = *test->input;
}
static const LV2_Descriptor descriptor = {
- PLUGIN_URI,
- instantiate,
- connect_port,
- NULL, // activate,
- run,
- NULL, // deactivate,
- cleanup,
- NULL // extension_data
+ PLUGIN_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ NULL // extension_data
};
LV2_SYMBOL_EXPORT
-const LV2_Descriptor* lv2_descriptor(uint32_t index)
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
{
- return (index == 0) ? &descriptor : NULL;
+ return (index == 0) ? &descriptor : NULL;
}
diff --git a/test/bad_syntax.lv2/test_bad_syntax.c b/test/bad_syntax.lv2/test_bad_syntax.c
index 10aa4da..5f10828 100644
--- a/test/bad_syntax.lv2/test_bad_syntax.c
+++ b/test/bad_syntax.lv2/test_bad_syntax.c
@@ -16,33 +16,32 @@
int
main(int argc, char** argv)
{
- if (argc != 2) {
- fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
- return 1;
- }
-
- const char* bundle_path = argv[1];
- 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);
- free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
-
- LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
-
- assert(!lilv_plugin_get_name(plugin));
- assert(!lilv_plugin_instantiate(plugin, 48000, NULL));
-
- lilv_node_free(plugin_uri);
- lilv_world_free(world);
-
- return 0;
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ 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);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+ lilv_node_free(bundle_uri);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+
+ assert(!lilv_plugin_get_name(plugin));
+ assert(!lilv_plugin_instantiate(plugin, 48000, NULL));
+
+ lilv_node_free(plugin_uri);
+ lilv_world_free(world);
+
+ return 0;
}
-
diff --git a/test/failed_instantiation.lv2/failed_instantiation.c b/test/failed_instantiation.lv2/failed_instantiation.c
index 30ae0ca..d805848 100644
--- a/test/failed_instantiation.lv2/failed_instantiation.c
+++ b/test/failed_instantiation.lv2/failed_instantiation.c
@@ -22,14 +22,11 @@
#define PLUGIN_URI "http://example.org/failed-instantiation"
-enum {
- TEST_INPUT = 0,
- TEST_OUTPUT = 1
-};
+enum { TEST_INPUT = 0, TEST_OUTPUT = 1 };
typedef struct {
- float* input;
- float* output;
+ float* input;
+ float* output;
} Test;
static void
@@ -46,7 +43,7 @@ instantiate(const LV2_Descriptor* descriptor,
const char* path,
const LV2_Feature* const* features)
{
- return NULL;
+ return NULL;
}
static void
@@ -54,18 +51,19 @@ run(LV2_Handle instance, uint32_t sample_count)
{}
static const LV2_Descriptor descriptor = {
- PLUGIN_URI,
- instantiate,
- connect_port,
- NULL, // activate,
- run,
- NULL, // deactivate,
- cleanup,
- NULL // extension_data
+ PLUGIN_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ NULL // extension_data
};
LV2_SYMBOL_EXPORT
-const LV2_Descriptor* lv2_descriptor(uint32_t index)
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
{
- return (index == 0) ? &descriptor : NULL;
+ return (index == 0) ? &descriptor : NULL;
}
diff --git a/test/failed_instantiation.lv2/test_failed_instantiation.c b/test/failed_instantiation.lv2/test_failed_instantiation.c
index 7fb2714..8dbefc3 100644
--- a/test/failed_instantiation.lv2/test_failed_instantiation.c
+++ b/test/failed_instantiation.lv2/test_failed_instantiation.c
@@ -16,33 +16,32 @@
int
main(int argc, char** argv)
{
- if (argc != 2) {
- fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
- return 1;
- }
-
- const char* bundle_path = argv[1];
- 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);
- free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
-
- LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
- assert(plugin);
-
- assert(!lilv_plugin_instantiate(plugin, 48000, NULL));
-
- lilv_node_free(plugin_uri);
- lilv_world_free(world);
-
- return 0;
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ 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);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+ lilv_node_free(bundle_uri);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ assert(plugin);
+
+ assert(!lilv_plugin_instantiate(plugin, 48000, NULL));
+
+ lilv_node_free(plugin_uri);
+ lilv_world_free(world);
+
+ return 0;
}
-
diff --git a/test/failed_lib_descriptor.lv2/failed_lib_descriptor.c b/test/failed_lib_descriptor.lv2/failed_lib_descriptor.c
index e24c8d9..180c8ae 100644
--- a/test/failed_lib_descriptor.lv2/failed_lib_descriptor.c
+++ b/test/failed_lib_descriptor.lv2/failed_lib_descriptor.c
@@ -21,8 +21,7 @@
LV2_SYMBOL_EXPORT
const LV2_Lib_Descriptor*
-lv2_lib_descriptor(const char* bundle_path,
- const LV2_Feature*const* features)
+lv2_lib_descriptor(const char* bundle_path, const LV2_Feature* const* features)
{
- return NULL;
+ return NULL;
}
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 63e81f3..71a3b96 100644
--- a/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c
+++ b/test/failed_lib_descriptor.lv2/test_failed_lib_descriptor.c
@@ -16,34 +16,33 @@
int
main(int argc, char** argv)
{
- if (argc != 2) {
- fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
- return 1;
- }
-
- const char* bundle_path = argv[1];
- 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);
- free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
-
- LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
- assert(plugin);
-
- LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
- assert(!instance);
-
- lilv_node_free(plugin_uri);
- lilv_world_free(world);
-
- return 0;
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ 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);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+ lilv_node_free(bundle_uri);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ assert(plugin);
+
+ LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
+ assert(!instance);
+
+ lilv_node_free(plugin_uri);
+ lilv_world_free(world);
+
+ return 0;
}
-
diff --git a/test/lib_descriptor.lv2/lib_descriptor.c b/test/lib_descriptor.lv2/lib_descriptor.c
index 29176dc..0a14a23 100644
--- a/test/lib_descriptor.lv2/lib_descriptor.c
+++ b/test/lib_descriptor.lv2/lib_descriptor.c
@@ -22,36 +22,33 @@
#define PLUGIN_URI "http://example.org/lib-descriptor"
-enum {
- TEST_INPUT = 0,
- TEST_OUTPUT = 1
-};
+enum { TEST_INPUT = 0, TEST_OUTPUT = 1 };
typedef struct {
- float* input;
- float* output;
+ float* input;
+ float* output;
} Test;
static void
cleanup(LV2_Handle instance)
{
- free((Test*)instance);
+ free((Test*)instance);
}
static void
connect_port(LV2_Handle instance, uint32_t port, void* data)
{
- Test* test = (Test*)instance;
- switch (port) {
- case TEST_INPUT:
- test->input = (float*)data;
- break;
- case TEST_OUTPUT:
- test->output = (float*)data;
- break;
- default:
- break;
- }
+ Test* test = (Test*)instance;
+ switch (port) {
+ case TEST_INPUT:
+ test->input = (float*)data;
+ break;
+ case TEST_OUTPUT:
+ test->output = (float*)data;
+ break;
+ default:
+ break;
+ }
}
static LV2_Handle
@@ -60,54 +57,52 @@ instantiate(const LV2_Descriptor* descriptor,
const char* path,
const LV2_Feature* const* features)
{
- Test* test = (Test*)calloc(1, sizeof(Test));
- if (!test) {
- return NULL;
- }
+ Test* test = (Test*)calloc(1, sizeof(Test));
+ if (!test) {
+ return NULL;
+ }
- return (LV2_Handle)test;
+ return (LV2_Handle)test;
}
static void
run(LV2_Handle instance, uint32_t sample_count)
{
- Test* test = (Test*)instance;
+ Test* test = (Test*)instance;
- *test->output = *test->input;
+ *test->output = *test->input;
}
static const LV2_Descriptor descriptor = {
- PLUGIN_URI,
- instantiate,
- connect_port,
- NULL, // activate,
- run,
- NULL, // deactivate,
- cleanup,
- NULL // extension_data
+ PLUGIN_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ NULL // extension_data
};
static const LV2_Descriptor*
get_plugin(LV2_Lib_Handle handle, uint32_t index)
{
- switch (index) {
- case 0:
- return &descriptor;
- default:
- return NULL;
- }
+ switch (index) {
+ case 0:
+ return &descriptor;
+ default:
+ return NULL;
+ }
}
-static const LV2_Lib_Descriptor lib = {
- NULL,
- sizeof(LV2_Lib_Descriptor),
- NULL,
- get_plugin };
+static const LV2_Lib_Descriptor lib = {NULL,
+ sizeof(LV2_Lib_Descriptor),
+ NULL,
+ get_plugin};
LV2_SYMBOL_EXPORT
const LV2_Lib_Descriptor*
-lv2_lib_descriptor(const char* bundle_path,
- const LV2_Feature*const* features)
+lv2_lib_descriptor(const char* bundle_path, const LV2_Feature* const* features)
{
- return &lib;
+ return &lib;
}
diff --git a/test/lib_descriptor.lv2/test_lib_descriptor.c b/test/lib_descriptor.lv2/test_lib_descriptor.c
index e0ba585..bf79be8 100644
--- a/test/lib_descriptor.lv2/test_lib_descriptor.c
+++ b/test/lib_descriptor.lv2/test_lib_descriptor.c
@@ -16,47 +16,46 @@
int
main(int argc, char** argv)
{
- if (argc != 2) {
- fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
- return 1;
- }
-
- const char* bundle_path = argv[1];
- 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);
- free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
-
- LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
- assert(plugin);
-
- LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
- assert(instance);
- lilv_instance_free(instance);
-
- LilvNode* eg_blob = lilv_new_uri(world, "http://example.org/blob");
- LilvNode* blob = lilv_world_get(world, plugin_uri, eg_blob, NULL);
- assert(lilv_node_is_literal(blob));
- lilv_node_free(blob);
- lilv_node_free(eg_blob);
-
- LilvNode* eg_junk = lilv_new_uri(world, "http://example.org/junk");
- LilvNode* junk = lilv_world_get(world, plugin_uri, eg_junk, NULL);
- assert(lilv_node_is_literal(junk));
- lilv_node_free(junk);
- lilv_node_free(eg_junk);
-
- lilv_node_free(plugin_uri);
- lilv_world_free(world);
-
- return 0;
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ 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);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+ lilv_node_free(bundle_uri);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ assert(plugin);
+
+ LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
+ assert(instance);
+ lilv_instance_free(instance);
+
+ LilvNode* eg_blob = lilv_new_uri(world, "http://example.org/blob");
+ LilvNode* blob = lilv_world_get(world, plugin_uri, eg_blob, NULL);
+ assert(lilv_node_is_literal(blob));
+ lilv_node_free(blob);
+ lilv_node_free(eg_blob);
+
+ LilvNode* eg_junk = lilv_new_uri(world, "http://example.org/junk");
+ LilvNode* junk = lilv_world_get(world, plugin_uri, eg_junk, NULL);
+ assert(lilv_node_is_literal(junk));
+ lilv_node_free(junk);
+ lilv_node_free(eg_junk);
+
+ lilv_node_free(plugin_uri);
+ lilv_world_free(world);
+
+ return 0;
}
-
diff --git a/test/lilv_cxx_test.cpp b/test/lilv_cxx_test.cpp
index 4ee21ae..392ead2 100644
--- a/test/lilv_cxx_test.cpp
+++ b/test/lilv_cxx_test.cpp
@@ -19,7 +19,7 @@
int
main()
{
- Lilv::World world;
+ Lilv::World world;
- return 0;
+ return 0;
}
diff --git a/test/lilv_test_uri_map.h b/test/lilv_test_uri_map.h
index e56445a..b18d8f4 100644
--- a/test/lilv_test_uri_map.h
+++ b/test/lilv_test_uri_map.h
@@ -28,59 +28,58 @@
#include <stdlib.h>
#include <string.h>
-typedef struct
-{
- char** uris;
- size_t n_uris;
+typedef struct {
+ char** uris;
+ size_t n_uris;
} LilvTestUriMap;
static inline void
lilv_test_uri_map_init(LilvTestUriMap* const map)
{
- map->uris = NULL;
- map->n_uris = 0;
+ map->uris = NULL;
+ map->n_uris = 0;
}
static inline void
lilv_test_uri_map_clear(LilvTestUriMap* const map)
{
- for (size_t i = 0; i < map->n_uris; ++i) {
- free(map->uris[i]);
- }
+ for (size_t i = 0; i < map->n_uris; ++i) {
+ free(map->uris[i]);
+ }
- free(map->uris);
- map->uris = NULL;
- map->n_uris = 0;
+ free(map->uris);
+ map->uris = NULL;
+ map->n_uris = 0;
}
static inline LV2_URID
map_uri(LV2_URID_Map_Handle handle, const char* uri)
{
- LilvTestUriMap* map = (LilvTestUriMap*)handle;
+ LilvTestUriMap* map = (LilvTestUriMap*)handle;
- for (size_t i = 0; i < map->n_uris; ++i) {
- if (!strcmp(map->uris[i], uri)) {
- return i + 1;
- }
- }
+ for (size_t i = 0; i < map->n_uris; ++i) {
+ if (!strcmp(map->uris[i], uri)) {
+ return i + 1;
+ }
+ }
- assert(serd_uri_string_has_scheme((const uint8_t*)uri));
+ assert(serd_uri_string_has_scheme((const uint8_t*)uri));
- map->uris = (char**)realloc(map->uris, ++map->n_uris * sizeof(char*));
- map->uris[map->n_uris - 1] = lilv_strdup(uri);
- return map->n_uris;
+ map->uris = (char**)realloc(map->uris, ++map->n_uris * sizeof(char*));
+ map->uris[map->n_uris - 1] = lilv_strdup(uri);
+ return map->n_uris;
}
static inline const char*
unmap_uri(LV2_URID_Map_Handle handle, LV2_URID urid)
{
- LilvTestUriMap* map = (LilvTestUriMap*)handle;
+ LilvTestUriMap* map = (LilvTestUriMap*)handle;
- if (urid > 0 && urid <= map->n_uris) {
- return map->uris[urid - 1];
- }
+ if (urid > 0 && urid <= map->n_uris) {
+ return map->uris[urid - 1];
+ }
- return NULL;
+ return NULL;
}
#endif // LILV_TEST_URI_MAP_H
diff --git a/test/lilv_test_utils.c b/test/lilv_test_utils.c
index 38754b0..16eeb8e 100644
--- a/test/lilv_test_utils.c
+++ b/test/lilv_test_utils.c
@@ -34,151 +34,149 @@
LilvTestEnv*
lilv_test_env_new(void)
{
- LilvWorld* world = lilv_world_new();
- if (!world) {
- return NULL;
- }
-
- LilvTestEnv* env = (LilvTestEnv*)calloc(1, sizeof(LilvTestEnv));
-
- env->world = world;
- env->plugin1_uri = lilv_new_uri(world, "http://example.org/plug");
- env->plugin2_uri = lilv_new_uri(world, "http://example.org/foobar");
-
- // Set custom LV2_PATH in build directory to only use test data
- char* test_path = lilv_path_canonical(LILV_TEST_DIR);
- char* lv2_path = lilv_strjoin(test_path, "/test_lv2_path", NULL);
- LilvNode* path = lilv_new_string(world, lv2_path);
- lilv_world_set_option(world, LILV_OPTION_LV2_PATH, path);
- free(lv2_path);
- free(test_path);
- lilv_node_free(path);
-
- return env;
+ LilvWorld* world = lilv_world_new();
+ if (!world) {
+ return NULL;
+ }
+
+ LilvTestEnv* env = (LilvTestEnv*)calloc(1, sizeof(LilvTestEnv));
+
+ env->world = world;
+ env->plugin1_uri = lilv_new_uri(world, "http://example.org/plug");
+ env->plugin2_uri = lilv_new_uri(world, "http://example.org/foobar");
+
+ // Set custom LV2_PATH in build directory to only use test data
+ char* test_path = lilv_path_canonical(LILV_TEST_DIR);
+ char* lv2_path = lilv_strjoin(test_path, "/test_lv2_path", NULL);
+ LilvNode* path = lilv_new_string(world, lv2_path);
+ lilv_world_set_option(world, LILV_OPTION_LV2_PATH, path);
+ free(lv2_path);
+ free(test_path);
+ lilv_node_free(path);
+
+ return env;
}
void
lilv_test_env_free(LilvTestEnv* env)
{
- free(env->test_content_path);
- free(env->test_manifest_path);
- free(env->test_bundle_uri);
- free(env->test_bundle_path);
- lilv_node_free(env->plugin2_uri);
- lilv_node_free(env->plugin1_uri);
- lilv_world_free(env->world);
- free(env);
+ free(env->test_content_path);
+ free(env->test_manifest_path);
+ free(env->test_bundle_uri);
+ free(env->test_bundle_path);
+ lilv_node_free(env->plugin2_uri);
+ lilv_node_free(env->plugin1_uri);
+ lilv_world_free(env->world);
+ free(env);
}
int
create_bundle(LilvTestEnv* env, const char* manifest, const char* plugin)
{
- {
- static const char* const bundle_path = "/test_lv2_path/lilv-test.lv2";
-
- char* const test_path = lilv_path_canonical(LILV_TEST_DIR);
- env->test_bundle_path = lilv_strjoin(test_path, bundle_path, NULL);
- lilv_free(test_path);
- }
-
- if (lilv_create_directories(env->test_bundle_path)) {
- fprintf(stderr,
- "Failed to create directory '%s' (%s)\n",
- env->test_bundle_path,
- strerror(errno));
- return 1;
- }
-
- SerdNode s = serd_node_new_file_uri((const uint8_t*)env->test_bundle_path,
- NULL,
- NULL,
- true);
-
- env->test_bundle_uri = lilv_strjoin((const char*)s.buf, "/", NULL);
- env->test_manifest_path =
- lilv_strjoin(env->test_bundle_path, "/manifest.ttl", NULL);
- env->test_content_path =
- lilv_strjoin(env->test_bundle_path, "/plugin.ttl", NULL);
-
- serd_node_free(&s);
-
- FILE* const manifest_file = fopen(env->test_manifest_path, "w");
- if (!manifest_file) {
- return 2;
- }
-
- FILE* const plugin_file = fopen(env->test_content_path, "w");
- if (!plugin_file) {
- fclose(manifest_file);
- return 3;
- }
-
- const size_t manifest_head_len = strlen(MANIFEST_PREFIXES);
- const size_t manifest_len = strlen(manifest);
- const size_t plugin_head_len = strlen(PLUGIN_PREFIXES);
- const size_t plugin_len = strlen(plugin);
- const size_t n_total =
- manifest_len + plugin_len + manifest_head_len + plugin_head_len;
-
- size_t n_written = 0;
- n_written += fwrite(MANIFEST_PREFIXES, 1, manifest_head_len, manifest_file);
- n_written += fwrite(manifest, 1, manifest_len, manifest_file);
- n_written += fwrite(PLUGIN_PREFIXES, 1, plugin_head_len, plugin_file);
- n_written += fwrite(plugin, 1, plugin_len, plugin_file);
-
- fclose(manifest_file);
- fclose(plugin_file);
- return n_written == n_total ? 0 : 4;
+ {
+ static const char* const bundle_path = "/test_lv2_path/lilv-test.lv2";
+
+ char* const test_path = lilv_path_canonical(LILV_TEST_DIR);
+ env->test_bundle_path = lilv_strjoin(test_path, bundle_path, NULL);
+ lilv_free(test_path);
+ }
+
+ if (lilv_create_directories(env->test_bundle_path)) {
+ fprintf(stderr,
+ "Failed to create directory '%s' (%s)\n",
+ env->test_bundle_path,
+ strerror(errno));
+ return 1;
+ }
+
+ SerdNode s = serd_node_new_file_uri(
+ (const uint8_t*)env->test_bundle_path, NULL, NULL, true);
+
+ env->test_bundle_uri = lilv_strjoin((const char*)s.buf, "/", NULL);
+ env->test_manifest_path =
+ lilv_strjoin(env->test_bundle_path, "/manifest.ttl", NULL);
+ env->test_content_path =
+ lilv_strjoin(env->test_bundle_path, "/plugin.ttl", NULL);
+
+ serd_node_free(&s);
+
+ FILE* const manifest_file = fopen(env->test_manifest_path, "w");
+ if (!manifest_file) {
+ return 2;
+ }
+
+ FILE* const plugin_file = fopen(env->test_content_path, "w");
+ if (!plugin_file) {
+ fclose(manifest_file);
+ return 3;
+ }
+
+ const size_t manifest_head_len = strlen(MANIFEST_PREFIXES);
+ const size_t manifest_len = strlen(manifest);
+ const size_t plugin_head_len = strlen(PLUGIN_PREFIXES);
+ const size_t plugin_len = strlen(plugin);
+ const size_t n_total =
+ manifest_len + plugin_len + manifest_head_len + plugin_head_len;
+
+ size_t n_written = 0;
+ n_written += fwrite(MANIFEST_PREFIXES, 1, manifest_head_len, manifest_file);
+ n_written += fwrite(manifest, 1, manifest_len, manifest_file);
+ n_written += fwrite(PLUGIN_PREFIXES, 1, plugin_head_len, plugin_file);
+ n_written += fwrite(plugin, 1, plugin_len, plugin_file);
+
+ fclose(manifest_file);
+ fclose(plugin_file);
+ return n_written == n_total ? 0 : 4;
}
int
start_bundle(LilvTestEnv* env, const char* manifest, const char* plugin)
{
- if (create_bundle(env, manifest, plugin)) {
- return 1;
- }
+ if (create_bundle(env, manifest, plugin)) {
+ return 1;
+ }
- lilv_world_load_all(env->world);
- return 0;
+ lilv_world_load_all(env->world);
+ return 0;
}
void
delete_bundle(LilvTestEnv* env)
{
- if (env->test_content_path) {
- lilv_remove(env->test_content_path);
- }
-
- if (env->test_manifest_path) {
- lilv_remove(env->test_manifest_path);
- }
-
- if (env->test_bundle_path) {
- remove(env->test_bundle_path);
- }
-
- free(env->test_content_path);
- free(env->test_manifest_path);
- free(env->test_bundle_uri);
- free(env->test_bundle_path);
-
- env->test_content_path = NULL;
- env->test_manifest_path = NULL;
- env->test_bundle_uri = NULL;
- env->test_bundle_path = NULL;
+ if (env->test_content_path) {
+ lilv_remove(env->test_content_path);
+ }
+
+ if (env->test_manifest_path) {
+ lilv_remove(env->test_manifest_path);
+ }
+
+ if (env->test_bundle_path) {
+ remove(env->test_bundle_path);
+ }
+
+ free(env->test_content_path);
+ free(env->test_manifest_path);
+ free(env->test_bundle_uri);
+ free(env->test_bundle_path);
+
+ env->test_content_path = NULL;
+ env->test_manifest_path = NULL;
+ env->test_bundle_uri = NULL;
+ env->test_bundle_path = NULL;
}
void
set_env(const char* name, const char* value)
{
#ifdef _WIN32
- // setenv on Windows does not modify the current process' environment
- const size_t len = strlen(name) + 1 + strlen(value) + 1;
- char* str = (char*)calloc(1, len);
- snprintf(str, len, "%s=%s", name, value);
- putenv(str);
- free(str);
+ // setenv on Windows does not modify the current process' environment
+ const size_t len = strlen(name) + 1 + strlen(value) + 1;
+ char* str = (char*)calloc(1, len);
+ snprintf(str, len, "%s=%s", name, value);
+ putenv(str);
+ free(str);
#else
- setenv(name, value, 1);
+ setenv(name, value, 1);
#endif
}
diff --git a/test/lilv_test_utils.h b/test/lilv_test_utils.h
index 13fd939..e20c7df 100644
--- a/test/lilv_test_utils.h
+++ b/test/lilv_test_utils.h
@@ -20,13 +20,13 @@
#include "lilv/lilv.h"
#define MANIFEST_PREFIXES \
- "\
+ "\
@prefix : <http://example.org/> .\n\
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .\n\
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"
#define PLUGIN_PREFIXES \
- "\
+ "\
@prefix : <http://example.org/> .\n\
@prefix atom: <http://lv2plug.in/ns/ext/atom#> . \n\
@prefix doap: <http://usefulinc.com/ns/doap#> .\n\
@@ -37,30 +37,29 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"
#define SIMPLE_MANIFEST_TTL \
- "\
+ "\
:plug a lv2:Plugin ;\n\
lv2:binary <foo" SHLIB_EXT "> ;\n\
rdfs:seeAlso <plugin.ttl> .\n"
#if defined(__APPLE__)
-# define SHLIB_EXT ".dylib"
+# define SHLIB_EXT ".dylib"
#elif defined(_WIN32)
-# define SHLIB_EXT ".dll"
+# define SHLIB_EXT ".dll"
#else
-# define SHLIB_EXT ".so"
+# define SHLIB_EXT ".so"
#endif
-typedef struct
-{
- LilvWorld* world;
- LilvNode* plugin1_uri;
- LilvNode* plugin2_uri;
- char* test_bundle_path;
- char* test_bundle_uri;
- char* test_manifest_path;
- char* test_content_path;
- int test_count;
- int error_count;
+typedef struct {
+ LilvWorld* world;
+ LilvNode* plugin1_uri;
+ LilvNode* plugin2_uri;
+ char* test_bundle_path;
+ char* test_bundle_uri;
+ char* test_manifest_path;
+ char* test_content_path;
+ int test_count;
+ int error_count;
} LilvTestEnv;
// Create a new test environment with a world, common values, and test LV2_PATH
diff --git a/test/missing_descriptor.lv2/test_missing_descriptor.c b/test/missing_descriptor.lv2/test_missing_descriptor.c
index f7b5ceb..330e534 100644
--- a/test/missing_descriptor.lv2/test_missing_descriptor.c
+++ b/test/missing_descriptor.lv2/test_missing_descriptor.c
@@ -16,34 +16,33 @@
int
main(int argc, char** argv)
{
- if (argc != 2) {
- fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
- return 1;
- }
-
- const char* bundle_path = argv[1];
- 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);
- free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
-
- LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
- assert(plugin);
-
- LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
- assert(!instance);
-
- lilv_node_free(plugin_uri);
- lilv_world_free(world);
-
- return 0;
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ 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);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+ lilv_node_free(bundle_uri);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ assert(plugin);
+
+ LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
+ assert(!instance);
+
+ lilv_node_free(plugin_uri);
+ lilv_world_free(world);
+
+ return 0;
}
-
diff --git a/test/missing_name.lv2/missing_name.c b/test/missing_name.lv2/missing_name.c
index 8945c1f..2f53cf4 100644
--- a/test/missing_name.lv2/missing_name.c
+++ b/test/missing_name.lv2/missing_name.c
@@ -22,36 +22,33 @@
#define PLUGIN_URI "http://example.org/missing-name"
-enum {
- TEST_INPUT = 0,
- TEST_OUTPUT = 1
-};
+enum { TEST_INPUT = 0, TEST_OUTPUT = 1 };
typedef struct {
- float* input;
- float* output;
+ float* input;
+ float* output;
} Test;
static void
cleanup(LV2_Handle instance)
{
- free((Test*)instance);
+ free((Test*)instance);
}
static void
connect_port(LV2_Handle instance, uint32_t port, void* data)
{
- Test* test = (Test*)instance;
- switch (port) {
- case TEST_INPUT:
- test->input = (float*)data;
- break;
- case TEST_OUTPUT:
- test->output = (float*)data;
- break;
- default:
- break;
- }
+ Test* test = (Test*)instance;
+ switch (port) {
+ case TEST_INPUT:
+ test->input = (float*)data;
+ break;
+ case TEST_OUTPUT:
+ test->output = (float*)data;
+ break;
+ default:
+ break;
+ }
}
static LV2_Handle
@@ -60,35 +57,36 @@ instantiate(const LV2_Descriptor* descriptor,
const char* path,
const LV2_Feature* const* features)
{
- Test* test = (Test*)calloc(1, sizeof(Test));
- if (!test) {
- return NULL;
- }
+ Test* test = (Test*)calloc(1, sizeof(Test));
+ if (!test) {
+ return NULL;
+ }
- return (LV2_Handle)test;
+ return (LV2_Handle)test;
}
static void
run(LV2_Handle instance, uint32_t sample_count)
{
- Test* test = (Test*)instance;
+ Test* test = (Test*)instance;
- *test->output = *test->input;
+ *test->output = *test->input;
}
static const LV2_Descriptor descriptor = {
- PLUGIN_URI,
- instantiate,
- connect_port,
- NULL, // activate,
- run,
- NULL, // deactivate,
- cleanup,
- NULL // extension_data
+ PLUGIN_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ NULL // extension_data
};
LV2_SYMBOL_EXPORT
-const LV2_Descriptor* lv2_descriptor(uint32_t index)
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
{
- return (index == 0) ? &descriptor : NULL;
+ return (index == 0) ? &descriptor : NULL;
}
diff --git a/test/missing_name.lv2/test_missing_name.c b/test/missing_name.lv2/test_missing_name.c
index bf8cf95..5cb069a 100644
--- a/test/missing_name.lv2/test_missing_name.c
+++ b/test/missing_name.lv2/test_missing_name.c
@@ -16,35 +16,34 @@
int
main(int argc, char** argv)
{
- if (argc != 2) {
- fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
- return 1;
- }
-
- const char* bundle_path = argv[1];
- 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);
- free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
-
- LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
- assert(plugin);
-
- LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
- assert(instance);
- lilv_instance_free(instance);
-
- lilv_node_free(plugin_uri);
- lilv_world_free(world);
-
- return 0;
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ 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);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+ lilv_node_free(bundle_uri);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ assert(plugin);
+
+ LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
+ assert(instance);
+ lilv_instance_free(instance);
+
+ lilv_node_free(plugin_uri);
+ lilv_world_free(world);
+
+ return 0;
}
-
diff --git a/test/missing_plugin.lv2/missing_plugin.c b/test/missing_plugin.lv2/missing_plugin.c
index bf45cbe..8ca146c 100644
--- a/test/missing_plugin.lv2/missing_plugin.c
+++ b/test/missing_plugin.lv2/missing_plugin.c
@@ -21,22 +21,22 @@
#include <stdlib.h>
static const LV2_Descriptor descriptor = {
- "http://example.org/not-the-plugin-you-are-looking-for",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
-};
+ "http://example.org/not-the-plugin-you-are-looking-for",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL};
LV2_SYMBOL_EXPORT
-const LV2_Descriptor* lv2_descriptor(uint32_t index)
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
{
- if (index == 0) {
- return &descriptor;
- }
+ if (index == 0) {
+ return &descriptor;
+ }
- return NULL;
+ return NULL;
}
diff --git a/test/missing_plugin.lv2/test_missing_plugin.c b/test/missing_plugin.lv2/test_missing_plugin.c
index c2a8259..861fcba 100644
--- a/test/missing_plugin.lv2/test_missing_plugin.c
+++ b/test/missing_plugin.lv2/test_missing_plugin.c
@@ -16,34 +16,33 @@
int
main(int argc, char** argv)
{
- if (argc != 2) {
- fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
- return 1;
- }
-
- const char* bundle_path = argv[1];
- 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);
- free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
-
- LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
- assert(plugin);
-
- LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
- assert(!instance);
-
- lilv_node_free(plugin_uri);
- lilv_world_free(world);
-
- return 0;
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ 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);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+ lilv_node_free(bundle_uri);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ assert(plugin);
+
+ LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL);
+ assert(!instance);
+
+ lilv_node_free(plugin_uri);
+ lilv_world_free(world);
+
+ return 0;
}
-
diff --git a/test/missing_port.lv2/missing_port.c b/test/missing_port.lv2/missing_port.c
index 558eeb0..e2fa77a 100644
--- a/test/missing_port.lv2/missing_port.c
+++ b/test/missing_port.lv2/missing_port.c
@@ -22,36 +22,33 @@
#define PLUGIN_URI "http://example.org/missing-port"
-enum {
- TEST_INPUT = 0,
- TEST_OUTPUT = 1
-};
+enum { TEST_INPUT = 0, TEST_OUTPUT = 1 };
typedef struct {
- float* input;
- float* output;
+ float* input;
+ float* output;
} Test;
static void
cleanup(LV2_Handle instance)
{
- free((Test*)instance);
+ free((Test*)instance);
}
static void
connect_port(LV2_Handle instance, uint32_t port, void* data)
{
- Test* test = (Test*)instance;
- switch (port) {
- case TEST_INPUT:
- test->input = (float*)data;
- break;
- case TEST_OUTPUT:
- test->output = (float*)data;
- break;
- default:
- break;
- }
+ Test* test = (Test*)instance;
+ switch (port) {
+ case TEST_INPUT:
+ test->input = (float*)data;
+ break;
+ case TEST_OUTPUT:
+ test->output = (float*)data;
+ break;
+ default:
+ break;
+ }
}
static LV2_Handle
@@ -60,35 +57,36 @@ instantiate(const LV2_Descriptor* descriptor,
const char* path,
const LV2_Feature* const* features)
{
- Test* test = (Test*)calloc(1, sizeof(Test));
- if (!test) {
- return NULL;
- }
+ Test* test = (Test*)calloc(1, sizeof(Test));
+ if (!test) {
+ return NULL;
+ }
- return (LV2_Handle)test;
+ return (LV2_Handle)test;
}
static void
run(LV2_Handle instance, uint32_t sample_count)
{
- Test* test = (Test*)instance;
+ Test* test = (Test*)instance;
- *test->output = *test->input;
+ *test->output = *test->input;
}
static const LV2_Descriptor descriptor = {
- PLUGIN_URI,
- instantiate,
- connect_port,
- NULL, // activate,
- run,
- NULL, // deactivate,
- cleanup,
- NULL // extension_data
+ PLUGIN_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ NULL // extension_data
};
LV2_SYMBOL_EXPORT
-const LV2_Descriptor* lv2_descriptor(uint32_t index)
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
{
- return (index == 0) ? &descriptor : NULL;
+ return (index == 0) ? &descriptor : NULL;
}
diff --git a/test/missing_port.lv2/test_missing_port.c b/test/missing_port.lv2/test_missing_port.c
index a966d93..ec6713c 100644
--- a/test/missing_port.lv2/test_missing_port.c
+++ b/test/missing_port.lv2/test_missing_port.c
@@ -16,33 +16,32 @@
int
main(int argc, char** argv)
{
- if (argc != 2) {
- fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
- return 1;
- }
-
- const char* bundle_path = argv[1];
- 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);
- free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
-
- LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
-
- // Check that all ports are ignored
- assert(lilv_plugin_get_num_ports(plugin) == 0);
-
- lilv_node_free(plugin_uri);
- lilv_world_free(world);
-
- return 0;
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ 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);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+ lilv_node_free(bundle_uri);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+
+ // Check that all ports are ignored
+ assert(lilv_plugin_get_num_ports(plugin) == 0);
+
+ lilv_node_free(plugin_uri);
+ lilv_world_free(world);
+
+ return 0;
}
-
diff --git a/test/missing_port_name.lv2/missing_port_name.c b/test/missing_port_name.lv2/missing_port_name.c
index f48203a..2b8efe0 100644
--- a/test/missing_port_name.lv2/missing_port_name.c
+++ b/test/missing_port_name.lv2/missing_port_name.c
@@ -22,36 +22,33 @@
#define PLUGIN_URI "http://example.org/missing-port-name"
-enum {
- TEST_INPUT = 0,
- TEST_OUTPUT = 1
-};
+enum { TEST_INPUT = 0, TEST_OUTPUT = 1 };
typedef struct {
- float* input;
- float* output;
+ float* input;
+ float* output;
} Test;
static void
cleanup(LV2_Handle instance)
{
- free((Test*)instance);
+ free((Test*)instance);
}
static void
connect_port(LV2_Handle instance, uint32_t port, void* data)
{
- Test* test = (Test*)instance;
- switch (port) {
- case TEST_INPUT:
- test->input = (float*)data;
- break;
- case TEST_OUTPUT:
- test->output = (float*)data;
- break;
- default:
- break;
- }
+ Test* test = (Test*)instance;
+ switch (port) {
+ case TEST_INPUT:
+ test->input = (float*)data;
+ break;
+ case TEST_OUTPUT:
+ test->output = (float*)data;
+ break;
+ default:
+ break;
+ }
}
static LV2_Handle
@@ -60,35 +57,36 @@ instantiate(const LV2_Descriptor* descriptor,
const char* path,
const LV2_Feature* const* features)
{
- Test* test = (Test*)calloc(1, sizeof(Test));
- if (!test) {
- return NULL;
- }
+ Test* test = (Test*)calloc(1, sizeof(Test));
+ if (!test) {
+ return NULL;
+ }
- return (LV2_Handle)test;
+ return (LV2_Handle)test;
}
static void
run(LV2_Handle instance, uint32_t sample_count)
{
- Test* test = (Test*)instance;
+ Test* test = (Test*)instance;
- *test->output = *test->input;
+ *test->output = *test->input;
}
static const LV2_Descriptor descriptor = {
- PLUGIN_URI,
- instantiate,
- connect_port,
- NULL, // activate,
- run,
- NULL, // deactivate,
- cleanup,
- NULL // extension_data
+ PLUGIN_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ NULL // extension_data
};
LV2_SYMBOL_EXPORT
-const LV2_Descriptor* lv2_descriptor(uint32_t index)
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
{
- return (index == 0) ? &descriptor : NULL;
+ return (index == 0) ? &descriptor : NULL;
}
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 9a68065..4d017d9 100644
--- a/test/missing_port_name.lv2/test_missing_port_name.c
+++ b/test/missing_port_name.lv2/test_missing_port_name.c
@@ -16,37 +16,36 @@
int
main(int argc, char** argv)
{
- if (argc != 2) {
- fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
- return 1;
- }
-
- const char* bundle_path = argv[1];
- 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);
- free(abs_bundle);
- serd_node_free(&bundle);
- lilv_node_free(bundle_uri);
-
- LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
- assert(plugin);
-
- const LilvPort* port = lilv_plugin_get_port_by_index(plugin, 0);
- assert(port);
- LilvNode* name = lilv_port_get_name(plugin, port);
- assert(!name);
- lilv_node_free(name);
-
- lilv_node_free(plugin_uri);
- lilv_world_free(world);
-
- return 0;
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s BUNDLE\n", argv[0]);
+ return 1;
+ }
+
+ const char* bundle_path = argv[1];
+ 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);
+ free(abs_bundle);
+ serd_node_free(&bundle);
+ lilv_node_free(bundle_uri);
+
+ LilvNode* plugin_uri = lilv_new_uri(world, PLUGIN_URI);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ assert(plugin);
+
+ const LilvPort* port = lilv_plugin_get_port_by_index(plugin, 0);
+ assert(port);
+ LilvNode* name = lilv_port_get_name(plugin, port);
+ assert(!name);
+ lilv_node_free(name);
+
+ lilv_node_free(plugin_uri);
+ lilv_world_free(world);
+
+ return 0;
}
-
diff --git a/test/new_version.lv2/new_version.c b/test/new_version.lv2/new_version.c
index 2669a83..ac5c6ad 100644
--- a/test/new_version.lv2/new_version.c
+++ b/test/new_version.lv2/new_version.c
@@ -22,36 +22,33 @@
#define PLUGIN_URI "http://example.org/versioned"
-enum {
- TEST_INPUT = 0,
- TEST_OUTPUT = 1
-};
+enum { TEST_INPUT = 0, TEST_OUTPUT = 1 };
typedef struct {
- float* input;
- float* output;
+ float* input;
+ float* output;
} Test;
static void
cleanup(LV2_Handle instance)
{
- free((Test*)instance);
+ free((Test*)instance);
}
static void
connect_port(LV2_Handle instance, uint32_t port, void* data)
{
- Test* test = (Test*)instance;
- switch (port) {
- case TEST_INPUT:
- test->input = (float*)data;
- break;
- case TEST_OUTPUT:
- test->output = (float*)data;
- break;
- default:
- break;
- }
+ Test* test = (Test*)instance;
+ switch (port) {
+ case TEST_INPUT:
+ test->input = (float*)data;
+ break;
+ case TEST_OUTPUT:
+ test->output = (float*)data;
+ break;
+ default:
+ break;
+ }
}
static LV2_Handle
@@ -60,35 +57,36 @@ instantiate(const LV2_Descriptor* descriptor,
const char* path,
const LV2_Feature* const* features)
{
- Test* test = (Test*)calloc(1, sizeof(Test));
- if (!test) {
- return NULL;
- }
+ Test* test = (Test*)calloc(1, sizeof(Test));
+ if (!test) {
+ return NULL;
+ }
- return (LV2_Handle)test;
+ return (LV2_Handle)test;
}
static void
run(LV2_Handle instance, uint32_t sample_count)
{
- Test* test = (Test*)instance;
+ Test* test = (Test*)instance;
- *test->output = *test->input;
+ *test->output = *test->input;
}
static const LV2_Descriptor descriptor = {
- PLUGIN_URI,
- instantiate,
- connect_port,
- NULL, // activate,
- run,
- NULL, // deactivate,
- cleanup,
- NULL // extension_data
+ PLUGIN_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ NULL // extension_data
};
LV2_SYMBOL_EXPORT
-const LV2_Descriptor* lv2_descriptor(uint32_t index)
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
{
- return (index == 0) ? &descriptor : NULL;
+ return (index == 0) ? &descriptor : NULL;
}
diff --git a/test/old_version.lv2/old_version.c b/test/old_version.lv2/old_version.c
index 84d3b2c..ae25ad2 100644
--- a/test/old_version.lv2/old_version.c
+++ b/test/old_version.lv2/old_version.c
@@ -22,36 +22,33 @@
#define PLUGIN_URI "http://example.org/versioned"
-enum {
- TEST_INPUT = 0,
- TEST_OUTPUT = 1
-};
+enum { TEST_INPUT = 0, TEST_OUTPUT = 1 };
typedef struct {
- float* input;
- float* output;
+ float* input;
+ float* output;
} Test;
static void
cleanup(LV2_Handle instance)
{
- free((Test*)instance);
+ free((Test*)instance);
}
static void
connect_port(LV2_Handle instance, uint32_t port, void* data)
{
- Test* test = (Test*)instance;
- switch (port) {
- case TEST_INPUT:
- test->input = (float*)data;
- break;
- case TEST_OUTPUT:
- test->output = (float*)data;
- break;
- default:
- break;
- }
+ Test* test = (Test*)instance;
+ switch (port) {
+ case TEST_INPUT:
+ test->input = (float*)data;
+ break;
+ case TEST_OUTPUT:
+ test->output = (float*)data;
+ break;
+ default:
+ break;
+ }
}
static LV2_Handle
@@ -60,35 +57,36 @@ instantiate(const LV2_Descriptor* descriptor,
const char* path,
const LV2_Feature* const* features)
{
- Test* test = (Test*)calloc(1, sizeof(Test));
- if (!test) {
- return NULL;
- }
+ Test* test = (Test*)calloc(1, sizeof(Test));
+ if (!test) {
+ return NULL;
+ }
- return (LV2_Handle)test;
+ return (LV2_Handle)test;
}
static void
run(LV2_Handle instance, uint32_t sample_count)
{
- Test* test = (Test*)instance;
+ Test* test = (Test*)instance;
- *test->output = *test->input;
+ *test->output = *test->input;
}
static const LV2_Descriptor descriptor = {
- PLUGIN_URI,
- instantiate,
- connect_port,
- NULL, // activate,
- run,
- NULL, // deactivate,
- cleanup,
- NULL // extension_data
+ PLUGIN_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ NULL // extension_data
};
LV2_SYMBOL_EXPORT
-const LV2_Descriptor* lv2_descriptor(uint32_t index)
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
{
- return (index == 0) ? &descriptor : NULL;
+ return (index == 0) ? &descriptor : NULL;
}
diff --git a/test/test.lv2/test.c b/test/test.lv2/test.c
index b3ddd85..d6b2544 100644
--- a/test/test.lv2/test.c
+++ b/test/test.lv2/test.c
@@ -23,8 +23,8 @@
#include "lv2/urid/urid.h"
#ifdef _MSC_VER
-# include <io.h>
-# define mkstemp(pat) _mktemp(pat)
+# include <io.h>
+# define mkstemp(pat) _mktemp(pat)
#endif
#include <stdint.h>
@@ -36,64 +36,57 @@
#define TMP_TEMPLATE "lilv_testXXXXXX"
-enum {
- TEST_INPUT = 0,
- TEST_OUTPUT = 1,
- TEST_CONTROL = 2
-};
+enum { TEST_INPUT = 0, TEST_OUTPUT = 1, TEST_CONTROL = 2 };
typedef struct {
- LV2_URID_Map* map;
- LV2_State_Free_Path* free_path;
+ LV2_URID_Map* map;
+ LV2_State_Free_Path* free_path;
- struct {
- LV2_URID atom_Float;
- } uris;
+ struct {
+ LV2_URID atom_Float;
+ } uris;
- char tmp_file_path[sizeof(TMP_TEMPLATE)];
- char* rec_file_path;
- FILE* rec_file;
+ char tmp_file_path[sizeof(TMP_TEMPLATE)];
+ char* rec_file_path;
+ FILE* rec_file;
- float* input;
- float* output;
- unsigned num_runs;
+ float* input;
+ float* output;
+ unsigned num_runs;
} Test;
static void
cleanup(LV2_Handle instance)
{
- Test* test = (Test*)instance;
- if (test->rec_file) {
- fclose(test->rec_file);
- }
+ Test* test = (Test*)instance;
+ if (test->rec_file) {
+ fclose(test->rec_file);
+ }
- if (test->free_path) {
- test->free_path->free_path(test->free_path->handle,
- test->rec_file_path);
- }
+ if (test->free_path) {
+ test->free_path->free_path(test->free_path->handle, test->rec_file_path);
+ }
- free(instance);
+ free(instance);
}
static void
-connect_port(LV2_Handle instance,
- uint32_t port,
- void* data)
+connect_port(LV2_Handle instance, uint32_t port, void* data)
{
- Test* test = (Test*)instance;
- switch (port) {
- case TEST_INPUT:
- test->input = (float*)data;
- break;
- case TEST_OUTPUT:
- test->output = (float*)data;
- break;
- case TEST_CONTROL:
- test->output = (float*)data;
- break;
- default:
- break;
- }
+ Test* test = (Test*)instance;
+ switch (port) {
+ case TEST_INPUT:
+ test->input = (float*)data;
+ break;
+ case TEST_OUTPUT:
+ test->output = (float*)data;
+ break;
+ case TEST_CONTROL:
+ test->output = (float*)data;
+ break;
+ default:
+ break;
+ }
}
static LV2_Handle
@@ -102,74 +95,73 @@ instantiate(const LV2_Descriptor* descriptor,
const char* path,
const LV2_Feature* const* features)
{
- Test* test = (Test*)calloc(1, sizeof(Test));
- if (!test) {
- return NULL;
- }
-
- strncpy(test->tmp_file_path, TMP_TEMPLATE, strlen(TMP_TEMPLATE) + 1);
- mkstemp(test->tmp_file_path);
-
- LV2_State_Make_Path* make_path = NULL;
-
- for (int i = 0; features[i]; ++i) {
- if (!strcmp(features[i]->URI, LV2_URID_URI "#map")) {
- test->map = (LV2_URID_Map*)features[i]->data;
- test->uris.atom_Float = test->map->map(
- test->map->handle, LV2_ATOM__Float);
- } else if (!strcmp(features[i]->URI, LV2_STATE__makePath)) {
- make_path = (LV2_State_Make_Path*)features[i]->data;
- } else if (!strcmp(features[i]->URI, LV2_STATE__freePath)) {
- test->free_path = (LV2_State_Free_Path*)features[i]->data;
- }
- }
-
- if (!test->map) {
- fprintf(stderr, "Host does not support urid:map\n");
- free(test);
- return NULL;
- }
-
- if (make_path) {
- if (!test->free_path) {
- fprintf(stderr, "Host provided make_path without free_path\n");
- free(test);
- return NULL;
- }
-
- test->rec_file_path = make_path->path(make_path->handle, "recfile");
- if (!(test->rec_file = fopen(test->rec_file_path, "w"))) {
- fprintf(stderr, "ERROR: Failed to open rec file\n");
- }
- fprintf(test->rec_file, "instantiate\n");
- }
-
- return (LV2_Handle)test;
+ Test* test = (Test*)calloc(1, sizeof(Test));
+ if (!test) {
+ return NULL;
+ }
+
+ strncpy(test->tmp_file_path, TMP_TEMPLATE, strlen(TMP_TEMPLATE) + 1);
+ mkstemp(test->tmp_file_path);
+
+ LV2_State_Make_Path* make_path = NULL;
+
+ for (int i = 0; features[i]; ++i) {
+ if (!strcmp(features[i]->URI, LV2_URID_URI "#map")) {
+ test->map = (LV2_URID_Map*)features[i]->data;
+ test->uris.atom_Float =
+ test->map->map(test->map->handle, LV2_ATOM__Float);
+ } else if (!strcmp(features[i]->URI, LV2_STATE__makePath)) {
+ make_path = (LV2_State_Make_Path*)features[i]->data;
+ } else if (!strcmp(features[i]->URI, LV2_STATE__freePath)) {
+ test->free_path = (LV2_State_Free_Path*)features[i]->data;
+ }
+ }
+
+ if (!test->map) {
+ fprintf(stderr, "Host does not support urid:map\n");
+ free(test);
+ return NULL;
+ }
+
+ if (make_path) {
+ if (!test->free_path) {
+ fprintf(stderr, "Host provided make_path without free_path\n");
+ free(test);
+ return NULL;
+ }
+
+ test->rec_file_path = make_path->path(make_path->handle, "recfile");
+ if (!(test->rec_file = fopen(test->rec_file_path, "w"))) {
+ fprintf(stderr, "ERROR: Failed to open rec file\n");
+ }
+ fprintf(test->rec_file, "instantiate\n");
+ }
+
+ return (LV2_Handle)test;
}
static void
-run(LV2_Handle instance,
- uint32_t sample_count)
+run(LV2_Handle instance, uint32_t sample_count)
{
- Test* test = (Test*)instance;
- *test->output = *test->input;
- if (sample_count == 1) {
- ++test->num_runs;
- } else if (sample_count == 2 && test->rec_file) {
- // Append to rec file (changes size)
- fprintf(test->rec_file, "run\n");
- } else if (sample_count == 3 && test->rec_file) {
- // Change the first byte of rec file (doesn't change size)
- fseek(test->rec_file, 0, SEEK_SET);
- fprintf(test->rec_file, "X");
- fseek(test->rec_file, 0, SEEK_END);
- }
+ Test* test = (Test*)instance;
+ *test->output = *test->input;
+ if (sample_count == 1) {
+ ++test->num_runs;
+ } else if (sample_count == 2 && test->rec_file) {
+ // Append to rec file (changes size)
+ fprintf(test->rec_file, "run\n");
+ } else if (sample_count == 3 && test->rec_file) {
+ // Change the first byte of rec file (doesn't change size)
+ fseek(test->rec_file, 0, SEEK_SET);
+ fprintf(test->rec_file, "X");
+ fseek(test->rec_file, 0, SEEK_END);
+ }
}
static uint32_t
map_uri(Test* plugin, const char* uri)
{
- return plugin->map->map(plugin->map->handle, uri);
+ return plugin->map->map(plugin->map->handle, uri);
}
static LV2_State_Status
@@ -179,156 +171,155 @@ save(LV2_Handle instance,
uint32_t flags,
const LV2_Feature* const* features)
{
- Test* plugin = (Test*)instance;
-
- LV2_State_Map_Path* map_path = NULL;
- LV2_State_Make_Path* make_path = NULL;
- LV2_State_Free_Path* free_path = NULL;
- for (int i = 0; features && features[i]; ++i) {
- if (!strcmp(features[i]->URI, LV2_STATE__mapPath)) {
- map_path = (LV2_State_Map_Path*)features[i]->data;
- } else if (!strcmp(features[i]->URI, LV2_STATE__makePath)) {
- make_path = (LV2_State_Make_Path*)features[i]->data;
- } else if (!strcmp(features[i]->URI, LV2_STATE__freePath)) {
- free_path = (LV2_State_Free_Path*)features[i]->data;
- }
- }
-
- if (!map_path || !free_path) {
- return LV2_STATE_ERR_NO_FEATURE;
- }
-
- store(callback_data,
- map_uri(plugin, "http://example.org/greeting"),
- "hello",
- strlen("hello") + 1,
- map_uri(plugin, LV2_ATOM__String),
- LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
-
- const uint32_t urid = map_uri(plugin, "http://example.org/urivalue");
- store(callback_data,
- map_uri(plugin, "http://example.org/uri"),
- &urid,
- sizeof(uint32_t),
- map_uri(plugin, LV2_ATOM__URID),
- LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
-
- // Try to store second value for the same property (should fail)
- const uint32_t urid2 = map_uri(plugin, "http://example.org/urivalue2");
- if (!store(callback_data,
- map_uri(plugin, "http://example.org/uri"),
- &urid2,
- sizeof(uint32_t),
- map_uri(plugin, LV2_ATOM__URID),
- LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE)) {
- return LV2_STATE_ERR_UNKNOWN;
- }
-
- // Try to store with a null key (should fail)
- if (!store(callback_data,
- 0,
- &urid2,
- sizeof(uint32_t),
- map_uri(plugin, LV2_ATOM__URID),
- LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE)) {
- return LV2_STATE_ERR_UNKNOWN;
- }
-
- store(callback_data,
- map_uri(plugin, "http://example.org/num-runs"),
- &plugin->num_runs,
- sizeof(plugin->num_runs),
- map_uri(plugin, LV2_ATOM__Int),
- LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
-
- const float two = 2.0f;
- store(callback_data,
- map_uri(plugin, "http://example.org/two"),
- &two,
- sizeof(two),
- map_uri(plugin, LV2_ATOM__Float),
- LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
-
- const uint32_t affirmative = 1;
- store(callback_data,
- map_uri(plugin, "http://example.org/true"),
- &affirmative,
- sizeof(affirmative),
- map_uri(plugin, LV2_ATOM__Bool),
- LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
-
- const uint32_t negative = 0;
- store(callback_data,
- map_uri(plugin, "http://example.org/false"),
- &negative,
- sizeof(negative),
- map_uri(plugin, LV2_ATOM__Bool),
- LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
-
- const uint8_t blob[] = "I am a blob of arbitrary data.";
- store(callback_data,
- map_uri(plugin, "http://example.org/blob"),
- blob,
- sizeof(blob),
- map_uri(plugin, "http://example.org/SomeUnknownType"),
- LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
-
- if (map_path) {
- FILE* file = fopen(plugin->tmp_file_path, "w");
- fprintf(file, "Hello\n");
- fclose(file);
- char* apath = map_path->abstract_path(map_path->handle,
- plugin->tmp_file_path);
- char* apath2 = map_path->abstract_path(map_path->handle,
- plugin->tmp_file_path);
- if (strcmp(apath, apath2)) {
- fprintf(stderr, "ERROR: Path %s != %s\n", apath, apath2);
- }
-
- store(callback_data,
- map_uri(plugin, "http://example.org/extfile"),
- apath,
- strlen(apath) + 1,
- map_uri(plugin, LV2_ATOM__Path),
- LV2_STATE_IS_POD);
-
- free_path->free_path(free_path->handle, apath);
- free_path->free_path(free_path->handle, apath2);
-
- if (plugin->rec_file) {
- fflush(plugin->rec_file);
- apath = map_path->abstract_path(map_path->handle,
- plugin->rec_file_path);
-
- store(callback_data,
- map_uri(plugin, "http://example.org/recfile"),
- apath,
- strlen(apath) + 1,
- map_uri(plugin, LV2_ATOM__Path),
- LV2_STATE_IS_POD);
-
- free_path->free_path(free_path->handle, apath);
- }
-
- if (make_path) {
- char* spath = make_path->path(make_path->handle, "save");
- FILE* sfile = fopen(spath, "w");
- fprintf(sfile, "save");
- fclose(sfile);
-
- apath = map_path->abstract_path(map_path->handle, spath);
- store(callback_data,
- map_uri(plugin, "http://example.org/save-file"),
- apath,
- strlen(apath) + 1,
- map_uri(plugin, LV2_ATOM__Path),
- LV2_STATE_IS_POD);
- free_path->free_path(free_path->handle, apath);
- free_path->free_path(free_path->handle, spath);
- }
- }
-
- return LV2_STATE_SUCCESS;
+ Test* plugin = (Test*)instance;
+
+ LV2_State_Map_Path* map_path = NULL;
+ LV2_State_Make_Path* make_path = NULL;
+ LV2_State_Free_Path* free_path = NULL;
+ for (int i = 0; features && features[i]; ++i) {
+ if (!strcmp(features[i]->URI, LV2_STATE__mapPath)) {
+ map_path = (LV2_State_Map_Path*)features[i]->data;
+ } else if (!strcmp(features[i]->URI, LV2_STATE__makePath)) {
+ make_path = (LV2_State_Make_Path*)features[i]->data;
+ } else if (!strcmp(features[i]->URI, LV2_STATE__freePath)) {
+ free_path = (LV2_State_Free_Path*)features[i]->data;
+ }
+ }
+
+ if (!map_path || !free_path) {
+ return LV2_STATE_ERR_NO_FEATURE;
+ }
+
+ store(callback_data,
+ map_uri(plugin, "http://example.org/greeting"),
+ "hello",
+ strlen("hello") + 1,
+ map_uri(plugin, LV2_ATOM__String),
+ LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
+
+ const uint32_t urid = map_uri(plugin, "http://example.org/urivalue");
+ store(callback_data,
+ map_uri(plugin, "http://example.org/uri"),
+ &urid,
+ sizeof(uint32_t),
+ map_uri(plugin, LV2_ATOM__URID),
+ LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
+
+ // Try to store second value for the same property (should fail)
+ const uint32_t urid2 = map_uri(plugin, "http://example.org/urivalue2");
+ if (!store(callback_data,
+ map_uri(plugin, "http://example.org/uri"),
+ &urid2,
+ sizeof(uint32_t),
+ map_uri(plugin, LV2_ATOM__URID),
+ LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE)) {
+ return LV2_STATE_ERR_UNKNOWN;
+ }
+
+ // Try to store with a null key (should fail)
+ if (!store(callback_data,
+ 0,
+ &urid2,
+ sizeof(uint32_t),
+ map_uri(plugin, LV2_ATOM__URID),
+ LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE)) {
+ return LV2_STATE_ERR_UNKNOWN;
+ }
+
+ store(callback_data,
+ map_uri(plugin, "http://example.org/num-runs"),
+ &plugin->num_runs,
+ sizeof(plugin->num_runs),
+ map_uri(plugin, LV2_ATOM__Int),
+ LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
+
+ const float two = 2.0f;
+ store(callback_data,
+ map_uri(plugin, "http://example.org/two"),
+ &two,
+ sizeof(two),
+ map_uri(plugin, LV2_ATOM__Float),
+ LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
+
+ const uint32_t affirmative = 1;
+ store(callback_data,
+ map_uri(plugin, "http://example.org/true"),
+ &affirmative,
+ sizeof(affirmative),
+ map_uri(plugin, LV2_ATOM__Bool),
+ LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
+
+ const uint32_t negative = 0;
+ store(callback_data,
+ map_uri(plugin, "http://example.org/false"),
+ &negative,
+ sizeof(negative),
+ map_uri(plugin, LV2_ATOM__Bool),
+ LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
+
+ const uint8_t blob[] = "I am a blob of arbitrary data.";
+ store(callback_data,
+ map_uri(plugin, "http://example.org/blob"),
+ blob,
+ sizeof(blob),
+ map_uri(plugin, "http://example.org/SomeUnknownType"),
+ LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
+
+ if (map_path) {
+ FILE* file = fopen(plugin->tmp_file_path, "w");
+ fprintf(file, "Hello\n");
+ fclose(file);
+ char* apath =
+ map_path->abstract_path(map_path->handle, plugin->tmp_file_path);
+ char* apath2 =
+ map_path->abstract_path(map_path->handle, plugin->tmp_file_path);
+ if (strcmp(apath, apath2)) {
+ fprintf(stderr, "ERROR: Path %s != %s\n", apath, apath2);
+ }
+
+ store(callback_data,
+ map_uri(plugin, "http://example.org/extfile"),
+ apath,
+ strlen(apath) + 1,
+ map_uri(plugin, LV2_ATOM__Path),
+ LV2_STATE_IS_POD);
+
+ free_path->free_path(free_path->handle, apath);
+ free_path->free_path(free_path->handle, apath2);
+
+ if (plugin->rec_file) {
+ fflush(plugin->rec_file);
+ apath = map_path->abstract_path(map_path->handle, plugin->rec_file_path);
+
+ store(callback_data,
+ map_uri(plugin, "http://example.org/recfile"),
+ apath,
+ strlen(apath) + 1,
+ map_uri(plugin, LV2_ATOM__Path),
+ LV2_STATE_IS_POD);
+
+ free_path->free_path(free_path->handle, apath);
+ }
+
+ if (make_path) {
+ char* spath = make_path->path(make_path->handle, "save");
+ FILE* sfile = fopen(spath, "w");
+ fprintf(sfile, "save");
+ fclose(sfile);
+
+ apath = map_path->abstract_path(map_path->handle, spath);
+ store(callback_data,
+ map_uri(plugin, "http://example.org/save-file"),
+ apath,
+ strlen(apath) + 1,
+ map_uri(plugin, LV2_ATOM__Path),
+ LV2_STATE_IS_POD);
+ free_path->free_path(free_path->handle, apath);
+ free_path->free_path(free_path->handle, spath);
+ }
+ }
+
+ return LV2_STATE_SUCCESS;
}
static LV2_State_Status
@@ -338,102 +329,105 @@ restore(LV2_Handle instance,
uint32_t flags,
const LV2_Feature* const* features)
{
- Test* plugin = (Test*)instance;
-
- LV2_State_Map_Path* map_path = NULL;
- LV2_State_Free_Path* free_path = NULL;
- for (int i = 0; features && features[i]; ++i) {
- if (!strcmp(features[i]->URI, LV2_STATE__mapPath)) {
- map_path = (LV2_State_Map_Path*)features[i]->data;
- } else if (!strcmp(features[i]->URI, LV2_STATE__freePath)) {
- free_path = (LV2_State_Free_Path*)features[i]->data;
- }
- }
-
- size_t size = 0;
- uint32_t type = 0;
- uint32_t valflags = 0;
-
- plugin->num_runs = *(int32_t*)retrieve(
- callback_data,
- map_uri(plugin, "http://example.org/num-runs"),
- &size, &type, &valflags);
-
- if (!map_path || !free_path) {
- return LV2_STATE_ERR_NO_FEATURE;
- }
-
- char* apath = (char*)retrieve(
- callback_data,
- map_uri(plugin, "http://example.org/extfile"),
- &size, &type, &valflags);
-
- if (valflags != LV2_STATE_IS_POD) {
- fprintf(stderr, "error: Restored bad file flags\n");
- return LV2_STATE_ERR_BAD_FLAGS;
- }
-
- if (apath) {
- char* path = map_path->absolute_path(map_path->handle, apath);
- FILE* f = fopen(path, "r");
- char str[8];
- size_t n_read = fread(str, 1, sizeof(str), f);
- fclose(f);
- if (strncmp(str, "Hello\n", n_read)) {
- fprintf(stderr, "error: Restored bad file contents `%s' != `Hello'\n",
- str);
- }
- free_path->free_path(free_path->handle, path);
- }
-
- apath = (char*)retrieve(
- callback_data,
- map_uri(plugin, "http://example.org/save-file"),
- &size, &type, &valflags);
- if (apath) {
- char* spath = map_path->absolute_path(map_path->handle, apath);
- FILE* sfile = fopen(spath, "r");
- if (!sfile) {
- fprintf(stderr, "error: Failed to open save file %s\n", spath);
- } else {
- fclose(sfile);
- }
- free_path->free_path(free_path->handle, spath);
- } else {
- fprintf(stderr, "error: Failed to restore save file.\n");
- }
-
- return LV2_STATE_SUCCESS;
+ Test* plugin = (Test*)instance;
+
+ LV2_State_Map_Path* map_path = NULL;
+ LV2_State_Free_Path* free_path = NULL;
+ for (int i = 0; features && features[i]; ++i) {
+ if (!strcmp(features[i]->URI, LV2_STATE__mapPath)) {
+ map_path = (LV2_State_Map_Path*)features[i]->data;
+ } else if (!strcmp(features[i]->URI, LV2_STATE__freePath)) {
+ free_path = (LV2_State_Free_Path*)features[i]->data;
+ }
+ }
+
+ size_t size = 0;
+ uint32_t type = 0;
+ uint32_t valflags = 0;
+
+ plugin->num_runs =
+ *(int32_t*)retrieve(callback_data,
+ map_uri(plugin, "http://example.org/num-runs"),
+ &size,
+ &type,
+ &valflags);
+
+ if (!map_path || !free_path) {
+ return LV2_STATE_ERR_NO_FEATURE;
+ }
+
+ char* apath = (char*)retrieve(callback_data,
+ map_uri(plugin, "http://example.org/extfile"),
+ &size,
+ &type,
+ &valflags);
+
+ if (valflags != LV2_STATE_IS_POD) {
+ fprintf(stderr, "error: Restored bad file flags\n");
+ return LV2_STATE_ERR_BAD_FLAGS;
+ }
+
+ if (apath) {
+ char* path = map_path->absolute_path(map_path->handle, apath);
+ FILE* f = fopen(path, "r");
+ char str[8];
+ size_t n_read = fread(str, 1, sizeof(str), f);
+ fclose(f);
+ if (strncmp(str, "Hello\n", n_read)) {
+ fprintf(
+ stderr, "error: Restored bad file contents `%s' != `Hello'\n", str);
+ }
+ free_path->free_path(free_path->handle, path);
+ }
+
+ apath = (char*)retrieve(callback_data,
+ map_uri(plugin, "http://example.org/save-file"),
+ &size,
+ &type,
+ &valflags);
+ if (apath) {
+ char* spath = map_path->absolute_path(map_path->handle, apath);
+ FILE* sfile = fopen(spath, "r");
+ if (!sfile) {
+ fprintf(stderr, "error: Failed to open save file %s\n", spath);
+ } else {
+ fclose(sfile);
+ }
+ free_path->free_path(free_path->handle, spath);
+ } else {
+ fprintf(stderr, "error: Failed to restore save file.\n");
+ }
+
+ return LV2_STATE_SUCCESS;
}
static const void*
extension_data(const char* uri)
{
- static const LV2_State_Interface state = { save, restore };
- if (!strcmp(uri, LV2_STATE__interface)) {
- return &state;
- }
- return NULL;
+ static const LV2_State_Interface state = {save, restore};
+ if (!strcmp(uri, LV2_STATE__interface)) {
+ return &state;
+ }
+ return NULL;
}
-static const LV2_Descriptor descriptor = {
- TEST_URI,
- instantiate,
- connect_port,
- NULL, // activate,
- run,
- NULL, // deactivate,
- cleanup,
- extension_data
-};
+static const LV2_Descriptor descriptor = {TEST_URI,
+ instantiate,
+ connect_port,
+ NULL, // activate,
+ run,
+ NULL, // deactivate,
+ cleanup,
+ extension_data};
LV2_SYMBOL_EXPORT
-const LV2_Descriptor* lv2_descriptor(uint32_t index)
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
{
- switch (index) {
- case 0:
- return &descriptor;
- default:
- return NULL;
- }
+ switch (index) {
+ case 0:
+ return &descriptor;
+ default:
+ return NULL;
+ }
}
diff --git a/test/test_bad_port_index.c b/test/test_bad_port_index.c
index a4d9ad2..a116760 100644
--- a/test/test_bad_port_index.c
+++ b/test/test_bad_port_index.c
@@ -38,21 +38,21 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- uint32_t n_ports = lilv_plugin_get_num_ports(plug);
- assert(n_ports == 0);
+ uint32_t n_ports = lilv_plugin_get_num_ports(plug);
+ assert(n_ports == 0);
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_bad_port_symbol.c b/test/test_bad_port_symbol.c
index be00986..16944b6 100644
--- a/test/test_bad_port_symbol.c
+++ b/test/test_bad_port_symbol.c
@@ -38,21 +38,21 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- uint32_t n_ports = lilv_plugin_get_num_ports(plug);
- assert(n_ports == 0);
+ uint32_t n_ports = lilv_plugin_get_num_ports(plug);
+ assert(n_ports == 0);
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_classes.c b/test/test_classes.c
index 2c74c07..de9fc65 100644
--- a/test/test_classes.c
+++ b/test/test_classes.c
@@ -38,38 +38,38 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
- const LilvPluginClass* plugin = lilv_world_get_plugin_class(world);
- const LilvPluginClasses* classes = lilv_world_get_plugin_classes(world);
- LilvPluginClasses* children = lilv_plugin_class_get_children(plugin);
+ const LilvPluginClass* plugin = lilv_world_get_plugin_class(world);
+ const LilvPluginClasses* classes = lilv_world_get_plugin_classes(world);
+ LilvPluginClasses* children = lilv_plugin_class_get_children(plugin);
- assert(lilv_plugin_class_get_parent_uri(plugin) == NULL);
- assert(lilv_plugin_classes_size(classes) >
- lilv_plugin_classes_size(children));
- assert(!strcmp(lilv_node_as_string(lilv_plugin_class_get_label(plugin)),
- "Plugin"));
- assert(!strcmp(lilv_node_as_string(lilv_plugin_class_get_uri(plugin)),
- "http://lv2plug.in/ns/lv2core#Plugin"));
+ assert(lilv_plugin_class_get_parent_uri(plugin) == NULL);
+ assert(lilv_plugin_classes_size(classes) >
+ lilv_plugin_classes_size(children));
+ assert(!strcmp(lilv_node_as_string(lilv_plugin_class_get_label(plugin)),
+ "Plugin"));
+ assert(!strcmp(lilv_node_as_string(lilv_plugin_class_get_uri(plugin)),
+ "http://lv2plug.in/ns/lv2core#Plugin"));
- LILV_FOREACH (plugin_classes, i, children) {
- assert(lilv_node_equals(lilv_plugin_class_get_parent_uri(
- lilv_plugin_classes_get(children, i)),
- lilv_plugin_class_get_uri(plugin)));
- }
+ LILV_FOREACH (plugin_classes, i, children) {
+ assert(lilv_node_equals(
+ lilv_plugin_class_get_parent_uri(lilv_plugin_classes_get(children, i)),
+ lilv_plugin_class_get_uri(plugin)));
+ }
- LilvNode* some_uri = lilv_new_uri(world, "http://example.org/whatever");
- assert(lilv_plugin_classes_get_by_uri(classes, some_uri) == NULL);
- lilv_node_free(some_uri);
+ LilvNode* some_uri = lilv_new_uri(world, "http://example.org/whatever");
+ assert(lilv_plugin_classes_get_by_uri(classes, some_uri) == NULL);
+ lilv_node_free(some_uri);
- lilv_plugin_classes_free(children);
- delete_bundle(env);
- lilv_test_env_free(env);
+ lilv_plugin_classes_free(children);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_discovery.c b/test/test_discovery.c
index 2585959..f212203 100644
--- a/test/test_discovery.c
+++ b/test/test_discovery.c
@@ -39,58 +39,56 @@ static int discovery_plugin_found = 0;
static void
discovery_verify_plugin(const LilvTestEnv* env, const LilvPlugin* plugin)
{
- const LilvNode* value = lilv_plugin_get_uri(plugin);
- if (lilv_node_equals(value, env->plugin1_uri)) {
- const LilvNode* lib_uri = NULL;
- assert(!lilv_node_equals(value, env->plugin2_uri));
- discovery_plugin_found = 1;
- lib_uri = lilv_plugin_get_library_uri(plugin);
- assert(lib_uri);
- assert(lilv_node_is_uri(lib_uri));
- assert(lilv_node_as_uri(lib_uri));
- assert(strstr(lilv_node_as_uri(lib_uri), "foo" SHLIB_EXT));
- assert(lilv_plugin_verify(plugin));
- }
+ const LilvNode* value = lilv_plugin_get_uri(plugin);
+ if (lilv_node_equals(value, env->plugin1_uri)) {
+ const LilvNode* lib_uri = NULL;
+ assert(!lilv_node_equals(value, env->plugin2_uri));
+ discovery_plugin_found = 1;
+ lib_uri = lilv_plugin_get_library_uri(plugin);
+ assert(lib_uri);
+ assert(lilv_node_is_uri(lib_uri));
+ assert(lilv_node_as_uri(lib_uri));
+ assert(strstr(lilv_node_as_uri(lib_uri), "foo" SHLIB_EXT));
+ assert(lilv_plugin_verify(plugin));
+ }
}
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- assert(lilv_plugins_size(plugins) > 0);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ assert(lilv_plugins_size(plugins) > 0);
- const LilvPlugin* plug1 =
- lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ const LilvPlugin* plug1 = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- const LilvPlugin* plug2 =
- lilv_plugins_get_by_uri(plugins, env->plugin2_uri);
+ const LilvPlugin* plug2 = lilv_plugins_get_by_uri(plugins, env->plugin2_uri);
- assert(plug1);
- assert(!plug2);
+ assert(plug1);
+ assert(!plug2);
- {
- LilvNode* name = lilv_plugin_get_name(plug1);
- assert(!strcmp(lilv_node_as_string(name), "Test plugin"));
- lilv_node_free(name);
- }
+ {
+ LilvNode* name = lilv_plugin_get_name(plug1);
+ assert(!strcmp(lilv_node_as_string(name), "Test plugin"));
+ lilv_node_free(name);
+ }
- discovery_plugin_found = 0;
- LILV_FOREACH (plugins, i, plugins) {
- discovery_verify_plugin(env, lilv_plugins_get(plugins, i));
- }
+ discovery_plugin_found = 0;
+ LILV_FOREACH (plugins, i, plugins) {
+ discovery_verify_plugin(env, lilv_plugins_get(plugins, i));
+ }
- assert(discovery_plugin_found);
- plugins = NULL;
+ assert(discovery_plugin_found);
+ plugins = NULL;
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_filesystem.c b/test/test_filesystem.c
index 7e1968d..761595e 100644
--- a/test/test_filesystem.c
+++ b/test/test_filesystem.c
@@ -30,523 +30,522 @@
static bool
equals(char* string, const char* expected)
{
- const bool result = !strcmp(string, expected);
- free(string);
- return result;
+ const bool result = !strcmp(string, expected);
+ free(string);
+ return result;
}
static void
test_temp_directory_path(void)
{
- char* tmpdir = lilv_temp_directory_path();
+ char* tmpdir = lilv_temp_directory_path();
- assert(lilv_is_directory(tmpdir));
+ assert(lilv_is_directory(tmpdir));
- free(tmpdir);
+ free(tmpdir);
}
static void
test_path_is_absolute(void)
{
- assert(lilv_path_is_absolute("/a/b"));
- assert(lilv_path_is_absolute("/a"));
- assert(lilv_path_is_absolute("/"));
+ assert(lilv_path_is_absolute("/a/b"));
+ assert(lilv_path_is_absolute("/a"));
+ assert(lilv_path_is_absolute("/"));
- assert(!lilv_path_is_absolute("a/b"));
- assert(!lilv_path_is_absolute("a"));
- assert(!lilv_path_is_absolute("."));
+ assert(!lilv_path_is_absolute("a/b"));
+ assert(!lilv_path_is_absolute("a"));
+ assert(!lilv_path_is_absolute("."));
#ifdef _WIN32
- assert(lilv_path_is_absolute("C:/a/b"));
- assert(lilv_path_is_absolute("C:\\a\\b"));
- assert(lilv_path_is_absolute("D:/a/b"));
- assert(lilv_path_is_absolute("D:\\a\\b"));
+ assert(lilv_path_is_absolute("C:/a/b"));
+ assert(lilv_path_is_absolute("C:\\a\\b"));
+ assert(lilv_path_is_absolute("D:/a/b"));
+ assert(lilv_path_is_absolute("D:\\a\\b"));
#endif
}
static void
test_path_is_child(void)
{
- assert(lilv_path_is_child("/a/b", "/a"));
- assert(lilv_path_is_child("/a/b", "/a/"));
- assert(lilv_path_is_child("/a/b/", "/a"));
- assert(lilv_path_is_child("/a/b/", "/a/"));
-
- assert(!lilv_path_is_child("/a/b", "/a/c"));
- assert(!lilv_path_is_child("/a/b", "/a/c/"));
- assert(!lilv_path_is_child("/a/b/", "/a/c"));
- assert(!lilv_path_is_child("/a/b/", "/a/c/"));
-
- assert(!lilv_path_is_child("/a/b", "/c"));
- assert(!lilv_path_is_child("/a/b", "/c/"));
- assert(!lilv_path_is_child("/a/b/", "/c"));
- assert(!lilv_path_is_child("/a/b/", "/c/"));
+ assert(lilv_path_is_child("/a/b", "/a"));
+ assert(lilv_path_is_child("/a/b", "/a/"));
+ assert(lilv_path_is_child("/a/b/", "/a"));
+ assert(lilv_path_is_child("/a/b/", "/a/"));
+
+ assert(!lilv_path_is_child("/a/b", "/a/c"));
+ assert(!lilv_path_is_child("/a/b", "/a/c/"));
+ assert(!lilv_path_is_child("/a/b/", "/a/c"));
+ assert(!lilv_path_is_child("/a/b/", "/a/c/"));
+
+ assert(!lilv_path_is_child("/a/b", "/c"));
+ assert(!lilv_path_is_child("/a/b", "/c/"));
+ assert(!lilv_path_is_child("/a/b/", "/c"));
+ assert(!lilv_path_is_child("/a/b/", "/c/"));
}
static void
test_path_current(void)
{
- char* cwd = lilv_path_current();
+ char* cwd = lilv_path_current();
- assert(lilv_is_directory(cwd));
+ assert(lilv_is_directory(cwd));
- free(cwd);
+ free(cwd);
}
static void
test_path_absolute(void)
{
- const char* const short_path = "a";
- const char* const long_path = "a/b/c";
+ const char* const short_path = "a";
+ const char* const long_path = "a/b/c";
- char* const cwd = lilv_path_current();
- char* const expected_short = lilv_path_join(cwd, short_path);
- char* const expected_long = lilv_path_join(cwd, long_path);
+ char* const cwd = lilv_path_current();
+ char* const expected_short = lilv_path_join(cwd, short_path);
+ char* const expected_long = lilv_path_join(cwd, long_path);
- assert(equals(lilv_path_absolute(short_path), expected_short));
- assert(equals(lilv_path_absolute(long_path), expected_long));
+ assert(equals(lilv_path_absolute(short_path), expected_short));
+ assert(equals(lilv_path_absolute(long_path), expected_long));
- free(expected_long);
- free(expected_short);
- free(cwd);
+ free(expected_long);
+ free(expected_short);
+ free(cwd);
}
static void
test_path_absolute_child(void)
{
- const char* const parent = "/parent";
- const char* const short_path = "a";
- const char* const long_path = "a/b/c";
+ const char* const parent = "/parent";
+ const char* const short_path = "a";
+ const char* const long_path = "a/b/c";
- char* const expected_short = lilv_path_join(parent, short_path);
- char* const expected_long = lilv_path_join(parent, long_path);
+ char* const expected_short = lilv_path_join(parent, short_path);
+ char* const expected_long = lilv_path_join(parent, long_path);
- assert(equals(lilv_path_absolute_child(short_path, parent),
- expected_short));
+ assert(equals(lilv_path_absolute_child(short_path, parent), expected_short));
- assert(equals(lilv_path_absolute_child(long_path, parent),
- expected_long));
+ assert(equals(lilv_path_absolute_child(long_path, parent), expected_long));
- free(expected_long);
- free(expected_short);
+ free(expected_long);
+ free(expected_short);
}
static void
test_path_relative_to(void)
{
- assert(equals(lilv_path_relative_to("/a/b", "/a/"), "b"));
- assert(equals(lilv_path_relative_to("/a", "/b/c/"), "/a"));
- assert(equals(lilv_path_relative_to("/a/b/c", "/a/b/d/"), "../c"));
- assert(equals(lilv_path_relative_to("/a/b/c", "/a/b/d/e/"), "../../c"));
+ assert(equals(lilv_path_relative_to("/a/b", "/a/"), "b"));
+ assert(equals(lilv_path_relative_to("/a", "/b/c/"), "/a"));
+ assert(equals(lilv_path_relative_to("/a/b/c", "/a/b/d/"), "../c"));
+ assert(equals(lilv_path_relative_to("/a/b/c", "/a/b/d/e/"), "../../c"));
#ifdef _WIN32
- assert(equals(lilv_path_relative_to("C:/a/b", "C:/a/"), "b"));
- assert(equals(lilv_path_relative_to("C:/a", "C:/b/c/"), "../../a"));
- assert(equals(lilv_path_relative_to("C:/a/b/c", "C:/a/b/d/"), "../c"));
- assert(equals(lilv_path_relative_to("C:/a/b/c", "C:/a/b/d/e/"), "../../c"));
-
- assert(equals(lilv_path_relative_to("C:\\a\\b", "C:\\a\\"), "b"));
- assert(equals(lilv_path_relative_to("C:\\a", "C:\\b\\c\\"), "..\\..\\a"));
- assert(equals(lilv_path_relative_to("C:\\a\\b\\c", "C:\\a\\b\\d\\"), "..\\c"));
- assert(equals(lilv_path_relative_to("C:\\a\\b\\c", "C:\\a\\b\\d\\e\\"), "..\\..\\c"));
+ assert(equals(lilv_path_relative_to("C:/a/b", "C:/a/"), "b"));
+ assert(equals(lilv_path_relative_to("C:/a", "C:/b/c/"), "../../a"));
+ assert(equals(lilv_path_relative_to("C:/a/b/c", "C:/a/b/d/"), "../c"));
+ assert(equals(lilv_path_relative_to("C:/a/b/c", "C:/a/b/d/e/"), "../../c"));
+
+ assert(equals(lilv_path_relative_to("C:\\a\\b", "C:\\a\\"), "b"));
+ assert(equals(lilv_path_relative_to("C:\\a", "C:\\b\\c\\"), "..\\..\\a"));
+ assert(
+ equals(lilv_path_relative_to("C:\\a\\b\\c", "C:\\a\\b\\d\\"), "..\\c"));
+ assert(equals(lilv_path_relative_to("C:\\a\\b\\c", "C:\\a\\b\\d\\e\\"),
+ "..\\..\\c"));
#endif
}
static void
test_path_parent(void)
{
- assert(equals(lilv_path_parent("/"), "/"));
- assert(equals(lilv_path_parent("//"), "/"));
- assert(equals(lilv_path_parent("/a"), "/"));
- assert(equals(lilv_path_parent("/a/"), "/"));
- assert(equals(lilv_path_parent("/a///b/"), "/a"));
- assert(equals(lilv_path_parent("/a///b//"), "/a"));
- assert(equals(lilv_path_parent("/a/b"), "/a"));
- assert(equals(lilv_path_parent("/a/b/"), "/a"));
- assert(equals(lilv_path_parent("/a/b/c"), "/a/b"));
- assert(equals(lilv_path_parent("/a/b/c/"), "/a/b"));
- assert(equals(lilv_path_parent("a"), "."));
+ assert(equals(lilv_path_parent("/"), "/"));
+ assert(equals(lilv_path_parent("//"), "/"));
+ assert(equals(lilv_path_parent("/a"), "/"));
+ assert(equals(lilv_path_parent("/a/"), "/"));
+ assert(equals(lilv_path_parent("/a///b/"), "/a"));
+ assert(equals(lilv_path_parent("/a///b//"), "/a"));
+ assert(equals(lilv_path_parent("/a/b"), "/a"));
+ assert(equals(lilv_path_parent("/a/b/"), "/a"));
+ assert(equals(lilv_path_parent("/a/b/c"), "/a/b"));
+ assert(equals(lilv_path_parent("/a/b/c/"), "/a/b"));
+ assert(equals(lilv_path_parent("a"), "."));
}
static void
test_path_filename(void)
{
- // Cases from cppreference.com for std::filesystem::path::filename
- assert(equals(lilv_path_filename("/foo/bar.txt"), "bar.txt"));
- assert(equals(lilv_path_filename("/foo/.bar"), ".bar"));
- assert(equals(lilv_path_filename("/foo/bar/"), ""));
- assert(equals(lilv_path_filename("/foo/."), "."));
- assert(equals(lilv_path_filename("/foo/.."), ".."));
- assert(equals(lilv_path_filename("."), "."));
- assert(equals(lilv_path_filename(".."), ".."));
- assert(equals(lilv_path_filename("/"), ""));
- assert(equals(lilv_path_filename("//host"), "host"));
+ // Cases from cppreference.com for std::filesystem::path::filename
+ assert(equals(lilv_path_filename("/foo/bar.txt"), "bar.txt"));
+ assert(equals(lilv_path_filename("/foo/.bar"), ".bar"));
+ assert(equals(lilv_path_filename("/foo/bar/"), ""));
+ assert(equals(lilv_path_filename("/foo/."), "."));
+ assert(equals(lilv_path_filename("/foo/.."), ".."));
+ assert(equals(lilv_path_filename("."), "."));
+ assert(equals(lilv_path_filename(".."), ".."));
+ assert(equals(lilv_path_filename("/"), ""));
+ assert(equals(lilv_path_filename("//host"), "host"));
#ifdef _WIN32
- assert(equals(lilv_path_filename("C:/foo/bar.txt"), "bar.txt"));
- assert(equals(lilv_path_filename("C:\\foo\\bar.txt"), "bar.txt"));
- assert(equals(lilv_path_filename("foo/bar.txt"), "bar.txt"));
- assert(equals(lilv_path_filename("foo\\bar.txt"), "bar.txt"));
+ assert(equals(lilv_path_filename("C:/foo/bar.txt"), "bar.txt"));
+ assert(equals(lilv_path_filename("C:\\foo\\bar.txt"), "bar.txt"));
+ assert(equals(lilv_path_filename("foo/bar.txt"), "bar.txt"));
+ assert(equals(lilv_path_filename("foo\\bar.txt"), "bar.txt"));
#endif
}
static void
test_path_join(void)
{
- assert(lilv_path_join(NULL, NULL) == NULL);
- assert(lilv_path_join(NULL, "") == NULL);
+ assert(lilv_path_join(NULL, NULL) == NULL);
+ assert(lilv_path_join(NULL, "") == NULL);
#ifdef _WIN32
- assert(equals(lilv_path_join("", NULL), "\\"));
- assert(equals(lilv_path_join("", ""), "\\"));
- assert(equals(lilv_path_join("a", ""), "a\\"));
- assert(equals(lilv_path_join("a", NULL), "a\\"));
- assert(equals(lilv_path_join("a", "b"), "a\\b"));
+ assert(equals(lilv_path_join("", NULL), "\\"));
+ assert(equals(lilv_path_join("", ""), "\\"));
+ assert(equals(lilv_path_join("a", ""), "a\\"));
+ assert(equals(lilv_path_join("a", NULL), "a\\"));
+ assert(equals(lilv_path_join("a", "b"), "a\\b"));
#else
- assert(equals(lilv_path_join("", NULL), "/"));
- assert(equals(lilv_path_join("", ""), "/"));
- assert(equals(lilv_path_join("a", ""), "a/"));
- assert(equals(lilv_path_join("a", NULL), "a/"));
- assert(equals(lilv_path_join("a", "b"), "a/b"));
+ assert(equals(lilv_path_join("", NULL), "/"));
+ assert(equals(lilv_path_join("", ""), "/"));
+ assert(equals(lilv_path_join("a", ""), "a/"));
+ assert(equals(lilv_path_join("a", NULL), "a/"));
+ assert(equals(lilv_path_join("a", "b"), "a/b"));
#endif
- assert(equals(lilv_path_join("/a", ""), "/a/"));
- assert(equals(lilv_path_join("/a/b", ""), "/a/b/"));
- assert(equals(lilv_path_join("/a/", ""), "/a/"));
- assert(equals(lilv_path_join("/a/b/", ""), "/a/b/"));
- assert(equals(lilv_path_join("a/b", ""), "a/b/"));
- assert(equals(lilv_path_join("a/", ""), "a/"));
- assert(equals(lilv_path_join("a/b/", ""), "a/b/"));
-
- assert(equals(lilv_path_join("/a", NULL), "/a/"));
- assert(equals(lilv_path_join("/a/b", NULL), "/a/b/"));
- assert(equals(lilv_path_join("/a/", NULL), "/a/"));
- assert(equals(lilv_path_join("/a/b/", NULL), "/a/b/"));
- assert(equals(lilv_path_join("a/b", NULL), "a/b/"));
- assert(equals(lilv_path_join("a/", NULL), "a/"));
- assert(equals(lilv_path_join("a/b/", NULL), "a/b/"));
-
- assert(equals(lilv_path_join("/a", "b"), "/a/b"));
- assert(equals(lilv_path_join("/a/", "b"), "/a/b"));
- assert(equals(lilv_path_join("a/", "b"), "a/b"));
-
- assert(equals(lilv_path_join("/a", "b/"), "/a/b/"));
- assert(equals(lilv_path_join("/a/", "b/"), "/a/b/"));
- assert(equals(lilv_path_join("a", "b/"), "a/b/"));
- assert(equals(lilv_path_join("a/", "b/"), "a/b/"));
+ assert(equals(lilv_path_join("/a", ""), "/a/"));
+ assert(equals(lilv_path_join("/a/b", ""), "/a/b/"));
+ assert(equals(lilv_path_join("/a/", ""), "/a/"));
+ assert(equals(lilv_path_join("/a/b/", ""), "/a/b/"));
+ assert(equals(lilv_path_join("a/b", ""), "a/b/"));
+ assert(equals(lilv_path_join("a/", ""), "a/"));
+ assert(equals(lilv_path_join("a/b/", ""), "a/b/"));
+
+ assert(equals(lilv_path_join("/a", NULL), "/a/"));
+ assert(equals(lilv_path_join("/a/b", NULL), "/a/b/"));
+ assert(equals(lilv_path_join("/a/", NULL), "/a/"));
+ assert(equals(lilv_path_join("/a/b/", NULL), "/a/b/"));
+ assert(equals(lilv_path_join("a/b", NULL), "a/b/"));
+ assert(equals(lilv_path_join("a/", NULL), "a/"));
+ assert(equals(lilv_path_join("a/b/", NULL), "a/b/"));
+
+ assert(equals(lilv_path_join("/a", "b"), "/a/b"));
+ assert(equals(lilv_path_join("/a/", "b"), "/a/b"));
+ assert(equals(lilv_path_join("a/", "b"), "a/b"));
+
+ assert(equals(lilv_path_join("/a", "b/"), "/a/b/"));
+ assert(equals(lilv_path_join("/a/", "b/"), "/a/b/"));
+ assert(equals(lilv_path_join("a", "b/"), "a/b/"));
+ assert(equals(lilv_path_join("a/", "b/"), "a/b/"));
#ifdef _WIN32
- assert(equals(lilv_path_join("C:/a", "b"), "C:/a/b"));
- assert(equals(lilv_path_join("C:\\a", "b"), "C:\\a\\b"));
- assert(equals(lilv_path_join("C:/a", "b/"), "C:/a/b/"));
- assert(equals(lilv_path_join("C:\\a", "b\\"), "C:\\a\\b\\"));
+ assert(equals(lilv_path_join("C:/a", "b"), "C:/a/b"));
+ assert(equals(lilv_path_join("C:\\a", "b"), "C:\\a\\b"));
+ assert(equals(lilv_path_join("C:/a", "b/"), "C:/a/b/"));
+ assert(equals(lilv_path_join("C:\\a", "b\\"), "C:\\a\\b\\"));
#endif
}
static void
test_path_canonical(void)
{
- char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
- char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
+ char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
+ char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
- FILE* f = fopen(file_path, "w");
- fprintf(f, "test\n");
- fclose(f);
+ FILE* f = fopen(file_path, "w");
+ fprintf(f, "test\n");
+ fclose(f);
#ifndef _WIN32
- // Test symlink resolution
+ // Test symlink resolution
- char* const link_path = lilv_path_join(temp_dir, "lilv_test_link");
+ char* const link_path = lilv_path_join(temp_dir, "lilv_test_link");
- assert(!lilv_symlink(file_path, link_path));
+ assert(!lilv_symlink(file_path, link_path));
- char* const real_file_path = lilv_path_canonical(file_path);
- char* const real_link_path = lilv_path_canonical(link_path);
+ char* const real_file_path = lilv_path_canonical(file_path);
+ char* const real_link_path = lilv_path_canonical(link_path);
- assert(!strcmp(real_file_path, real_link_path));
+ assert(!strcmp(real_file_path, real_link_path));
- assert(!lilv_remove(link_path));
- free(real_link_path);
- free(real_file_path);
- free(link_path);
+ assert(!lilv_remove(link_path));
+ free(real_link_path);
+ free(real_file_path);
+ free(link_path);
#endif
- // Test dot segment resolution
+ // Test dot segment resolution
- char* const parent_dir_1 = lilv_path_join(temp_dir, "..");
- char* const parent_dir_2 = lilv_path_parent(temp_dir);
- char* const real_parent_dir_1 = lilv_path_canonical(parent_dir_1);
- char* const real_parent_dir_2 = lilv_path_canonical(parent_dir_2);
+ char* const parent_dir_1 = lilv_path_join(temp_dir, "..");
+ char* const parent_dir_2 = lilv_path_parent(temp_dir);
+ char* const real_parent_dir_1 = lilv_path_canonical(parent_dir_1);
+ char* const real_parent_dir_2 = lilv_path_canonical(parent_dir_2);
- assert(!strcmp(real_parent_dir_1, real_parent_dir_2));
+ assert(!strcmp(real_parent_dir_1, real_parent_dir_2));
- // Clean everything up
+ // Clean everything up
- assert(!lilv_remove(file_path));
- assert(!lilv_remove(temp_dir));
+ assert(!lilv_remove(file_path));
+ assert(!lilv_remove(temp_dir));
- free(real_parent_dir_2);
- free(real_parent_dir_1);
- free(parent_dir_2);
- free(parent_dir_1);
- free(file_path);
- free(temp_dir);
+ free(real_parent_dir_2);
+ free(real_parent_dir_1);
+ free(parent_dir_2);
+ free(parent_dir_1);
+ free(file_path);
+ free(temp_dir);
}
static void
test_path_exists(void)
{
- char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
- char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
+ char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
+ char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
- assert(!lilv_path_exists(file_path));
+ assert(!lilv_path_exists(file_path));
- FILE* f = fopen(file_path, "w");
- fprintf(f, "test\n");
- fclose(f);
+ FILE* f = fopen(file_path, "w");
+ fprintf(f, "test\n");
+ fclose(f);
- assert(lilv_path_exists(file_path));
+ assert(lilv_path_exists(file_path));
- assert(!lilv_remove(file_path));
- assert(!lilv_remove(temp_dir));
+ assert(!lilv_remove(file_path));
+ assert(!lilv_remove(temp_dir));
- free(file_path);
- free(temp_dir);
+ free(file_path);
+ free(temp_dir);
}
static void
test_is_directory(void)
{
- char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
- char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
+ char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
+ char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
- assert(lilv_is_directory(temp_dir));
- assert(!lilv_is_directory(file_path)); // Nonexistent
+ assert(lilv_is_directory(temp_dir));
+ assert(!lilv_is_directory(file_path)); // Nonexistent
- FILE* f = fopen(file_path, "w");
- fprintf(f, "test\n");
- fclose(f);
+ FILE* f = fopen(file_path, "w");
+ fprintf(f, "test\n");
+ fclose(f);
- assert(!lilv_is_directory(file_path)); // File
+ assert(!lilv_is_directory(file_path)); // File
- assert(!lilv_remove(file_path));
- assert(!lilv_remove(temp_dir));
+ assert(!lilv_remove(file_path));
+ assert(!lilv_remove(temp_dir));
- free(file_path);
- free(temp_dir);
+ free(file_path);
+ free(temp_dir);
}
static void
test_copy_file(void)
{
- char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
- char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
- char* const copy_path = lilv_path_join(temp_dir, "lilv_test_copy");
-
- FILE* f = fopen(file_path, "w");
- fprintf(f, "test\n");
- fclose(f);
-
- assert(!lilv_copy_file(file_path, copy_path));
- assert(lilv_file_equals(file_path, copy_path));
-
- if (lilv_path_exists("/dev/full")) {
- // Copy short file (error after flushing)
- assert(lilv_copy_file(file_path, "/dev/full") == ENOSPC);
-
- // Copy long file (error during writing)
- f = fopen(file_path, "w");
- for (size_t i = 0; i < 4096; ++i) {
- fprintf(f, "test\n");
- }
- fclose(f);
- assert(lilv_copy_file(file_path, "/dev/full") == ENOSPC);
- }
-
- assert(!lilv_remove(copy_path));
- assert(!lilv_remove(file_path));
- assert(!lilv_remove(temp_dir));
-
- free(copy_path);
- free(file_path);
- free(temp_dir);
+ char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
+ char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
+ char* const copy_path = lilv_path_join(temp_dir, "lilv_test_copy");
+
+ FILE* f = fopen(file_path, "w");
+ fprintf(f, "test\n");
+ fclose(f);
+
+ assert(!lilv_copy_file(file_path, copy_path));
+ assert(lilv_file_equals(file_path, copy_path));
+
+ if (lilv_path_exists("/dev/full")) {
+ // Copy short file (error after flushing)
+ assert(lilv_copy_file(file_path, "/dev/full") == ENOSPC);
+
+ // Copy long file (error during writing)
+ f = fopen(file_path, "w");
+ for (size_t i = 0; i < 4096; ++i) {
+ fprintf(f, "test\n");
+ }
+ fclose(f);
+ assert(lilv_copy_file(file_path, "/dev/full") == ENOSPC);
+ }
+
+ assert(!lilv_remove(copy_path));
+ assert(!lilv_remove(file_path));
+ assert(!lilv_remove(temp_dir));
+
+ free(copy_path);
+ free(file_path);
+ free(temp_dir);
}
static void
test_flock(void)
{
- char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
- char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
-
- FILE* const f1 = fopen(file_path, "w");
- FILE* const f2 = fopen(file_path, "w");
-
- assert(!lilv_flock(f1, true, false));
- assert(lilv_flock(f2, true, false));
- assert(!lilv_flock(f1, false, false));
-
- fclose(f2);
- fclose(f1);
- assert(!lilv_remove(file_path));
- assert(!lilv_remove(temp_dir));
- free(file_path);
- free(temp_dir);
+ char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
+ char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
+
+ FILE* const f1 = fopen(file_path, "w");
+ FILE* const f2 = fopen(file_path, "w");
+
+ assert(!lilv_flock(f1, true, false));
+ assert(lilv_flock(f2, true, false));
+ assert(!lilv_flock(f1, false, false));
+
+ fclose(f2);
+ fclose(f1);
+ assert(!lilv_remove(file_path));
+ assert(!lilv_remove(temp_dir));
+ free(file_path);
+ free(temp_dir);
}
-typedef struct
-{
- size_t n_names;
- char** names;
+typedef struct {
+ size_t n_names;
+ char** names;
} FileList;
static void
visit(const char* const path, const char* const name, void* const data)
{
- FileList* file_list = (FileList*)data;
+ FileList* file_list = (FileList*)data;
- file_list->names =
- (char**)realloc(file_list->names, sizeof(char*) * ++file_list->n_names);
+ file_list->names =
+ (char**)realloc(file_list->names, sizeof(char*) * ++file_list->n_names);
- file_list->names[file_list->n_names - 1] = lilv_strdup(name);
+ file_list->names[file_list->n_names - 1] = lilv_strdup(name);
}
static void
test_dir_for_each(void)
{
- char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
- char* const path1 = lilv_path_join(temp_dir, "lilv_test_1");
- char* const path2 = lilv_path_join(temp_dir, "lilv_test_2");
-
- FILE* const f1 = fopen(path1, "w");
- FILE* const f2 = fopen(path2, "w");
- fprintf(f1, "test\n");
- fprintf(f2, "test\n");
- fclose(f2);
- fclose(f1);
-
- FileList file_list = {0, NULL};
- lilv_dir_for_each(temp_dir, &file_list, visit);
-
- assert((!strcmp(file_list.names[0], "lilv_test_1") &&
- !strcmp(file_list.names[1], "lilv_test_2")) ||
- (!strcmp(file_list.names[0], "lilv_test_2") &&
- !strcmp(file_list.names[1], "lilv_test_1")));
-
- assert(!lilv_remove(path2));
- assert(!lilv_remove(path1));
- assert(!lilv_remove(temp_dir));
-
- free(file_list.names[0]);
- free(file_list.names[1]);
- free(file_list.names);
- free(path2);
- free(path1);
- free(temp_dir);
+ char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
+ char* const path1 = lilv_path_join(temp_dir, "lilv_test_1");
+ char* const path2 = lilv_path_join(temp_dir, "lilv_test_2");
+
+ FILE* const f1 = fopen(path1, "w");
+ FILE* const f2 = fopen(path2, "w");
+ fprintf(f1, "test\n");
+ fprintf(f2, "test\n");
+ fclose(f2);
+ fclose(f1);
+
+ FileList file_list = {0, NULL};
+ lilv_dir_for_each(temp_dir, &file_list, visit);
+
+ assert((!strcmp(file_list.names[0], "lilv_test_1") &&
+ !strcmp(file_list.names[1], "lilv_test_2")) ||
+ (!strcmp(file_list.names[0], "lilv_test_2") &&
+ !strcmp(file_list.names[1], "lilv_test_1")));
+
+ assert(!lilv_remove(path2));
+ assert(!lilv_remove(path1));
+ assert(!lilv_remove(temp_dir));
+
+ free(file_list.names[0]);
+ free(file_list.names[1]);
+ free(file_list.names);
+ free(path2);
+ free(path1);
+ free(temp_dir);
}
static void
test_create_temporary_directory(void)
{
- char* const path1 = lilv_create_temporary_directory("lilvXXXXXX");
+ char* const path1 = lilv_create_temporary_directory("lilvXXXXXX");
- assert(lilv_is_directory(path1));
+ assert(lilv_is_directory(path1));
- char* const path2 = lilv_create_temporary_directory("lilvXXXXXX");
+ char* const path2 = lilv_create_temporary_directory("lilvXXXXXX");
- assert(strcmp(path1, path2));
- assert(lilv_is_directory(path2));
+ assert(strcmp(path1, path2));
+ assert(lilv_is_directory(path2));
- assert(!lilv_remove(path2));
- assert(!lilv_remove(path1));
- free(path2);
- free(path1);
+ assert(!lilv_remove(path2));
+ assert(!lilv_remove(path1));
+ free(path2);
+ free(path1);
}
static void
test_create_directories(void)
{
- char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
+ char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
- assert(lilv_is_directory(temp_dir));
+ assert(lilv_is_directory(temp_dir));
- char* const child_dir = lilv_path_join(temp_dir, "child");
- char* const grandchild_dir = lilv_path_join(child_dir, "grandchild");
+ char* const child_dir = lilv_path_join(temp_dir, "child");
+ char* const grandchild_dir = lilv_path_join(child_dir, "grandchild");
- assert(!lilv_create_directories(grandchild_dir));
- assert(lilv_is_directory(grandchild_dir));
- assert(lilv_is_directory(child_dir));
+ assert(!lilv_create_directories(grandchild_dir));
+ assert(lilv_is_directory(grandchild_dir));
+ assert(lilv_is_directory(child_dir));
- char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
- FILE* const f = fopen(file_path, "w");
+ char* const file_path = lilv_path_join(temp_dir, "lilv_test_file");
+ FILE* const f = fopen(file_path, "w");
- fprintf(f, "test\n");
- fclose(f);
+ fprintf(f, "test\n");
+ fclose(f);
- assert(lilv_create_directories(file_path));
+ assert(lilv_create_directories(file_path));
- assert(!lilv_remove(file_path));
- assert(!lilv_remove(grandchild_dir));
- assert(!lilv_remove(child_dir));
- assert(!lilv_remove(temp_dir));
- free(file_path);
- free(child_dir);
- free(grandchild_dir);
- free(temp_dir);
+ assert(!lilv_remove(file_path));
+ assert(!lilv_remove(grandchild_dir));
+ assert(!lilv_remove(child_dir));
+ assert(!lilv_remove(temp_dir));
+ free(file_path);
+ free(child_dir);
+ free(grandchild_dir);
+ free(temp_dir);
}
static void
test_file_equals(void)
{
- char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
- char* const path1 = lilv_path_join(temp_dir, "lilv_test_1");
- char* const path2 = lilv_path_join(temp_dir, "lilv_test_2");
+ char* const temp_dir = lilv_create_temporary_directory("lilvXXXXXX");
+ char* const path1 = lilv_path_join(temp_dir, "lilv_test_1");
+ char* const path2 = lilv_path_join(temp_dir, "lilv_test_2");
- FILE* const f1 = fopen(path1, "w");
- FILE* const f2 = fopen(path2, "w");
- fprintf(f1, "test\n");
- fprintf(f2, "test\n");
+ FILE* const f1 = fopen(path1, "w");
+ FILE* const f2 = fopen(path2, "w");
+ fprintf(f1, "test\n");
+ fprintf(f2, "test\n");
- assert(lilv_file_equals(path1, path2));
+ assert(lilv_file_equals(path1, path2));
- fprintf(f2, "diff\n");
- fflush(f2);
+ fprintf(f2, "diff\n");
+ fflush(f2);
- assert(!lilv_file_equals(path1, path2));
+ assert(!lilv_file_equals(path1, path2));
- fclose(f2);
- fclose(f1);
+ fclose(f2);
+ fclose(f1);
- assert(!lilv_remove(path2));
- assert(!lilv_remove(path1));
- assert(!lilv_remove(temp_dir));
+ assert(!lilv_remove(path2));
+ assert(!lilv_remove(path1));
+ assert(!lilv_remove(temp_dir));
- free(path2);
- free(path1);
- free(temp_dir);
+ free(path2);
+ free(path1);
+ free(temp_dir);
}
int
main(void)
{
- test_temp_directory_path();
- test_path_is_absolute();
- test_path_is_child();
- test_path_current();
- test_path_absolute();
- test_path_absolute_child();
- test_path_relative_to();
- test_path_parent();
- test_path_filename();
- test_path_join();
- test_path_canonical();
- test_path_exists();
- test_is_directory();
- test_copy_file();
- test_flock();
- test_dir_for_each();
- test_create_temporary_directory();
- test_create_directories();
- test_file_equals();
-
- return 0;
+ test_temp_directory_path();
+ test_path_is_absolute();
+ test_path_is_child();
+ test_path_current();
+ test_path_absolute();
+ test_path_absolute_child();
+ test_path_relative_to();
+ test_path_parent();
+ test_path_filename();
+ test_path_join();
+ test_path_canonical();
+ test_path_exists();
+ test_is_directory();
+ test_copy_file();
+ test_flock();
+ test_dir_for_each();
+ test_create_temporary_directory();
+ test_create_directories();
+ test_file_equals();
+
+ return 0;
}
diff --git a/test/test_get_symbol.c b/test/test_get_symbol.c
index 0427447..e8cb452 100644
--- a/test/test_get_symbol.c
+++ b/test/test_get_symbol.c
@@ -37,45 +37,45 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, manifest_ttl, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, manifest_ttl, plugin_ttl)) {
+ return 1;
+ }
- LilvNode* plug_sym = lilv_world_get_symbol(world, env->plugin1_uri);
- LilvNode* path = lilv_new_uri(world, "http://example.org/foo");
- LilvNode* path_sym = lilv_world_get_symbol(world, path);
- LilvNode* query = lilv_new_uri(world, "http://example.org/foo?bar=baz");
- LilvNode* query_sym = lilv_world_get_symbol(world, query);
- LilvNode* frag = lilv_new_uri(world, "http://example.org/foo#bar");
- LilvNode* frag_sym = lilv_world_get_symbol(world, frag);
- LilvNode* queryfrag =
- lilv_new_uri(world, "http://example.org/foo?bar=baz#quux");
- LilvNode* queryfrag_sym = lilv_world_get_symbol(world, queryfrag);
- LilvNode* nonuri = lilv_new_int(world, 42);
+ LilvNode* plug_sym = lilv_world_get_symbol(world, env->plugin1_uri);
+ LilvNode* path = lilv_new_uri(world, "http://example.org/foo");
+ LilvNode* path_sym = lilv_world_get_symbol(world, path);
+ LilvNode* query = lilv_new_uri(world, "http://example.org/foo?bar=baz");
+ LilvNode* query_sym = lilv_world_get_symbol(world, query);
+ LilvNode* frag = lilv_new_uri(world, "http://example.org/foo#bar");
+ LilvNode* frag_sym = lilv_world_get_symbol(world, frag);
+ LilvNode* queryfrag =
+ lilv_new_uri(world, "http://example.org/foo?bar=baz#quux");
+ LilvNode* queryfrag_sym = lilv_world_get_symbol(world, queryfrag);
+ LilvNode* nonuri = lilv_new_int(world, 42);
- assert(lilv_world_get_symbol(world, nonuri) == NULL);
- assert(!strcmp(lilv_node_as_string(plug_sym), "plugsym"));
- assert(!strcmp(lilv_node_as_string(path_sym), "foo"));
- assert(!strcmp(lilv_node_as_string(query_sym), "bar_baz"));
- assert(!strcmp(lilv_node_as_string(frag_sym), "bar"));
- assert(!strcmp(lilv_node_as_string(queryfrag_sym), "quux"));
+ assert(lilv_world_get_symbol(world, nonuri) == NULL);
+ assert(!strcmp(lilv_node_as_string(plug_sym), "plugsym"));
+ assert(!strcmp(lilv_node_as_string(path_sym), "foo"));
+ assert(!strcmp(lilv_node_as_string(query_sym), "bar_baz"));
+ assert(!strcmp(lilv_node_as_string(frag_sym), "bar"));
+ assert(!strcmp(lilv_node_as_string(queryfrag_sym), "quux"));
- lilv_node_free(nonuri);
- lilv_node_free(queryfrag_sym);
- lilv_node_free(queryfrag);
- lilv_node_free(frag_sym);
- lilv_node_free(frag);
- lilv_node_free(query_sym);
- lilv_node_free(query);
- lilv_node_free(path_sym);
- lilv_node_free(path);
- lilv_node_free(plug_sym);
+ lilv_node_free(nonuri);
+ lilv_node_free(queryfrag_sym);
+ lilv_node_free(queryfrag);
+ lilv_node_free(frag_sym);
+ lilv_node_free(frag);
+ lilv_node_free(query_sym);
+ lilv_node_free(query);
+ lilv_node_free(path_sym);
+ lilv_node_free(path);
+ lilv_node_free(plug_sym);
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_no_author.c b/test/test_no_author.c
index 9cceedc..b67a284 100644
--- a/test/test_no_author.c
+++ b/test/test_no_author.c
@@ -60,28 +60,28 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(plug);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ assert(plug);
- LilvNode* author_name = lilv_plugin_get_author_name(plug);
- assert(!author_name);
+ LilvNode* author_name = lilv_plugin_get_author_name(plug);
+ assert(!author_name);
- LilvNode* author_email = lilv_plugin_get_author_email(plug);
- assert(!author_email);
+ LilvNode* author_email = lilv_plugin_get_author_email(plug);
+ assert(!author_email);
- LilvNode* author_homepage = lilv_plugin_get_author_homepage(plug);
- assert(!author_homepage);
+ LilvNode* author_homepage = lilv_plugin_get_author_homepage(plug);
+ assert(!author_homepage);
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_no_verify.c b/test/test_no_verify.c
index 70812a5..cf6e0fd 100644
--- a/test/test_no_verify.c
+++ b/test/test_no_verify.c
@@ -27,22 +27,21 @@ static const char* const plugin_ttl = ":plug a lv2:Plugin .\n";
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* explug =
- lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* explug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(explug);
- assert(!lilv_plugin_verify(explug));
+ assert(explug);
+ assert(!lilv_plugin_verify(explug));
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_plugin.c b/test/test_plugin.c
index 6eab638..4b5645c 100644
--- a/test/test_plugin.c
+++ b/test/test_plugin.c
@@ -79,218 +79,213 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
-
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
-
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(plug);
-
- const LilvPluginClass* klass = lilv_plugin_get_class(plug);
- const LilvNode* klass_uri = lilv_plugin_class_get_uri(klass);
- assert(!strcmp(lilv_node_as_string(klass_uri),
- "http://lv2plug.in/ns/lv2core#CompressorPlugin"));
-
- LilvNode* rdf_type =
- lilv_new_uri(world, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
- assert(
- lilv_world_ask(world, lilv_plugin_get_uri(plug), rdf_type, klass_uri));
- lilv_node_free(rdf_type);
-
- assert(!lilv_plugin_is_replaced(plug));
- assert(!lilv_plugin_get_related(plug, NULL));
-
- const LilvNode* plug_bundle_uri = lilv_plugin_get_bundle_uri(plug);
- assert(!strcmp(lilv_node_as_string(plug_bundle_uri), env->test_bundle_uri));
-
- const LilvNodes* data_uris = lilv_plugin_get_data_uris(plug);
- assert(lilv_nodes_size(data_uris) == 2);
-
- LilvNode* project = lilv_plugin_get_project(plug);
- assert(!project);
-
- char* manifest_uri = lilv_strjoin(lilv_node_as_string(plug_bundle_uri),
- "manifest.ttl",
- NULL);
-
- char* data_uri =
- lilv_strjoin(lilv_node_as_string(plug_bundle_uri), "plugin.ttl", NULL);
-
- LilvNode* manifest_uri_val = lilv_new_uri(world, manifest_uri);
- assert(lilv_nodes_contains(data_uris, manifest_uri_val));
- lilv_node_free(manifest_uri_val);
-
- LilvNode* data_uri_val = lilv_new_uri(world, data_uri);
- assert(lilv_nodes_contains(data_uris, data_uri_val));
- lilv_node_free(data_uri_val);
-
- LilvNode* unknown_uri_val =
- lilv_new_uri(world, "http://example.org/unknown");
- assert(!lilv_nodes_contains(data_uris, unknown_uri_val));
- lilv_node_free(unknown_uri_val);
-
- free(manifest_uri);
- free(data_uri);
-
- float mins[3];
- float maxs[3];
- float defs[3];
- lilv_plugin_get_port_ranges_float(plug, mins, maxs, defs);
- assert(mins[0] == -1.0f);
- assert(maxs[0] == 1.0f);
- assert(defs[0] == 0.5f);
-
- LilvNode* audio_class =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#AudioPort");
- LilvNode* control_class =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#ControlPort");
- LilvNode* in_class =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#InputPort");
- LilvNode* out_class =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#OutputPort");
-
- assert(lilv_plugin_get_num_ports_of_class(plug, control_class, NULL) == 3);
- assert(lilv_plugin_get_num_ports_of_class(plug, audio_class, NULL) == 0);
- assert(lilv_plugin_get_num_ports_of_class(plug, in_class, NULL) == 2);
- assert(lilv_plugin_get_num_ports_of_class(plug, out_class, NULL) == 1);
- assert(lilv_plugin_get_num_ports_of_class(
- plug, control_class, in_class, NULL) == 2);
- assert(lilv_plugin_get_num_ports_of_class(
- plug, control_class, out_class, NULL) == 1);
- assert(
- lilv_plugin_get_num_ports_of_class(plug, audio_class, in_class, NULL) ==
- 0);
- assert(lilv_plugin_get_num_ports_of_class(
- plug, audio_class, out_class, NULL) == 0);
-
- assert(lilv_plugin_has_latency(plug));
- assert(lilv_plugin_get_latency_port_index(plug) == 2);
-
- LilvNode* lv2_latency =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#latency");
- const LilvPort* latency_port =
- lilv_plugin_get_port_by_designation(plug, out_class, lv2_latency);
- lilv_node_free(lv2_latency);
-
- assert(latency_port);
- assert(lilv_port_get_index(plug, latency_port) == 2);
- assert(lilv_node_is_blank(lilv_port_get_node(plug, latency_port)));
-
- LilvNode* rt_feature =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#hardRTCapable");
- LilvNode* event_feature =
- lilv_new_uri(world, "http://lv2plug.in/ns/ext/event");
- LilvNode* pretend_feature =
- lilv_new_uri(world, "http://example.org/solvesWorldHunger");
-
- assert(lilv_plugin_has_feature(plug, rt_feature));
- assert(lilv_plugin_has_feature(plug, event_feature));
- assert(!lilv_plugin_has_feature(plug, pretend_feature));
-
- lilv_node_free(rt_feature);
- lilv_node_free(event_feature);
- lilv_node_free(pretend_feature);
-
- LilvNodes* supported = lilv_plugin_get_supported_features(plug);
- LilvNodes* required = lilv_plugin_get_required_features(plug);
- LilvNodes* optional = lilv_plugin_get_optional_features(plug);
- assert(lilv_nodes_size(supported) == 2);
- assert(lilv_nodes_size(required) == 1);
- assert(lilv_nodes_size(optional) == 1);
- lilv_nodes_free(supported);
- lilv_nodes_free(required);
- lilv_nodes_free(optional);
-
- LilvNode* foo_p = lilv_new_uri(world, "http://example.org/foo");
- LilvNodes* foos = lilv_plugin_get_value(plug, foo_p);
- assert(lilv_nodes_size(foos) == 1);
- assert(fabs(lilv_node_as_float(lilv_nodes_get_first(foos)) - 1.6180) <
- FLT_EPSILON);
- lilv_node_free(foo_p);
- lilv_nodes_free(foos);
-
- LilvNode* bar_p = lilv_new_uri(world, "http://example.org/bar");
- LilvNodes* bars = lilv_plugin_get_value(plug, bar_p);
- assert(lilv_nodes_size(bars) == 1);
- assert(lilv_node_as_bool(lilv_nodes_get_first(bars)) == true);
- lilv_node_free(bar_p);
- lilv_nodes_free(bars);
-
- LilvNode* baz_p = lilv_new_uri(world, "http://example.org/baz");
- LilvNodes* bazs = lilv_plugin_get_value(plug, baz_p);
- assert(lilv_nodes_size(bazs) == 1);
- assert(lilv_node_as_bool(lilv_nodes_get_first(bazs)) == false);
- lilv_node_free(baz_p);
- lilv_nodes_free(bazs);
-
- LilvNode* blank_p = lilv_new_uri(world, "http://example.org/blank");
- LilvNodes* blanks = lilv_plugin_get_value(plug, blank_p);
- assert(lilv_nodes_size(blanks) == 1);
- LilvNode* blank = lilv_nodes_get_first(blanks);
- assert(lilv_node_is_blank(blank));
- const char* blank_str = lilv_node_as_blank(blank);
- char* blank_tok = lilv_node_get_turtle_token(blank);
- assert(!strncmp(blank_tok, "_:", 2));
- assert(!strcmp(blank_tok + 2, blank_str));
- lilv_free(blank_tok);
- lilv_node_free(blank_p);
- lilv_nodes_free(blanks);
-
- LilvNode* author_name = lilv_plugin_get_author_name(plug);
- assert(!strcmp(lilv_node_as_string(author_name), "David Robillard"));
- lilv_node_free(author_name);
-
- LilvNode* author_email = lilv_plugin_get_author_email(plug);
- assert(!strcmp(lilv_node_as_string(author_email), "mailto:d@drobilla.net"));
- lilv_node_free(author_email);
-
- LilvNode* author_homepage = lilv_plugin_get_author_homepage(plug);
- assert(
- !strcmp(lilv_node_as_string(author_homepage), "http://drobilla.net"));
- lilv_node_free(author_homepage);
-
- LilvNode* thing_uri = lilv_new_uri(world, "http://example.org/thing");
- LilvNode* name_p = lilv_new_uri(world, "http://usefulinc.com/ns/doap#name");
- LilvNodes* thing_names =
- lilv_world_find_nodes(world, thing_uri, name_p, NULL);
- assert(lilv_nodes_size(thing_names) == 1);
- LilvNode* thing_name = lilv_nodes_get_first(thing_names);
- assert(thing_name);
- assert(lilv_node_is_string(thing_name));
- assert(!strcmp(lilv_node_as_string(thing_name), "Something else"));
- LilvNode* thing_name2 = lilv_world_get(world, thing_uri, name_p, NULL);
- assert(lilv_node_equals(thing_name, thing_name2));
-
- LilvUIs* uis = lilv_plugin_get_uis(plug);
- assert(lilv_uis_size(uis) == 0);
- lilv_uis_free(uis);
-
- LilvNode* extdata = lilv_new_uri(world, "http://example.org/extdata");
- LilvNode* noextdata = lilv_new_uri(world, "http://example.org/noextdata");
- LilvNodes* extdatas = lilv_plugin_get_extension_data(plug);
- assert(lilv_plugin_has_extension_data(plug, extdata));
- assert(!lilv_plugin_has_extension_data(plug, noextdata));
- assert(lilv_nodes_size(extdatas) == 1);
- assert(lilv_node_equals(lilv_nodes_get_first(extdatas), extdata));
- lilv_node_free(noextdata);
- lilv_node_free(extdata);
- lilv_nodes_free(extdatas);
-
- lilv_nodes_free(thing_names);
- lilv_node_free(thing_uri);
- lilv_node_free(thing_name2);
- lilv_node_free(name_p);
- lilv_node_free(control_class);
- lilv_node_free(audio_class);
- lilv_node_free(in_class);
- lilv_node_free(out_class);
-
- delete_bundle(env);
- lilv_test_env_free(env);
-
- return 0;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
+
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
+
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ assert(plug);
+
+ const LilvPluginClass* klass = lilv_plugin_get_class(plug);
+ const LilvNode* klass_uri = lilv_plugin_class_get_uri(klass);
+ assert(!strcmp(lilv_node_as_string(klass_uri),
+ "http://lv2plug.in/ns/lv2core#CompressorPlugin"));
+
+ LilvNode* rdf_type =
+ lilv_new_uri(world, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
+ assert(lilv_world_ask(world, lilv_plugin_get_uri(plug), rdf_type, klass_uri));
+ lilv_node_free(rdf_type);
+
+ assert(!lilv_plugin_is_replaced(plug));
+ assert(!lilv_plugin_get_related(plug, NULL));
+
+ const LilvNode* plug_bundle_uri = lilv_plugin_get_bundle_uri(plug);
+ assert(!strcmp(lilv_node_as_string(plug_bundle_uri), env->test_bundle_uri));
+
+ const LilvNodes* data_uris = lilv_plugin_get_data_uris(plug);
+ assert(lilv_nodes_size(data_uris) == 2);
+
+ LilvNode* project = lilv_plugin_get_project(plug);
+ assert(!project);
+
+ char* manifest_uri =
+ lilv_strjoin(lilv_node_as_string(plug_bundle_uri), "manifest.ttl", NULL);
+
+ char* data_uri =
+ lilv_strjoin(lilv_node_as_string(plug_bundle_uri), "plugin.ttl", NULL);
+
+ LilvNode* manifest_uri_val = lilv_new_uri(world, manifest_uri);
+ assert(lilv_nodes_contains(data_uris, manifest_uri_val));
+ lilv_node_free(manifest_uri_val);
+
+ LilvNode* data_uri_val = lilv_new_uri(world, data_uri);
+ assert(lilv_nodes_contains(data_uris, data_uri_val));
+ lilv_node_free(data_uri_val);
+
+ LilvNode* unknown_uri_val = lilv_new_uri(world, "http://example.org/unknown");
+ assert(!lilv_nodes_contains(data_uris, unknown_uri_val));
+ lilv_node_free(unknown_uri_val);
+
+ free(manifest_uri);
+ free(data_uri);
+
+ float mins[3];
+ float maxs[3];
+ float defs[3];
+ lilv_plugin_get_port_ranges_float(plug, mins, maxs, defs);
+ assert(mins[0] == -1.0f);
+ assert(maxs[0] == 1.0f);
+ assert(defs[0] == 0.5f);
+
+ LilvNode* audio_class =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#AudioPort");
+ LilvNode* control_class =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#ControlPort");
+ LilvNode* in_class =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#InputPort");
+ LilvNode* out_class =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#OutputPort");
+
+ assert(lilv_plugin_get_num_ports_of_class(plug, control_class, NULL) == 3);
+ assert(lilv_plugin_get_num_ports_of_class(plug, audio_class, NULL) == 0);
+ assert(lilv_plugin_get_num_ports_of_class(plug, in_class, NULL) == 2);
+ assert(lilv_plugin_get_num_ports_of_class(plug, out_class, NULL) == 1);
+ assert(lilv_plugin_get_num_ports_of_class(
+ plug, control_class, in_class, NULL) == 2);
+ assert(lilv_plugin_get_num_ports_of_class(
+ plug, control_class, out_class, NULL) == 1);
+ assert(
+ lilv_plugin_get_num_ports_of_class(plug, audio_class, in_class, NULL) == 0);
+ assert(lilv_plugin_get_num_ports_of_class(
+ plug, audio_class, out_class, NULL) == 0);
+
+ assert(lilv_plugin_has_latency(plug));
+ assert(lilv_plugin_get_latency_port_index(plug) == 2);
+
+ LilvNode* lv2_latency =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#latency");
+ const LilvPort* latency_port =
+ lilv_plugin_get_port_by_designation(plug, out_class, lv2_latency);
+ lilv_node_free(lv2_latency);
+
+ assert(latency_port);
+ assert(lilv_port_get_index(plug, latency_port) == 2);
+ assert(lilv_node_is_blank(lilv_port_get_node(plug, latency_port)));
+
+ LilvNode* rt_feature =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#hardRTCapable");
+ LilvNode* event_feature =
+ lilv_new_uri(world, "http://lv2plug.in/ns/ext/event");
+ LilvNode* pretend_feature =
+ lilv_new_uri(world, "http://example.org/solvesWorldHunger");
+
+ assert(lilv_plugin_has_feature(plug, rt_feature));
+ assert(lilv_plugin_has_feature(plug, event_feature));
+ assert(!lilv_plugin_has_feature(plug, pretend_feature));
+
+ lilv_node_free(rt_feature);
+ lilv_node_free(event_feature);
+ lilv_node_free(pretend_feature);
+
+ LilvNodes* supported = lilv_plugin_get_supported_features(plug);
+ LilvNodes* required = lilv_plugin_get_required_features(plug);
+ LilvNodes* optional = lilv_plugin_get_optional_features(plug);
+ assert(lilv_nodes_size(supported) == 2);
+ assert(lilv_nodes_size(required) == 1);
+ assert(lilv_nodes_size(optional) == 1);
+ lilv_nodes_free(supported);
+ lilv_nodes_free(required);
+ lilv_nodes_free(optional);
+
+ LilvNode* foo_p = lilv_new_uri(world, "http://example.org/foo");
+ LilvNodes* foos = lilv_plugin_get_value(plug, foo_p);
+ assert(lilv_nodes_size(foos) == 1);
+ assert(fabs(lilv_node_as_float(lilv_nodes_get_first(foos)) - 1.6180) <
+ FLT_EPSILON);
+ lilv_node_free(foo_p);
+ lilv_nodes_free(foos);
+
+ LilvNode* bar_p = lilv_new_uri(world, "http://example.org/bar");
+ LilvNodes* bars = lilv_plugin_get_value(plug, bar_p);
+ assert(lilv_nodes_size(bars) == 1);
+ assert(lilv_node_as_bool(lilv_nodes_get_first(bars)) == true);
+ lilv_node_free(bar_p);
+ lilv_nodes_free(bars);
+
+ LilvNode* baz_p = lilv_new_uri(world, "http://example.org/baz");
+ LilvNodes* bazs = lilv_plugin_get_value(plug, baz_p);
+ assert(lilv_nodes_size(bazs) == 1);
+ assert(lilv_node_as_bool(lilv_nodes_get_first(bazs)) == false);
+ lilv_node_free(baz_p);
+ lilv_nodes_free(bazs);
+
+ LilvNode* blank_p = lilv_new_uri(world, "http://example.org/blank");
+ LilvNodes* blanks = lilv_plugin_get_value(plug, blank_p);
+ assert(lilv_nodes_size(blanks) == 1);
+ LilvNode* blank = lilv_nodes_get_first(blanks);
+ assert(lilv_node_is_blank(blank));
+ const char* blank_str = lilv_node_as_blank(blank);
+ char* blank_tok = lilv_node_get_turtle_token(blank);
+ assert(!strncmp(blank_tok, "_:", 2));
+ assert(!strcmp(blank_tok + 2, blank_str));
+ lilv_free(blank_tok);
+ lilv_node_free(blank_p);
+ lilv_nodes_free(blanks);
+
+ LilvNode* author_name = lilv_plugin_get_author_name(plug);
+ assert(!strcmp(lilv_node_as_string(author_name), "David Robillard"));
+ lilv_node_free(author_name);
+
+ LilvNode* author_email = lilv_plugin_get_author_email(plug);
+ assert(!strcmp(lilv_node_as_string(author_email), "mailto:d@drobilla.net"));
+ lilv_node_free(author_email);
+
+ LilvNode* author_homepage = lilv_plugin_get_author_homepage(plug);
+ assert(!strcmp(lilv_node_as_string(author_homepage), "http://drobilla.net"));
+ lilv_node_free(author_homepage);
+
+ LilvNode* thing_uri = lilv_new_uri(world, "http://example.org/thing");
+ LilvNode* name_p = lilv_new_uri(world, "http://usefulinc.com/ns/doap#name");
+ LilvNodes* thing_names =
+ lilv_world_find_nodes(world, thing_uri, name_p, NULL);
+ assert(lilv_nodes_size(thing_names) == 1);
+ LilvNode* thing_name = lilv_nodes_get_first(thing_names);
+ assert(thing_name);
+ assert(lilv_node_is_string(thing_name));
+ assert(!strcmp(lilv_node_as_string(thing_name), "Something else"));
+ LilvNode* thing_name2 = lilv_world_get(world, thing_uri, name_p, NULL);
+ assert(lilv_node_equals(thing_name, thing_name2));
+
+ LilvUIs* uis = lilv_plugin_get_uis(plug);
+ assert(lilv_uis_size(uis) == 0);
+ lilv_uis_free(uis);
+
+ LilvNode* extdata = lilv_new_uri(world, "http://example.org/extdata");
+ LilvNode* noextdata = lilv_new_uri(world, "http://example.org/noextdata");
+ LilvNodes* extdatas = lilv_plugin_get_extension_data(plug);
+ assert(lilv_plugin_has_extension_data(plug, extdata));
+ assert(!lilv_plugin_has_extension_data(plug, noextdata));
+ assert(lilv_nodes_size(extdatas) == 1);
+ assert(lilv_node_equals(lilv_nodes_get_first(extdatas), extdata));
+ lilv_node_free(noextdata);
+ lilv_node_free(extdata);
+ lilv_nodes_free(extdatas);
+
+ lilv_nodes_free(thing_names);
+ lilv_node_free(thing_uri);
+ lilv_node_free(thing_name2);
+ lilv_node_free(name_p);
+ lilv_node_free(control_class);
+ lilv_node_free(audio_class);
+ lilv_node_free(in_class);
+ lilv_node_free(out_class);
+
+ delete_bundle(env);
+ lilv_test_env_free(env);
+
+ return 0;
}
diff --git a/test/test_port.c b/test/test_port.c
index 0aba6ea..48812b2 100644
--- a/test/test_port.c
+++ b/test/test_port.c
@@ -77,257 +77,252 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
-
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
-
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(plug);
-
- LilvNode* psym = lilv_new_string(world, "foo");
- const LilvPort* p = lilv_plugin_get_port_by_index(plug, 0);
- const LilvPort* p2 = lilv_plugin_get_port_by_symbol(plug, psym);
- lilv_node_free(psym);
- assert(p != NULL);
- assert(p2 != NULL);
- assert(p == p2);
-
- LilvNode* nopsym = lilv_new_string(world, "thisaintnoportfoo");
- const LilvPort* p3 = lilv_plugin_get_port_by_symbol(plug, nopsym);
- assert(p3 == NULL);
- lilv_node_free(nopsym);
-
- // Try getting an invalid property
- LilvNode* num = lilv_new_int(world, 1);
- LilvNodes* nothing = lilv_port_get_value(plug, p, num);
- assert(!nothing);
- lilv_node_free(num);
-
- LilvNode* audio_class =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#AudioPort");
- LilvNode* control_class =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#ControlPort");
- LilvNode* in_class =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#InputPort");
- LilvNode* out_class =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#OutputPort");
-
- assert(lilv_nodes_size(lilv_port_get_classes(plug, p)) == 2);
- assert(lilv_plugin_get_num_ports(plug) == 4);
- assert(lilv_port_is_a(plug, p, control_class));
- assert(lilv_port_is_a(plug, p, in_class));
- assert(!lilv_port_is_a(plug, p, audio_class));
-
- LilvNodes* port_properties = lilv_port_get_properties(plug, p);
- assert(lilv_nodes_size(port_properties) == 1);
- lilv_nodes_free(port_properties);
-
- // Untranslated name (current locale is set to "C" in main)
- assert(!strcmp(lilv_node_as_string(lilv_port_get_symbol(plug, p)), "foo"));
- LilvNode* name = lilv_port_get_name(plug, p);
- assert(!strcmp(lilv_node_as_string(name), "store"));
- lilv_node_free(name);
-
- // Exact language match
- set_env("LANG", "de_DE");
- name = lilv_port_get_name(plug, p);
- assert(!strcmp(lilv_node_as_string(name), "Laden"));
- lilv_node_free(name);
-
- // Exact language match (with charset suffix)
- set_env("LANG", "de_AT.utf8");
- name = lilv_port_get_name(plug, p);
- assert(!strcmp(lilv_node_as_string(name), "Geschaeft"));
- lilv_node_free(name);
-
- // Partial language match (choose value translated for different country)
- set_env("LANG", "de_CH");
- name = lilv_port_get_name(plug, p);
- assert((!strcmp(lilv_node_as_string(name), "Laden")) ||
- (!strcmp(lilv_node_as_string(name), "Geschaeft")));
- lilv_node_free(name);
-
- // Partial language match (choose country-less language tagged value)
- set_env("LANG", "es_MX");
- name = lilv_port_get_name(plug, p);
- assert(!strcmp(lilv_node_as_string(name), "tienda"));
- lilv_node_free(name);
-
- // No language match (choose untranslated value)
- set_env("LANG", "cn");
- name = lilv_port_get_name(plug, p);
- assert(!strcmp(lilv_node_as_string(name), "store"));
- lilv_node_free(name);
-
- // Invalid language
- set_env("LANG", "1!");
- name = lilv_port_get_name(plug, p);
- assert(!strcmp(lilv_node_as_string(name), "store"));
- lilv_node_free(name);
-
- set_env("LANG", "en_CA.utf-8");
-
- // Language tagged value with no untranslated values
- LilvNode* rdfs_comment = lilv_new_uri(world, LILV_NS_RDFS "comment");
- LilvNodes* comments = lilv_port_get_value(plug, p, rdfs_comment);
- assert(!strcmp(lilv_node_as_string(lilv_nodes_get_first(comments)),
- "comment"));
- LilvNode* comment = lilv_port_get(plug, p, rdfs_comment);
- assert(!strcmp(lilv_node_as_string(comment), "comment"));
- lilv_node_free(comment);
- lilv_nodes_free(comments);
-
- set_env("LANG", "fr");
-
- comments = lilv_port_get_value(plug, p, rdfs_comment);
- assert(!strcmp(lilv_node_as_string(lilv_nodes_get_first(comments)),
- "commentaires"));
- lilv_nodes_free(comments);
-
- set_env("LANG", "cn");
-
- comments = lilv_port_get_value(plug, p, rdfs_comment);
- assert(!comments);
- lilv_nodes_free(comments);
-
- lilv_node_free(rdfs_comment);
-
- set_env("LANG", "C"); // Reset locale
-
- LilvScalePoints* points = lilv_port_get_scale_points(plug, p);
- assert(lilv_scale_points_size(points) == 2);
-
- LilvIter* sp_iter = lilv_scale_points_begin(points);
- const LilvScalePoint* sp0 = lilv_scale_points_get(points, sp_iter);
- assert(sp0);
- sp_iter = lilv_scale_points_next(points, sp_iter);
- const LilvScalePoint* sp1 = lilv_scale_points_get(points, sp_iter);
- assert(sp1);
-
- assert(((!strcmp(lilv_node_as_string(lilv_scale_point_get_label(sp0)),
- "Sin") &&
- lilv_node_as_float(lilv_scale_point_get_value(sp0)) == 3) &&
- (!strcmp(lilv_node_as_string(lilv_scale_point_get_label(sp1)),
- "Cos") &&
- lilv_node_as_float(lilv_scale_point_get_value(sp1)) == 4)) ||
- ((!strcmp(lilv_node_as_string(lilv_scale_point_get_label(sp0)),
- "Cos") &&
- lilv_node_as_float(lilv_scale_point_get_value(sp0)) == 4) &&
- (!strcmp(lilv_node_as_string(lilv_scale_point_get_label(sp1)),
- "Sin") &&
- lilv_node_as_float(lilv_scale_point_get_value(sp1)) == 3)));
-
- LilvNode* homepage_p =
- lilv_new_uri(world, "http://usefulinc.com/ns/doap#homepage");
- LilvNodes* homepages = lilv_plugin_get_value(plug, homepage_p);
- assert(lilv_nodes_size(homepages) == 1);
- assert(!strcmp(lilv_node_as_string(lilv_nodes_get_first(homepages)),
- "http://example.org/someplug"));
-
- LilvNode* min = NULL;
- LilvNode* max = NULL;
- LilvNode* def = NULL;
- lilv_port_get_range(plug, p, &def, &min, &max);
- assert(def);
- assert(min);
- assert(max);
- assert(lilv_node_as_float(def) == 0.5);
- assert(lilv_node_as_float(min) == -1.0);
- assert(lilv_node_as_float(max) == 1.0);
-
- LilvNode* integer_prop =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#integer");
- LilvNode* toggled_prop =
- lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#toggled");
-
- assert(lilv_port_has_property(plug, p, integer_prop));
- assert(!lilv_port_has_property(plug, p, toggled_prop));
-
- const LilvPort* ep = lilv_plugin_get_port_by_index(plug, 1);
-
- LilvNode* event_type = lilv_new_uri(world, "http://example.org/event");
- LilvNode* event_type_2 =
- lilv_new_uri(world, "http://example.org/otherEvent");
- LilvNode* atom_event = lilv_new_uri(world, "http://example.org/atomEvent");
- assert(lilv_port_supports_event(plug, ep, event_type));
- assert(!lilv_port_supports_event(plug, ep, event_type_2));
- assert(lilv_port_supports_event(plug, ep, atom_event));
-
- LilvNode* name_p = lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#name");
- LilvNodes* names = lilv_port_get_value(plug, p, name_p);
- assert(lilv_nodes_size(names) == 1);
- assert(!strcmp(lilv_node_as_string(lilv_nodes_get_first(names)), "store"));
- lilv_nodes_free(names);
-
- LilvNode* true_val = lilv_new_bool(world, true);
- LilvNode* false_val = lilv_new_bool(world, false);
-
- assert(!lilv_node_equals(true_val, false_val));
-
- lilv_world_set_option(world, LILV_OPTION_FILTER_LANG, false_val);
- names = lilv_port_get_value(plug, p, name_p);
- assert(lilv_nodes_size(names) == 4);
- lilv_nodes_free(names);
- lilv_world_set_option(world, LILV_OPTION_FILTER_LANG, true_val);
-
- lilv_node_free(false_val);
- lilv_node_free(true_val);
-
- names = lilv_port_get_value(plug, ep, name_p);
- assert(lilv_nodes_size(names) == 1);
- assert(!strcmp(lilv_node_as_string(lilv_nodes_get_first(names)),
- "Event Input"));
-
- const LilvPort* ap_in = lilv_plugin_get_port_by_index(plug, 2);
-
- assert(lilv_port_is_a(plug, ap_in, in_class));
- assert(!lilv_port_is_a(plug, ap_in, out_class));
- assert(lilv_port_is_a(plug, ap_in, audio_class));
- assert(!lilv_port_is_a(plug, ap_in, control_class));
-
- const LilvPort* ap_out = lilv_plugin_get_port_by_index(plug, 3);
-
- assert(lilv_port_is_a(plug, ap_out, out_class));
- assert(!lilv_port_is_a(plug, ap_out, in_class));
- assert(lilv_port_is_a(plug, ap_out, audio_class));
- assert(!lilv_port_is_a(plug, ap_out, control_class));
-
- assert(lilv_plugin_get_num_ports_of_class(
- plug, control_class, in_class, NULL) == 1);
- assert(
- lilv_plugin_get_num_ports_of_class(plug, audio_class, in_class, NULL) ==
- 1);
- assert(lilv_plugin_get_num_ports_of_class(
- plug, audio_class, out_class, NULL) == 1);
-
- lilv_nodes_free(names);
- lilv_node_free(name_p);
-
- lilv_node_free(integer_prop);
- lilv_node_free(toggled_prop);
- lilv_node_free(event_type);
- lilv_node_free(event_type_2);
- lilv_node_free(atom_event);
-
- lilv_node_free(min);
- lilv_node_free(max);
- lilv_node_free(def);
-
- lilv_node_free(homepage_p);
- lilv_nodes_free(homepages);
-
- lilv_scale_points_free(points);
- lilv_node_free(control_class);
- lilv_node_free(audio_class);
- lilv_node_free(out_class);
- lilv_node_free(in_class);
-
- delete_bundle(env);
- lilv_test_env_free(env);
-
- return 0;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
+
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
+
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ assert(plug);
+
+ LilvNode* psym = lilv_new_string(world, "foo");
+ const LilvPort* p = lilv_plugin_get_port_by_index(plug, 0);
+ const LilvPort* p2 = lilv_plugin_get_port_by_symbol(plug, psym);
+ lilv_node_free(psym);
+ assert(p != NULL);
+ assert(p2 != NULL);
+ assert(p == p2);
+
+ LilvNode* nopsym = lilv_new_string(world, "thisaintnoportfoo");
+ const LilvPort* p3 = lilv_plugin_get_port_by_symbol(plug, nopsym);
+ assert(p3 == NULL);
+ lilv_node_free(nopsym);
+
+ // Try getting an invalid property
+ LilvNode* num = lilv_new_int(world, 1);
+ LilvNodes* nothing = lilv_port_get_value(plug, p, num);
+ assert(!nothing);
+ lilv_node_free(num);
+
+ LilvNode* audio_class =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#AudioPort");
+ LilvNode* control_class =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#ControlPort");
+ LilvNode* in_class =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#InputPort");
+ LilvNode* out_class =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#OutputPort");
+
+ assert(lilv_nodes_size(lilv_port_get_classes(plug, p)) == 2);
+ assert(lilv_plugin_get_num_ports(plug) == 4);
+ assert(lilv_port_is_a(plug, p, control_class));
+ assert(lilv_port_is_a(plug, p, in_class));
+ assert(!lilv_port_is_a(plug, p, audio_class));
+
+ LilvNodes* port_properties = lilv_port_get_properties(plug, p);
+ assert(lilv_nodes_size(port_properties) == 1);
+ lilv_nodes_free(port_properties);
+
+ // Untranslated name (current locale is set to "C" in main)
+ assert(!strcmp(lilv_node_as_string(lilv_port_get_symbol(plug, p)), "foo"));
+ LilvNode* name = lilv_port_get_name(plug, p);
+ assert(!strcmp(lilv_node_as_string(name), "store"));
+ lilv_node_free(name);
+
+ // Exact language match
+ set_env("LANG", "de_DE");
+ name = lilv_port_get_name(plug, p);
+ assert(!strcmp(lilv_node_as_string(name), "Laden"));
+ lilv_node_free(name);
+
+ // Exact language match (with charset suffix)
+ set_env("LANG", "de_AT.utf8");
+ name = lilv_port_get_name(plug, p);
+ assert(!strcmp(lilv_node_as_string(name), "Geschaeft"));
+ lilv_node_free(name);
+
+ // Partial language match (choose value translated for different country)
+ set_env("LANG", "de_CH");
+ name = lilv_port_get_name(plug, p);
+ assert((!strcmp(lilv_node_as_string(name), "Laden")) ||
+ (!strcmp(lilv_node_as_string(name), "Geschaeft")));
+ lilv_node_free(name);
+
+ // Partial language match (choose country-less language tagged value)
+ set_env("LANG", "es_MX");
+ name = lilv_port_get_name(plug, p);
+ assert(!strcmp(lilv_node_as_string(name), "tienda"));
+ lilv_node_free(name);
+
+ // No language match (choose untranslated value)
+ set_env("LANG", "cn");
+ name = lilv_port_get_name(plug, p);
+ assert(!strcmp(lilv_node_as_string(name), "store"));
+ lilv_node_free(name);
+
+ // Invalid language
+ set_env("LANG", "1!");
+ name = lilv_port_get_name(plug, p);
+ assert(!strcmp(lilv_node_as_string(name), "store"));
+ lilv_node_free(name);
+
+ set_env("LANG", "en_CA.utf-8");
+
+ // Language tagged value with no untranslated values
+ LilvNode* rdfs_comment = lilv_new_uri(world, LILV_NS_RDFS "comment");
+ LilvNodes* comments = lilv_port_get_value(plug, p, rdfs_comment);
+ assert(
+ !strcmp(lilv_node_as_string(lilv_nodes_get_first(comments)), "comment"));
+ LilvNode* comment = lilv_port_get(plug, p, rdfs_comment);
+ assert(!strcmp(lilv_node_as_string(comment), "comment"));
+ lilv_node_free(comment);
+ lilv_nodes_free(comments);
+
+ set_env("LANG", "fr");
+
+ comments = lilv_port_get_value(plug, p, rdfs_comment);
+ assert(!strcmp(lilv_node_as_string(lilv_nodes_get_first(comments)),
+ "commentaires"));
+ lilv_nodes_free(comments);
+
+ set_env("LANG", "cn");
+
+ comments = lilv_port_get_value(plug, p, rdfs_comment);
+ assert(!comments);
+ lilv_nodes_free(comments);
+
+ lilv_node_free(rdfs_comment);
+
+ set_env("LANG", "C"); // Reset locale
+
+ LilvScalePoints* points = lilv_port_get_scale_points(plug, p);
+ assert(lilv_scale_points_size(points) == 2);
+
+ LilvIter* sp_iter = lilv_scale_points_begin(points);
+ const LilvScalePoint* sp0 = lilv_scale_points_get(points, sp_iter);
+ assert(sp0);
+ sp_iter = lilv_scale_points_next(points, sp_iter);
+ const LilvScalePoint* sp1 = lilv_scale_points_get(points, sp_iter);
+ assert(sp1);
+
+ assert(
+ ((!strcmp(lilv_node_as_string(lilv_scale_point_get_label(sp0)), "Sin") &&
+ lilv_node_as_float(lilv_scale_point_get_value(sp0)) == 3) &&
+ (!strcmp(lilv_node_as_string(lilv_scale_point_get_label(sp1)), "Cos") &&
+ lilv_node_as_float(lilv_scale_point_get_value(sp1)) == 4)) ||
+ ((!strcmp(lilv_node_as_string(lilv_scale_point_get_label(sp0)), "Cos") &&
+ lilv_node_as_float(lilv_scale_point_get_value(sp0)) == 4) &&
+ (!strcmp(lilv_node_as_string(lilv_scale_point_get_label(sp1)), "Sin") &&
+ lilv_node_as_float(lilv_scale_point_get_value(sp1)) == 3)));
+
+ LilvNode* homepage_p =
+ lilv_new_uri(world, "http://usefulinc.com/ns/doap#homepage");
+ LilvNodes* homepages = lilv_plugin_get_value(plug, homepage_p);
+ assert(lilv_nodes_size(homepages) == 1);
+ assert(!strcmp(lilv_node_as_string(lilv_nodes_get_first(homepages)),
+ "http://example.org/someplug"));
+
+ LilvNode* min = NULL;
+ LilvNode* max = NULL;
+ LilvNode* def = NULL;
+ lilv_port_get_range(plug, p, &def, &min, &max);
+ assert(def);
+ assert(min);
+ assert(max);
+ assert(lilv_node_as_float(def) == 0.5);
+ assert(lilv_node_as_float(min) == -1.0);
+ assert(lilv_node_as_float(max) == 1.0);
+
+ LilvNode* integer_prop =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#integer");
+ LilvNode* toggled_prop =
+ lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#toggled");
+
+ assert(lilv_port_has_property(plug, p, integer_prop));
+ assert(!lilv_port_has_property(plug, p, toggled_prop));
+
+ const LilvPort* ep = lilv_plugin_get_port_by_index(plug, 1);
+
+ LilvNode* event_type = lilv_new_uri(world, "http://example.org/event");
+ LilvNode* event_type_2 = lilv_new_uri(world, "http://example.org/otherEvent");
+ LilvNode* atom_event = lilv_new_uri(world, "http://example.org/atomEvent");
+ assert(lilv_port_supports_event(plug, ep, event_type));
+ assert(!lilv_port_supports_event(plug, ep, event_type_2));
+ assert(lilv_port_supports_event(plug, ep, atom_event));
+
+ LilvNode* name_p = lilv_new_uri(world, "http://lv2plug.in/ns/lv2core#name");
+ LilvNodes* names = lilv_port_get_value(plug, p, name_p);
+ assert(lilv_nodes_size(names) == 1);
+ assert(!strcmp(lilv_node_as_string(lilv_nodes_get_first(names)), "store"));
+ lilv_nodes_free(names);
+
+ LilvNode* true_val = lilv_new_bool(world, true);
+ LilvNode* false_val = lilv_new_bool(world, false);
+
+ assert(!lilv_node_equals(true_val, false_val));
+
+ lilv_world_set_option(world, LILV_OPTION_FILTER_LANG, false_val);
+ names = lilv_port_get_value(plug, p, name_p);
+ assert(lilv_nodes_size(names) == 4);
+ lilv_nodes_free(names);
+ lilv_world_set_option(world, LILV_OPTION_FILTER_LANG, true_val);
+
+ lilv_node_free(false_val);
+ lilv_node_free(true_val);
+
+ names = lilv_port_get_value(plug, ep, name_p);
+ assert(lilv_nodes_size(names) == 1);
+ assert(
+ !strcmp(lilv_node_as_string(lilv_nodes_get_first(names)), "Event Input"));
+
+ const LilvPort* ap_in = lilv_plugin_get_port_by_index(plug, 2);
+
+ assert(lilv_port_is_a(plug, ap_in, in_class));
+ assert(!lilv_port_is_a(plug, ap_in, out_class));
+ assert(lilv_port_is_a(plug, ap_in, audio_class));
+ assert(!lilv_port_is_a(plug, ap_in, control_class));
+
+ const LilvPort* ap_out = lilv_plugin_get_port_by_index(plug, 3);
+
+ assert(lilv_port_is_a(plug, ap_out, out_class));
+ assert(!lilv_port_is_a(plug, ap_out, in_class));
+ assert(lilv_port_is_a(plug, ap_out, audio_class));
+ assert(!lilv_port_is_a(plug, ap_out, control_class));
+
+ assert(lilv_plugin_get_num_ports_of_class(
+ plug, control_class, in_class, NULL) == 1);
+ assert(
+ lilv_plugin_get_num_ports_of_class(plug, audio_class, in_class, NULL) == 1);
+ assert(lilv_plugin_get_num_ports_of_class(
+ plug, audio_class, out_class, NULL) == 1);
+
+ lilv_nodes_free(names);
+ lilv_node_free(name_p);
+
+ lilv_node_free(integer_prop);
+ lilv_node_free(toggled_prop);
+ lilv_node_free(event_type);
+ lilv_node_free(event_type_2);
+ lilv_node_free(atom_event);
+
+ lilv_node_free(min);
+ lilv_node_free(max);
+ lilv_node_free(def);
+
+ lilv_node_free(homepage_p);
+ lilv_nodes_free(homepages);
+
+ lilv_scale_points_free(points);
+ lilv_node_free(control_class);
+ lilv_node_free(audio_class);
+ lilv_node_free(out_class);
+ lilv_node_free(in_class);
+
+ delete_bundle(env);
+ lilv_test_env_free(env);
+
+ return 0;
}
diff --git a/test/test_preset.c b/test/test_preset.c
index d26d844..604d693 100644
--- a/test/test_preset.c
+++ b/test/test_preset.c
@@ -67,27 +67,27 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(plug);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ assert(plug);
- LilvNode* pset_Preset = lilv_new_uri(world, LV2_PRESETS__Preset);
- LilvNodes* related = lilv_plugin_get_related(plug, pset_Preset);
+ LilvNode* pset_Preset = lilv_new_uri(world, LV2_PRESETS__Preset);
+ LilvNodes* related = lilv_plugin_get_related(plug, pset_Preset);
- assert(lilv_nodes_size(related) == 1);
+ assert(lilv_nodes_size(related) == 1);
- lilv_node_free(pset_Preset);
- lilv_nodes_free(related);
+ lilv_node_free(pset_Preset);
+ lilv_nodes_free(related);
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_project.c b/test/test_project.c
index bc2e2c3..7080959 100644
--- a/test/test_project.c
+++ b/test/test_project.c
@@ -66,32 +66,31 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(plug);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ assert(plug);
- LilvNode* author_name = lilv_plugin_get_author_name(plug);
- assert(!strcmp(lilv_node_as_string(author_name), "David Robillard"));
- lilv_node_free(author_name);
+ LilvNode* author_name = lilv_plugin_get_author_name(plug);
+ assert(!strcmp(lilv_node_as_string(author_name), "David Robillard"));
+ lilv_node_free(author_name);
- LilvNode* author_email = lilv_plugin_get_author_email(plug);
- assert(!strcmp(lilv_node_as_string(author_email), "mailto:d@drobilla.net"));
- lilv_node_free(author_email);
+ LilvNode* author_email = lilv_plugin_get_author_email(plug);
+ assert(!strcmp(lilv_node_as_string(author_email), "mailto:d@drobilla.net"));
+ lilv_node_free(author_email);
- LilvNode* author_homepage = lilv_plugin_get_author_homepage(plug);
- assert(
- !strcmp(lilv_node_as_string(author_homepage), "http://drobilla.net"));
- lilv_node_free(author_homepage);
+ LilvNode* author_homepage = lilv_plugin_get_author_homepage(plug);
+ assert(!strcmp(lilv_node_as_string(author_homepage), "http://drobilla.net"));
+ lilv_node_free(author_homepage);
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_project_no_author.c b/test/test_project_no_author.c
index 017d359..a2bdcc9 100644
--- a/test/test_project_no_author.c
+++ b/test/test_project_no_author.c
@@ -60,28 +60,28 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(plug);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ assert(plug);
- LilvNode* author_name = lilv_plugin_get_author_name(plug);
- assert(!author_name);
+ LilvNode* author_name = lilv_plugin_get_author_name(plug);
+ assert(!author_name);
- LilvNode* author_email = lilv_plugin_get_author_email(plug);
- assert(!author_email);
+ LilvNode* author_email = lilv_plugin_get_author_email(plug);
+ assert(!author_email);
- LilvNode* author_homepage = lilv_plugin_get_author_homepage(plug);
- assert(!author_homepage);
+ LilvNode* author_homepage = lilv_plugin_get_author_homepage(plug);
+ assert(!author_homepage);
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_prototype.c b/test/test_prototype.c
index 4ad516e..77282eb 100644
--- a/test/test_prototype.c
+++ b/test/test_prototype.c
@@ -73,28 +73,28 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, manifest_ttl, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, manifest_ttl, plugin_ttl)) {
+ return 1;
+ }
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(plug);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ assert(plug);
- // Test non-inherited property
- LilvNode* name = lilv_plugin_get_name(plug);
- assert(!strcmp(lilv_node_as_string(name), "Instance"));
- lilv_node_free(name);
+ // Test non-inherited property
+ LilvNode* name = lilv_plugin_get_name(plug);
+ assert(!strcmp(lilv_node_as_string(name), "Instance"));
+ lilv_node_free(name);
- // Test inherited property
- const LilvNode* binary = lilv_plugin_get_library_uri(plug);
- assert(strstr(lilv_node_as_string(binary), "inst" SHLIB_EXT));
+ // Test inherited property
+ const LilvNode* binary = lilv_plugin_get_library_uri(plug);
+ assert(strstr(lilv_node_as_string(binary), "inst" SHLIB_EXT));
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_reload_bundle.c b/test/test_reload_bundle.c
index 19644ff..888f601 100644
--- a/test/test_reload_bundle.c
+++ b/test/test_reload_bundle.c
@@ -26,67 +26,66 @@
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
-
- // Create a simple plugin bundle
- create_bundle(env,
- ":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT
- "> ; rdfs:seeAlso <plugin.ttl> .\n",
- ":plug a lv2:Plugin ; "
- "doap:name \"First name\" .");
-
- lilv_world_load_specifications(world);
-
- // Load bundle
- LilvNode* bundle_uri = lilv_new_uri(world, env->test_bundle_uri);
- lilv_world_load_bundle(world, bundle_uri);
-
- // Check that plugin is present
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(plug);
-
- // Check that plugin name is correct
- LilvNode* name = lilv_plugin_get_name(plug);
- assert(!strcmp(lilv_node_as_string(name), "First name"));
- lilv_node_free(name);
-
- // Unload bundle from world and delete it
- lilv_world_unload_bundle(world, bundle_uri);
- delete_bundle(env);
-
- // Create a new version of the same bundle, but with a different name
- create_bundle(env,
- ":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT
- "> ; rdfs:seeAlso <plugin.ttl> .\n",
- ":plug a lv2:Plugin ; "
- "doap:name \"Second name\" .");
-
- // Check that plugin is no longer in the world's plugin list
- assert(lilv_plugins_size(plugins) == 0);
-
- // Load new bundle
- lilv_world_load_bundle(world, bundle_uri);
-
- // Check that plugin is present again and is the same LilvPlugin
- const LilvPlugin* plug2 =
- lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(plug2);
- assert(plug2 == plug);
-
- // Check that plugin now has new name
- LilvNode* name2 = lilv_plugin_get_name(plug2);
- assert(name2);
- assert(!strcmp(lilv_node_as_string(name2), "Second name"));
- lilv_node_free(name2);
-
- // Load new bundle again (noop)
- lilv_world_load_bundle(world, bundle_uri);
-
- lilv_node_free(bundle_uri);
- delete_bundle(env);
- lilv_test_env_free(env);
-
- return 0;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
+
+ // Create a simple plugin bundle
+ create_bundle(env,
+ ":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT
+ "> ; rdfs:seeAlso <plugin.ttl> .\n",
+ ":plug a lv2:Plugin ; "
+ "doap:name \"First name\" .");
+
+ lilv_world_load_specifications(world);
+
+ // Load bundle
+ LilvNode* bundle_uri = lilv_new_uri(world, env->test_bundle_uri);
+ lilv_world_load_bundle(world, bundle_uri);
+
+ // Check that plugin is present
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ assert(plug);
+
+ // Check that plugin name is correct
+ LilvNode* name = lilv_plugin_get_name(plug);
+ assert(!strcmp(lilv_node_as_string(name), "First name"));
+ lilv_node_free(name);
+
+ // Unload bundle from world and delete it
+ lilv_world_unload_bundle(world, bundle_uri);
+ delete_bundle(env);
+
+ // Create a new version of the same bundle, but with a different name
+ create_bundle(env,
+ ":plug a lv2:Plugin ; lv2:binary <foo" SHLIB_EXT
+ "> ; rdfs:seeAlso <plugin.ttl> .\n",
+ ":plug a lv2:Plugin ; "
+ "doap:name \"Second name\" .");
+
+ // Check that plugin is no longer in the world's plugin list
+ assert(lilv_plugins_size(plugins) == 0);
+
+ // Load new bundle
+ lilv_world_load_bundle(world, bundle_uri);
+
+ // Check that plugin is present again and is the same LilvPlugin
+ const LilvPlugin* plug2 = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ assert(plug2);
+ assert(plug2 == plug);
+
+ // Check that plugin now has new name
+ LilvNode* name2 = lilv_plugin_get_name(plug2);
+ assert(name2);
+ assert(!strcmp(lilv_node_as_string(name2), "Second name"));
+ lilv_node_free(name2);
+
+ // Load new bundle again (noop)
+ lilv_world_load_bundle(world, bundle_uri);
+
+ lilv_node_free(bundle_uri);
+ delete_bundle(env);
+ lilv_test_env_free(env);
+
+ return 0;
}
diff --git a/test/test_replace_version.c b/test/test_replace_version.c
index a686572..66b690d 100644
--- a/test/test_replace_version.c
+++ b/test/test_replace_version.c
@@ -30,76 +30,76 @@
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
-
- LilvNode* plug_uri = lilv_new_uri(world, "http://example.org/versioned");
- LilvNode* lv2_minorVersion = lilv_new_uri(world, LV2_CORE__minorVersion);
- LilvNode* lv2_microVersion = lilv_new_uri(world, LV2_CORE__microVersion);
- LilvNode* minor = NULL;
- LilvNode* micro = NULL;
-
- char* old_bundle_path = lilv_strjoin(LILV_TEST_DIR, "old_version.lv2/", 0);
-
- // Load plugin from old bundle
- LilvNode* old_bundle = lilv_new_file_uri(world, NULL, old_bundle_path);
- lilv_world_load_bundle(world, old_bundle);
- lilv_world_load_resource(world, plug_uri);
-
- // Check version
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* old_plug = lilv_plugins_get_by_uri(plugins, plug_uri);
- assert(old_plug);
- minor = lilv_world_get(world, plug_uri, lv2_minorVersion, 0);
- micro = lilv_world_get(world, plug_uri, lv2_microVersion, 0);
- assert(!strcmp(lilv_node_as_string(minor), "1"));
- assert(!strcmp(lilv_node_as_string(micro), "0"));
- lilv_node_free(micro);
- lilv_node_free(minor);
-
- char* new_bundle_path = lilv_strjoin(LILV_TEST_DIR, "new_version.lv2/", 0);
-
- // Load plugin from new bundle
- LilvNode* new_bundle = lilv_new_file_uri(world, NULL, new_bundle_path);
- lilv_world_load_bundle(world, new_bundle);
- lilv_world_load_resource(world, plug_uri);
-
- // Check that version in the world model has changed
- plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* new_plug = lilv_plugins_get_by_uri(plugins, plug_uri);
- assert(new_plug);
- assert(lilv_node_equals(lilv_plugin_get_bundle_uri(new_plug), new_bundle));
- minor = lilv_world_get(world, plug_uri, lv2_minorVersion, 0);
- micro = lilv_world_get(world, plug_uri, lv2_microVersion, 0);
- assert(!strcmp(lilv_node_as_string(minor), "2"));
- assert(!strcmp(lilv_node_as_string(micro), "1"));
- lilv_node_free(micro);
- lilv_node_free(minor);
-
- // Try to load the old version again
- lilv_world_load_bundle(world, old_bundle);
- lilv_world_load_resource(world, plug_uri);
-
- // Check that version in the world model has not changed
- plugins = lilv_world_get_all_plugins(world);
- new_plug = lilv_plugins_get_by_uri(plugins, plug_uri);
- assert(new_plug);
- minor = lilv_world_get(world, plug_uri, lv2_minorVersion, 0);
- micro = lilv_world_get(world, plug_uri, lv2_microVersion, 0);
- assert(!strcmp(lilv_node_as_string(minor), "2"));
- assert(!strcmp(lilv_node_as_string(micro), "1"));
- lilv_node_free(micro);
- lilv_node_free(minor);
-
- lilv_node_free(new_bundle);
- lilv_node_free(old_bundle);
- free(new_bundle_path);
- free(old_bundle_path);
- lilv_node_free(plug_uri);
- lilv_node_free(lv2_minorVersion);
- lilv_node_free(lv2_microVersion);
-
- lilv_test_env_free(env);
-
- return 0;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
+
+ LilvNode* plug_uri = lilv_new_uri(world, "http://example.org/versioned");
+ LilvNode* lv2_minorVersion = lilv_new_uri(world, LV2_CORE__minorVersion);
+ LilvNode* lv2_microVersion = lilv_new_uri(world, LV2_CORE__microVersion);
+ LilvNode* minor = NULL;
+ LilvNode* micro = NULL;
+
+ char* old_bundle_path = lilv_strjoin(LILV_TEST_DIR, "old_version.lv2/", 0);
+
+ // Load plugin from old bundle
+ LilvNode* old_bundle = lilv_new_file_uri(world, NULL, old_bundle_path);
+ lilv_world_load_bundle(world, old_bundle);
+ lilv_world_load_resource(world, plug_uri);
+
+ // Check version
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* old_plug = lilv_plugins_get_by_uri(plugins, plug_uri);
+ assert(old_plug);
+ minor = lilv_world_get(world, plug_uri, lv2_minorVersion, 0);
+ micro = lilv_world_get(world, plug_uri, lv2_microVersion, 0);
+ assert(!strcmp(lilv_node_as_string(minor), "1"));
+ assert(!strcmp(lilv_node_as_string(micro), "0"));
+ lilv_node_free(micro);
+ lilv_node_free(minor);
+
+ char* new_bundle_path = lilv_strjoin(LILV_TEST_DIR, "new_version.lv2/", 0);
+
+ // Load plugin from new bundle
+ LilvNode* new_bundle = lilv_new_file_uri(world, NULL, new_bundle_path);
+ lilv_world_load_bundle(world, new_bundle);
+ lilv_world_load_resource(world, plug_uri);
+
+ // Check that version in the world model has changed
+ plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* new_plug = lilv_plugins_get_by_uri(plugins, plug_uri);
+ assert(new_plug);
+ assert(lilv_node_equals(lilv_plugin_get_bundle_uri(new_plug), new_bundle));
+ minor = lilv_world_get(world, plug_uri, lv2_minorVersion, 0);
+ micro = lilv_world_get(world, plug_uri, lv2_microVersion, 0);
+ assert(!strcmp(lilv_node_as_string(minor), "2"));
+ assert(!strcmp(lilv_node_as_string(micro), "1"));
+ lilv_node_free(micro);
+ lilv_node_free(minor);
+
+ // Try to load the old version again
+ lilv_world_load_bundle(world, old_bundle);
+ lilv_world_load_resource(world, plug_uri);
+
+ // Check that version in the world model has not changed
+ plugins = lilv_world_get_all_plugins(world);
+ new_plug = lilv_plugins_get_by_uri(plugins, plug_uri);
+ assert(new_plug);
+ minor = lilv_world_get(world, plug_uri, lv2_minorVersion, 0);
+ micro = lilv_world_get(world, plug_uri, lv2_microVersion, 0);
+ assert(!strcmp(lilv_node_as_string(minor), "2"));
+ assert(!strcmp(lilv_node_as_string(micro), "1"));
+ lilv_node_free(micro);
+ lilv_node_free(minor);
+
+ lilv_node_free(new_bundle);
+ lilv_node_free(old_bundle);
+ free(new_bundle_path);
+ free(old_bundle_path);
+ lilv_node_free(plug_uri);
+ lilv_node_free(lv2_minorVersion);
+ lilv_node_free(lv2_microVersion);
+
+ lilv_test_env_free(env);
+
+ return 0;
}
diff --git a/test/test_state.c b/test/test_state.c
index dffacee..24106ac 100644
--- a/test/test_state.c
+++ b/test/test_state.c
@@ -28,10 +28,10 @@
#include "serd/serd.h"
#ifdef _WIN32
-# include <direct.h>
-# define mkdir(path, flags) _mkdir(path)
+# include <direct.h>
+# define mkdir(path, flags) _mkdir(path)
#else
-# include <sys/stat.h>
+# include <sys/stat.h>
#endif
#include <assert.h>
@@ -43,143 +43,141 @@
#define TEST_PLUGIN_URI "http://example.org/lilv-test-plugin"
-typedef struct
-{
- LilvTestEnv* env;
- LilvTestUriMap uri_map;
- LV2_URID_Map map;
- LV2_Feature map_feature;
- LV2_URID_Unmap unmap;
- LV2_Feature unmap_feature;
- LV2_State_Free_Path free_path;
- LV2_Feature free_path_feature;
- const LV2_Feature* features[4];
- LV2_URID atom_Float;
- float in;
- float out;
- float control;
+typedef struct {
+ LilvTestEnv* env;
+ LilvTestUriMap uri_map;
+ LV2_URID_Map map;
+ LV2_Feature map_feature;
+ LV2_URID_Unmap unmap;
+ LV2_Feature unmap_feature;
+ LV2_State_Free_Path free_path;
+ LV2_Feature free_path_feature;
+ const LV2_Feature* features[4];
+ LV2_URID atom_Float;
+ float in;
+ float out;
+ float control;
} TestContext;
-typedef struct
-{
- char* top; ///< Temporary directory that contains everything
- char* shared; ///< Common parent for shared directoryes (top/shared)
- char* scratch; ///< Scratch file directory (top/shared/scratch)
- char* copy; ///< Copy directory (top/shared/scratch)
- char* link; ///< Link directory (top/shared/scratch)
+typedef struct {
+ char* top; ///< Temporary directory that contains everything
+ char* shared; ///< Common parent for shared directoryes (top/shared)
+ char* scratch; ///< Scratch file directory (top/shared/scratch)
+ char* copy; ///< Copy directory (top/shared/scratch)
+ char* link; ///< Link directory (top/shared/scratch)
} TestDirectories;
static void
lilv_free_path(LV2_State_Free_Path_Handle handle, char* path)
{
- (void)handle;
+ (void)handle;
- lilv_free(path);
+ lilv_free(path);
}
static TestContext*
test_context_new(void)
{
- TestContext* ctx = (TestContext*)calloc(1, sizeof(TestContext));
-
- lilv_test_uri_map_init(&ctx->uri_map);
-
- ctx->env = lilv_test_env_new();
- ctx->map.handle = &ctx->uri_map;
- ctx->map.map = map_uri;
- ctx->map_feature.URI = LV2_URID_MAP_URI;
- ctx->map_feature.data = &ctx->map;
- ctx->unmap.handle = &ctx->uri_map;
- ctx->unmap.unmap = unmap_uri;
- ctx->unmap_feature.URI = LV2_URID_UNMAP_URI;
- ctx->unmap_feature.data = &ctx->unmap;
- ctx->free_path.free_path = lilv_free_path;
- ctx->free_path_feature.URI = LV2_STATE__freePath;
- ctx->free_path_feature.data = &ctx->free_path;
- ctx->features[0] = &ctx->map_feature;
- ctx->features[1] = &ctx->unmap_feature;
- ctx->features[2] = &ctx->free_path_feature;
- ctx->features[3] = NULL;
-
- ctx->atom_Float =
- map_uri(&ctx->uri_map, "http://lv2plug.in/ns/ext/atom#Float");
-
- ctx->in = 1.0;
- ctx->out = 42.0;
- ctx->control = 1234.0;
-
- return ctx;
+ TestContext* ctx = (TestContext*)calloc(1, sizeof(TestContext));
+
+ lilv_test_uri_map_init(&ctx->uri_map);
+
+ ctx->env = lilv_test_env_new();
+ ctx->map.handle = &ctx->uri_map;
+ ctx->map.map = map_uri;
+ ctx->map_feature.URI = LV2_URID_MAP_URI;
+ ctx->map_feature.data = &ctx->map;
+ ctx->unmap.handle = &ctx->uri_map;
+ ctx->unmap.unmap = unmap_uri;
+ ctx->unmap_feature.URI = LV2_URID_UNMAP_URI;
+ ctx->unmap_feature.data = &ctx->unmap;
+ ctx->free_path.free_path = lilv_free_path;
+ ctx->free_path_feature.URI = LV2_STATE__freePath;
+ ctx->free_path_feature.data = &ctx->free_path;
+ ctx->features[0] = &ctx->map_feature;
+ ctx->features[1] = &ctx->unmap_feature;
+ ctx->features[2] = &ctx->free_path_feature;
+ ctx->features[3] = NULL;
+
+ ctx->atom_Float =
+ map_uri(&ctx->uri_map, "http://lv2plug.in/ns/ext/atom#Float");
+
+ ctx->in = 1.0;
+ ctx->out = 42.0;
+ ctx->control = 1234.0;
+
+ return ctx;
}
static void
test_context_free(TestContext* ctx)
{
- lilv_test_uri_map_clear(&ctx->uri_map);
- lilv_test_env_free(ctx->env);
- free(ctx);
+ lilv_test_uri_map_clear(&ctx->uri_map);
+ lilv_test_env_free(ctx->env);
+ free(ctx);
}
static TestDirectories
create_test_directories(void)
{
- TestDirectories dirs;
+ TestDirectories dirs;
- char* const top = lilv_create_temporary_directory("lilv_XXXXXX");
- assert(top);
+ char* const top = lilv_create_temporary_directory("lilv_XXXXXX");
+ assert(top);
- /* On MacOS, temporary directories from mkdtemp involve symlinks, so
- resolve it here so that path comparisons in tests work. */
+ /* On MacOS, temporary directories from mkdtemp involve symlinks, so
+ resolve it here so that path comparisons in tests work. */
- dirs.top = lilv_path_canonical(top);
- dirs.shared = lilv_path_join(dirs.top, "shared");
- dirs.scratch = lilv_path_join(dirs.shared, "scratch");
- dirs.copy = lilv_path_join(dirs.shared, "copy");
- dirs.link = lilv_path_join(dirs.shared, "link");
+ dirs.top = lilv_path_canonical(top);
+ dirs.shared = lilv_path_join(dirs.top, "shared");
+ dirs.scratch = lilv_path_join(dirs.shared, "scratch");
+ dirs.copy = lilv_path_join(dirs.shared, "copy");
+ dirs.link = lilv_path_join(dirs.shared, "link");
- assert(!mkdir(dirs.shared, 0700));
- assert(!mkdir(dirs.scratch, 0700));
- assert(!mkdir(dirs.copy, 0700));
- assert(!mkdir(dirs.link, 0700));
+ assert(!mkdir(dirs.shared, 0700));
+ assert(!mkdir(dirs.scratch, 0700));
+ assert(!mkdir(dirs.copy, 0700));
+ assert(!mkdir(dirs.link, 0700));
- free(top);
+ free(top);
- return dirs;
+ return dirs;
}
static TestDirectories
no_test_directories(void)
{
- TestDirectories dirs = {NULL, NULL, NULL, NULL, NULL};
+ TestDirectories dirs = {NULL, NULL, NULL, NULL, NULL};
- return dirs;
+ return dirs;
}
static void
remove_file(const char* path, const char* name, void* data)
{
- char* const full_path = lilv_path_join(path, name);
- assert(!lilv_remove(full_path));
- free(full_path);
+ char* const full_path = lilv_path_join(path, name);
+ assert(!lilv_remove(full_path));
+ free(full_path);
}
static void
cleanup_test_directories(const TestDirectories dirs)
{
- lilv_dir_for_each(dirs.scratch, NULL, remove_file);
- lilv_dir_for_each(dirs.copy, NULL, remove_file);
- lilv_dir_for_each(dirs.link, NULL, remove_file);
-
- assert(!lilv_remove(dirs.link));
- assert(!lilv_remove(dirs.copy));
- assert(!lilv_remove(dirs.scratch));
- assert(!lilv_remove(dirs.shared));
- assert(!lilv_remove(dirs.top));
-
- free(dirs.link);
- free(dirs.copy);
- free(dirs.scratch);
- free(dirs.shared);
- free(dirs.top);
+ lilv_dir_for_each(dirs.scratch, NULL, remove_file);
+ lilv_dir_for_each(dirs.copy, NULL, remove_file);
+ lilv_dir_for_each(dirs.link, NULL, remove_file);
+
+ assert(!lilv_remove(dirs.link));
+ assert(!lilv_remove(dirs.copy));
+ assert(!lilv_remove(dirs.scratch));
+ assert(!lilv_remove(dirs.shared));
+ assert(!lilv_remove(dirs.top));
+
+ free(dirs.link);
+ free(dirs.copy);
+ free(dirs.scratch);
+ free(dirs.shared);
+ free(dirs.top);
}
static const void*
@@ -188,27 +186,26 @@ get_port_value(const char* port_symbol,
uint32_t* size,
uint32_t* type)
{
- TestContext* ctx = (TestContext*)user_data;
-
- if (!strcmp(port_symbol, "input")) {
- *size = sizeof(float);
- *type = ctx->atom_Float;
- return &ctx->in;
- } else if (!strcmp(port_symbol, "output")) {
- *size = sizeof(float);
- *type = ctx->atom_Float;
- return &ctx->out;
- } else if (!strcmp(port_symbol, "control")) {
- *size = sizeof(float);
- *type = ctx->atom_Float;
- return &ctx->control;
- } else {
- fprintf(stderr,
- "error: get_port_value for nonexistent port `%s'\n",
- port_symbol);
- *size = *type = 0;
- return NULL;
- }
+ TestContext* ctx = (TestContext*)user_data;
+
+ if (!strcmp(port_symbol, "input")) {
+ *size = sizeof(float);
+ *type = ctx->atom_Float;
+ return &ctx->in;
+ } else if (!strcmp(port_symbol, "output")) {
+ *size = sizeof(float);
+ *type = ctx->atom_Float;
+ return &ctx->out;
+ } else if (!strcmp(port_symbol, "control")) {
+ *size = sizeof(float);
+ *type = ctx->atom_Float;
+ return &ctx->control;
+ } else {
+ fprintf(
+ stderr, "error: get_port_value for nonexistent port `%s'\n", port_symbol);
+ *size = *type = 0;
+ return NULL;
+ }
}
static void
@@ -218,50 +215,49 @@ set_port_value(const char* port_symbol,
uint32_t size,
uint32_t type)
{
- TestContext* ctx = (TestContext*)user_data;
-
- if (!strcmp(port_symbol, "input")) {
- ctx->in = *(const float*)value;
- } else if (!strcmp(port_symbol, "output")) {
- ctx->out = *(const float*)value;
- } else if (!strcmp(port_symbol, "control")) {
- ctx->control = *(const float*)value;
- } else {
- fprintf(stderr,
- "error: set_port_value for nonexistent port `%s'\n",
- port_symbol);
- }
+ TestContext* ctx = (TestContext*)user_data;
+
+ if (!strcmp(port_symbol, "input")) {
+ ctx->in = *(const float*)value;
+ } else if (!strcmp(port_symbol, "output")) {
+ ctx->out = *(const float*)value;
+ } else if (!strcmp(port_symbol, "control")) {
+ ctx->control = *(const float*)value;
+ } else {
+ fprintf(
+ stderr, "error: set_port_value for nonexistent port `%s'\n", port_symbol);
+ }
}
static char*
make_scratch_path(LV2_State_Make_Path_Handle handle, const char* path)
{
- TestDirectories* dirs = (TestDirectories*)handle;
+ TestDirectories* dirs = (TestDirectories*)handle;
- return lilv_path_join(dirs->scratch, path);
+ return lilv_path_join(dirs->scratch, path);
}
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);
+ 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);
- lilv_world_load_bundle(world, bundle_uri);
+ lilv_world_load_bundle(world, bundle_uri);
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugins, plugin_uri);
- lilv_node_free(plugin_uri);
- lilv_node_free(bundle_uri);
- serd_node_free(&bundle);
- free(abs_bundle);
+ lilv_node_free(plugin_uri);
+ lilv_node_free(bundle_uri);
+ serd_node_free(&bundle);
+ free(abs_bundle);
- assert(plugin);
- return plugin;
+ assert(plugin);
+ return plugin;
}
static LilvState*
@@ -271,262 +267,262 @@ state_from_instance(const LilvPlugin* const plugin,
const TestDirectories* const dirs,
const char* const bundle_path)
{
- return lilv_state_new_from_instance(plugin,
- instance,
- &ctx->map,
- dirs->scratch,
- dirs->copy,
- dirs->link,
- bundle_path,
- get_port_value,
- ctx,
- 0,
- NULL);
+ return lilv_state_new_from_instance(plugin,
+ instance,
+ &ctx->map,
+ dirs->scratch,
+ dirs->copy,
+ dirs->link,
+ bundle_path,
+ get_port_value,
+ ctx,
+ 0,
+ NULL);
}
static void
test_instance_state(void)
{
- TestContext* const ctx = test_context_new();
- const TestDirectories dirs = no_test_directories();
- const LilvPlugin* const plugin = load_test_plugin(ctx);
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
+ TestContext* const ctx = test_context_new();
+ const TestDirectories dirs = no_test_directories();
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
- assert(instance);
+ assert(instance);
- // Get instance state
- LilvState* const state =
- state_from_instance(plugin, instance, ctx, &dirs, NULL);
+ // Get instance state
+ LilvState* const state =
+ state_from_instance(plugin, instance, ctx, &dirs, NULL);
- // Check that state contains properties saved by the plugin
- assert(lilv_state_get_num_properties(state) == 8);
+ // Check that state contains properties saved by the plugin
+ assert(lilv_state_get_num_properties(state) == 8);
- // Check that state has no URI
- assert(!lilv_state_get_uri(state));
+ // Check that state has no URI
+ assert(!lilv_state_get_uri(state));
- // Check that state can't be saved without a URI
- assert(!lilv_state_to_string(
- ctx->env->world, &ctx->map, &ctx->unmap, state, NULL, NULL));
+ // Check that state can't be saved without a URI
+ assert(!lilv_state_to_string(
+ ctx->env->world, &ctx->map, &ctx->unmap, state, NULL, NULL));
- // Check that we can't delete unsaved state
- assert(lilv_state_delete(ctx->env->world, state));
+ // Check that we can't delete unsaved state
+ assert(lilv_state_delete(ctx->env->world, state));
- lilv_state_free(state);
- lilv_instance_free(instance);
- test_context_free(ctx);
+ lilv_state_free(state);
+ lilv_instance_free(instance);
+ test_context_free(ctx);
}
static void
test_equal(void)
{
- TestContext* const ctx = test_context_new();
- const TestDirectories dirs = no_test_directories();
- const LilvPlugin* const plugin = load_test_plugin(ctx);
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
+ TestContext* const ctx = test_context_new();
+ const TestDirectories dirs = no_test_directories();
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
- assert(instance);
+ assert(instance);
- // Get instance state
- LilvState* const state_1 =
- state_from_instance(plugin, instance, ctx, &dirs, NULL);
+ // Get instance state
+ LilvState* const state_1 =
+ state_from_instance(plugin, instance, ctx, &dirs, NULL);
- // Get another instance state
- LilvState* const state_2 =
- state_from_instance(plugin, instance, ctx, &dirs, NULL);
+ // Get another instance state
+ LilvState* const state_2 =
+ state_from_instance(plugin, instance, ctx, &dirs, NULL);
- // Ensure they are equal
- assert(lilv_state_equals(state_1, state_2));
+ // Ensure they are equal
+ assert(lilv_state_equals(state_1, state_2));
- // Set a label on the second state
- assert(lilv_state_get_label(state_2) == NULL);
- lilv_state_set_label(state_2, "Test State Old Label");
+ // Set a label on the second state
+ assert(lilv_state_get_label(state_2) == NULL);
+ lilv_state_set_label(state_2, "Test State Old Label");
- // Ensure they are no longer equal
- assert(!lilv_state_equals(state_1, state_2));
+ // Ensure they are no longer equal
+ assert(!lilv_state_equals(state_1, state_2));
- lilv_state_free(state_2);
- lilv_state_free(state_1);
- lilv_instance_free(instance);
- test_context_free(ctx);
+ lilv_state_free(state_2);
+ lilv_state_free(state_1);
+ lilv_instance_free(instance);
+ test_context_free(ctx);
}
static void
test_changed_plugin_data(void)
{
- TestContext* const ctx = test_context_new();
- const TestDirectories dirs = no_test_directories();
- const LilvPlugin* const plugin = load_test_plugin(ctx);
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
-
- assert(instance);
-
- // Get initial state
- LilvState* const initial_state =
- state_from_instance(plugin, instance, ctx, &dirs, NULL);
-
- // Run plugin to change internal state
- lilv_instance_activate(instance);
- lilv_instance_connect_port(instance, 0, &ctx->in);
- lilv_instance_connect_port(instance, 1, &ctx->out);
- lilv_instance_run(instance, 1);
- assert(ctx->in == 1.0);
- assert(ctx->out == 1.0);
-
- // Get a new instance state (which should now differ)
- LilvState* const changed_state =
- state_from_instance(plugin, instance, ctx, &dirs, NULL);
-
- // Ensure state has changed
- assert(!lilv_state_equals(initial_state, changed_state));
-
- lilv_state_free(changed_state);
- lilv_state_free(initial_state);
- lilv_instance_free(instance);
- test_context_free(ctx);
+ TestContext* const ctx = test_context_new();
+ const TestDirectories dirs = no_test_directories();
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
+
+ assert(instance);
+
+ // Get initial state
+ LilvState* const initial_state =
+ state_from_instance(plugin, instance, ctx, &dirs, NULL);
+
+ // Run plugin to change internal state
+ lilv_instance_activate(instance);
+ lilv_instance_connect_port(instance, 0, &ctx->in);
+ lilv_instance_connect_port(instance, 1, &ctx->out);
+ lilv_instance_run(instance, 1);
+ assert(ctx->in == 1.0);
+ assert(ctx->out == 1.0);
+
+ // Get a new instance state (which should now differ)
+ LilvState* const changed_state =
+ state_from_instance(plugin, instance, ctx, &dirs, NULL);
+
+ // Ensure state has changed
+ assert(!lilv_state_equals(initial_state, changed_state));
+
+ lilv_state_free(changed_state);
+ lilv_state_free(initial_state);
+ lilv_instance_free(instance);
+ test_context_free(ctx);
}
static void
test_changed_metadata(void)
{
- TestContext* const ctx = test_context_new();
- const TestDirectories dirs = no_test_directories();
- LV2_URID_Map* const map = &ctx->map;
- const LilvPlugin* const plugin = load_test_plugin(ctx);
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
-
- assert(instance);
-
- // Get initial state
- LilvState* const initial_state =
- state_from_instance(plugin, instance, ctx, &dirs, NULL);
-
- // Save initial state to a string
- char* const initial_string =
- lilv_state_to_string(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- initial_state,
- "http://example.org/initial",
- NULL);
-
- // Get another state
- LilvState* const changed_state =
- state_from_instance(plugin, instance, ctx, &dirs, NULL);
-
- // Set a metadata property
- const LV2_URID key = map->map(map->handle, "http://example.org/extra");
- const int32_t value = 1;
- const LV2_URID type =
- map->map(map->handle, "http://lv2plug.in/ns/ext/atom#Int");
- lilv_state_set_metadata(changed_state,
- key,
- &value,
- sizeof(value),
- type,
- LV2_STATE_IS_PORTABLE | LV2_STATE_IS_POD);
-
- // Save changed state to a string
- char* const changed_string =
- lilv_state_to_string(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- changed_state,
- "http://example.org/changed",
- NULL);
-
- // Ensure that strings differ (metadata does not affect state equality)
- assert(strcmp(initial_string, changed_string));
-
- free(changed_string);
- lilv_state_free(changed_state);
- free(initial_string);
- lilv_state_free(initial_state);
- lilv_instance_free(instance);
- test_context_free(ctx);
+ TestContext* const ctx = test_context_new();
+ const TestDirectories dirs = no_test_directories();
+ LV2_URID_Map* const map = &ctx->map;
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
+
+ assert(instance);
+
+ // Get initial state
+ LilvState* const initial_state =
+ state_from_instance(plugin, instance, ctx, &dirs, NULL);
+
+ // Save initial state to a string
+ char* const initial_string =
+ lilv_state_to_string(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ initial_state,
+ "http://example.org/initial",
+ NULL);
+
+ // Get another state
+ LilvState* const changed_state =
+ state_from_instance(plugin, instance, ctx, &dirs, NULL);
+
+ // Set a metadata property
+ const LV2_URID key = map->map(map->handle, "http://example.org/extra");
+ const int32_t value = 1;
+ const LV2_URID type =
+ map->map(map->handle, "http://lv2plug.in/ns/ext/atom#Int");
+ lilv_state_set_metadata(changed_state,
+ key,
+ &value,
+ sizeof(value),
+ type,
+ LV2_STATE_IS_PORTABLE | LV2_STATE_IS_POD);
+
+ // Save changed state to a string
+ char* const changed_string =
+ lilv_state_to_string(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ changed_state,
+ "http://example.org/changed",
+ NULL);
+
+ // Ensure that strings differ (metadata does not affect state equality)
+ assert(strcmp(initial_string, changed_string));
+
+ free(changed_string);
+ lilv_state_free(changed_state);
+ free(initial_string);
+ lilv_state_free(initial_state);
+ lilv_instance_free(instance);
+ test_context_free(ctx);
}
static void
test_to_string(void)
{
- TestContext* const ctx = test_context_new();
- const TestDirectories dirs = no_test_directories();
- const LilvPlugin* const plugin = load_test_plugin(ctx);
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
-
- assert(instance);
-
- // Get initial state
- LilvState* const initial_state =
- state_from_instance(plugin, instance, ctx, &dirs, NULL);
-
- // Run plugin to change internal state
- lilv_instance_activate(instance);
- lilv_instance_connect_port(instance, 0, &ctx->in);
- lilv_instance_connect_port(instance, 1, &ctx->out);
- lilv_instance_run(instance, 1);
- assert(ctx->in == 1.0);
- assert(ctx->out == 1.0);
-
- // Restore instance state to original state
- lilv_state_restore(initial_state, instance, set_port_value, ctx, 0, NULL);
-
- // Take a new snapshot of the state
- LilvState* const restored =
- state_from_instance(plugin, instance, ctx, &dirs, NULL);
-
- // Check that new state matches the initial state
- assert(lilv_state_equals(initial_state, restored));
-
- lilv_state_free(restored);
- lilv_state_free(initial_state);
- lilv_instance_free(instance);
- test_context_free(ctx);
+ TestContext* const ctx = test_context_new();
+ const TestDirectories dirs = no_test_directories();
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
+
+ assert(instance);
+
+ // Get initial state
+ LilvState* const initial_state =
+ state_from_instance(plugin, instance, ctx, &dirs, NULL);
+
+ // Run plugin to change internal state
+ lilv_instance_activate(instance);
+ lilv_instance_connect_port(instance, 0, &ctx->in);
+ lilv_instance_connect_port(instance, 1, &ctx->out);
+ lilv_instance_run(instance, 1);
+ assert(ctx->in == 1.0);
+ assert(ctx->out == 1.0);
+
+ // Restore instance state to original state
+ lilv_state_restore(initial_state, instance, set_port_value, ctx, 0, NULL);
+
+ // Take a new snapshot of the state
+ LilvState* const restored =
+ state_from_instance(plugin, instance, ctx, &dirs, NULL);
+
+ // Check that new state matches the initial state
+ assert(lilv_state_equals(initial_state, restored));
+
+ lilv_state_free(restored);
+ lilv_state_free(initial_state);
+ lilv_instance_free(instance);
+ test_context_free(ctx);
}
static void
test_string_round_trip(void)
{
- TestContext* const ctx = test_context_new();
- const TestDirectories dirs = no_test_directories();
- const LilvPlugin* const plugin = load_test_plugin(ctx);
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
-
- assert(instance);
-
- // Get initial state
- LilvState* const initial_state =
- state_from_instance(plugin, instance, ctx, &dirs, NULL);
-
- // Save state to a string
- char* const string = lilv_state_to_string(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- initial_state,
- "http://example.org/string",
- NULL);
-
- // Restore from string
- LilvState* const restored =
- lilv_state_new_from_string(ctx->env->world, &ctx->map, string);
-
- // Ensure they are equal
- assert(lilv_state_equals(initial_state, restored));
-
- // Check that the restored state refers to the correct plugin
- const LilvNode* state_plugin_uri = lilv_state_get_plugin_uri(restored);
- assert(!strcmp(lilv_node_as_string(state_plugin_uri), TEST_PLUGIN_URI));
-
- lilv_state_free(restored);
- free(string);
- lilv_state_free(initial_state);
- lilv_instance_free(instance);
- test_context_free(ctx);
+ TestContext* const ctx = test_context_new();
+ const TestDirectories dirs = no_test_directories();
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
+
+ assert(instance);
+
+ // Get initial state
+ LilvState* const initial_state =
+ state_from_instance(plugin, instance, ctx, &dirs, NULL);
+
+ // Save state to a string
+ char* const string = lilv_state_to_string(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ initial_state,
+ "http://example.org/string",
+ NULL);
+
+ // Restore from string
+ LilvState* const restored =
+ lilv_state_new_from_string(ctx->env->world, &ctx->map, string);
+
+ // Ensure they are equal
+ assert(lilv_state_equals(initial_state, restored));
+
+ // Check that the restored state refers to the correct plugin
+ const LilvNode* state_plugin_uri = lilv_state_get_plugin_uri(restored);
+ assert(!strcmp(lilv_node_as_string(state_plugin_uri), TEST_PLUGIN_URI));
+
+ lilv_state_free(restored);
+ free(string);
+ lilv_state_free(initial_state);
+ lilv_instance_free(instance);
+ test_context_free(ctx);
}
static SerdStatus
@@ -539,582 +535,563 @@ count_sink(void* const handle,
const SerdNode* const object_datatype,
const SerdNode* const object_lang)
{
- size_t* const n_statements = (size_t*)handle;
+ size_t* const n_statements = (size_t*)handle;
- ++(*n_statements);
+ ++(*n_statements);
- return SERD_SUCCESS;
+ return SERD_SUCCESS;
}
static size_t
count_statements(const char* path)
{
- size_t n_statements = 0;
+ size_t n_statements = 0;
- SerdReader* reader = serd_reader_new(
- SERD_TURTLE, &n_statements, NULL, NULL, NULL, count_sink, NULL);
+ SerdReader* reader = serd_reader_new(
+ SERD_TURTLE, &n_statements, NULL, NULL, NULL, count_sink, NULL);
- SerdNode uri =
- serd_node_new_file_uri((const uint8_t*)path, NULL, NULL, true);
+ SerdNode uri = serd_node_new_file_uri((const uint8_t*)path, NULL, NULL, true);
- assert(!serd_reader_read_file(reader, uri.buf));
+ assert(!serd_reader_read_file(reader, uri.buf));
- serd_node_free(&uri);
- serd_reader_free(reader);
+ serd_node_free(&uri);
+ serd_reader_free(reader);
- return n_statements;
+ return n_statements;
}
static void
test_to_files(void)
{
- TestContext* const ctx = test_context_new();
- TestDirectories dirs = create_test_directories();
- const LilvPlugin* const plugin = load_test_plugin(ctx);
-
- LV2_State_Make_Path make_path = {&dirs, make_scratch_path};
- LV2_Feature make_path_feature = {LV2_STATE__makePath, &make_path};
-
- const LV2_Feature* const instance_features[] = {&ctx->map_feature,
- &ctx->free_path_feature,
- &make_path_feature,
- NULL};
-
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, instance_features);
-
- assert(instance);
-
- // Run plugin to generate some recording file data
- lilv_instance_activate(instance);
- lilv_instance_connect_port(instance, 0, &ctx->in);
- lilv_instance_connect_port(instance, 1, &ctx->out);
- lilv_instance_run(instance, 1);
- lilv_instance_run(instance, 2);
- assert(ctx->in == 1.0);
- assert(ctx->out == 1.0);
-
- // Check that the test plugin has made its recording scratch file
- char* const recfile_path = lilv_path_join(dirs.scratch, "recfile");
- assert(lilv_path_exists(recfile_path));
-
- // Get state
- char* const bundle_1_path = lilv_path_join(dirs.top, "state1.lv2");
- LilvState* const state_1 =
- state_from_instance(plugin, instance, ctx, &dirs, bundle_1_path);
-
- // Check that state contains properties saved by the plugin (with files)
- assert(lilv_state_get_num_properties(state_1) == 10);
-
- // Check that a snapshop of the recfile was created
- char* const recfile_copy_1 = lilv_path_join(dirs.copy, "recfile");
- assert(lilv_path_exists(recfile_copy_1));
-
- // Save state to a bundle
- assert(!lilv_state_save(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- state_1,
- "http://example.org/state1",
- bundle_1_path,
- "state.ttl"));
-
- // Check that a manifest exists
- char* const manifest_path = lilv_path_join(bundle_1_path, "manifest.ttl");
- assert(lilv_path_exists(manifest_path));
-
- // Check that the expected statements are in the manifest file
- assert(count_statements(manifest_path) == 3);
-
- // Check that a link to the recfile exists in the saved bundle
- char* const recfile_link_1 = lilv_path_join(bundle_1_path, "recfile");
- assert(lilv_path_exists(recfile_link_1));
-
- // Check that link points to the corresponding copy
- assert(lilv_file_equals(recfile_link_1, recfile_copy_1));
-
- // Run plugin again to modify recording file data
- lilv_instance_run(instance, 2);
-
- // Get updated state
- char* const bundle_2_path = lilv_path_join(dirs.top, "state2.lv2");
- LilvState* const state_2 =
- state_from_instance(plugin, instance, ctx, &dirs, bundle_2_path);
-
- // Save updated state to a bundle
- assert(!lilv_state_save(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- state_2,
- NULL,
- bundle_2_path,
- "state.ttl"));
-
- // Check that a new snapshop of the recfile was created
- char* const recfile_copy_2 = lilv_path_join(dirs.copy, "recfile.2");
- assert(lilv_path_exists(recfile_copy_2));
-
- // Check that a link to the recfile exists in the updated bundle
- char* const recfile_link_2 = lilv_path_join(bundle_2_path, "recfile");
- assert(lilv_path_exists(recfile_link_2));
-
- // Check that link points to the corresponding copy
- assert(lilv_file_equals(recfile_link_2, recfile_copy_2));
-
- lilv_instance_free(instance);
- lilv_dir_for_each(bundle_2_path, NULL, remove_file);
- lilv_dir_for_each(bundle_1_path, NULL, remove_file);
- assert(!lilv_remove(bundle_2_path));
- assert(!lilv_remove(bundle_1_path));
- cleanup_test_directories(dirs);
-
- free(recfile_link_2);
- free(recfile_copy_2);
- lilv_state_free(state_2);
- free(bundle_2_path);
- free(recfile_link_1);
- free(manifest_path);
- free(recfile_copy_1);
- lilv_state_free(state_1);
- free(bundle_1_path);
- free(recfile_path);
- test_context_free(ctx);
+ TestContext* const ctx = test_context_new();
+ TestDirectories dirs = create_test_directories();
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+
+ LV2_State_Make_Path make_path = {&dirs, make_scratch_path};
+ LV2_Feature make_path_feature = {LV2_STATE__makePath, &make_path};
+
+ const LV2_Feature* const instance_features[] = {
+ &ctx->map_feature, &ctx->free_path_feature, &make_path_feature, NULL};
+
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, instance_features);
+
+ assert(instance);
+
+ // Run plugin to generate some recording file data
+ lilv_instance_activate(instance);
+ lilv_instance_connect_port(instance, 0, &ctx->in);
+ lilv_instance_connect_port(instance, 1, &ctx->out);
+ lilv_instance_run(instance, 1);
+ lilv_instance_run(instance, 2);
+ assert(ctx->in == 1.0);
+ assert(ctx->out == 1.0);
+
+ // Check that the test plugin has made its recording scratch file
+ char* const recfile_path = lilv_path_join(dirs.scratch, "recfile");
+ assert(lilv_path_exists(recfile_path));
+
+ // Get state
+ char* const bundle_1_path = lilv_path_join(dirs.top, "state1.lv2");
+ LilvState* const state_1 =
+ state_from_instance(plugin, instance, ctx, &dirs, bundle_1_path);
+
+ // Check that state contains properties saved by the plugin (with files)
+ assert(lilv_state_get_num_properties(state_1) == 10);
+
+ // Check that a snapshop of the recfile was created
+ char* const recfile_copy_1 = lilv_path_join(dirs.copy, "recfile");
+ assert(lilv_path_exists(recfile_copy_1));
+
+ // Save state to a bundle
+ assert(!lilv_state_save(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ state_1,
+ "http://example.org/state1",
+ bundle_1_path,
+ "state.ttl"));
+
+ // Check that a manifest exists
+ char* const manifest_path = lilv_path_join(bundle_1_path, "manifest.ttl");
+ assert(lilv_path_exists(manifest_path));
+
+ // Check that the expected statements are in the manifest file
+ assert(count_statements(manifest_path) == 3);
+
+ // Check that a link to the recfile exists in the saved bundle
+ char* const recfile_link_1 = lilv_path_join(bundle_1_path, "recfile");
+ assert(lilv_path_exists(recfile_link_1));
+
+ // Check that link points to the corresponding copy
+ assert(lilv_file_equals(recfile_link_1, recfile_copy_1));
+
+ // Run plugin again to modify recording file data
+ lilv_instance_run(instance, 2);
+
+ // Get updated state
+ char* const bundle_2_path = lilv_path_join(dirs.top, "state2.lv2");
+ LilvState* const state_2 =
+ state_from_instance(plugin, instance, ctx, &dirs, bundle_2_path);
+
+ // Save updated state to a bundle
+ assert(!lilv_state_save(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ state_2,
+ NULL,
+ bundle_2_path,
+ "state.ttl"));
+
+ // Check that a new snapshop of the recfile was created
+ char* const recfile_copy_2 = lilv_path_join(dirs.copy, "recfile.2");
+ assert(lilv_path_exists(recfile_copy_2));
+
+ // Check that a link to the recfile exists in the updated bundle
+ char* const recfile_link_2 = lilv_path_join(bundle_2_path, "recfile");
+ assert(lilv_path_exists(recfile_link_2));
+
+ // Check that link points to the corresponding copy
+ assert(lilv_file_equals(recfile_link_2, recfile_copy_2));
+
+ lilv_instance_free(instance);
+ lilv_dir_for_each(bundle_2_path, NULL, remove_file);
+ lilv_dir_for_each(bundle_1_path, NULL, remove_file);
+ assert(!lilv_remove(bundle_2_path));
+ assert(!lilv_remove(bundle_1_path));
+ cleanup_test_directories(dirs);
+
+ free(recfile_link_2);
+ free(recfile_copy_2);
+ lilv_state_free(state_2);
+ free(bundle_2_path);
+ free(recfile_link_1);
+ free(manifest_path);
+ free(recfile_copy_1);
+ lilv_state_free(state_1);
+ free(bundle_1_path);
+ free(recfile_path);
+ test_context_free(ctx);
}
static void
test_multi_save(void)
{
- TestContext* const ctx = test_context_new();
- TestDirectories dirs = create_test_directories();
- const LilvPlugin* const plugin = load_test_plugin(ctx);
-
- LV2_State_Make_Path make_path = {&dirs, make_scratch_path};
- LV2_Feature make_path_feature = {LV2_STATE__makePath, &make_path};
-
- const LV2_Feature* const instance_features[] = {&ctx->map_feature,
- &ctx->free_path_feature,
- &make_path_feature,
- NULL};
-
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, instance_features);
-
- assert(instance);
-
- // Get state
- char* const bundle_1_path = lilv_path_join(dirs.top, "state1.lv2");
- LilvState* const state_1 =
- state_from_instance(plugin, instance, ctx, &dirs, bundle_1_path);
-
- // Save state to a bundle
- assert(!lilv_state_save(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- state_1,
- "http://example.org/state1",
- bundle_1_path,
- "state.ttl"));
-
- // Check that a manifest exists
- char* const manifest_path = lilv_path_join(bundle_1_path, "manifest.ttl");
- assert(lilv_path_exists(manifest_path));
-
- // Check that the state file exists
- char* const state_path = lilv_path_join(bundle_1_path, "state.ttl");
- assert(lilv_path_exists(state_path));
-
- // Check that the expected statements are in the files
- assert(count_statements(manifest_path) == 3);
- assert(count_statements(state_path) == 21);
-
- // Save state again to the same bundle
- assert(!lilv_state_save(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- state_1,
- "http://example.org/state1",
- bundle_1_path,
- "state.ttl"));
-
- // Check that everything is the same
- assert(lilv_path_exists(manifest_path));
- assert(lilv_path_exists(state_path));
- assert(count_statements(manifest_path) == 3);
- assert(count_statements(state_path) == 21);
-
- lilv_instance_free(instance);
- lilv_dir_for_each(bundle_1_path, NULL, remove_file);
- lilv_remove(bundle_1_path);
- cleanup_test_directories(dirs);
-
- free(state_path);
- free(manifest_path);
- lilv_state_free(state_1);
- free(bundle_1_path);
- test_context_free(ctx);
+ TestContext* const ctx = test_context_new();
+ TestDirectories dirs = create_test_directories();
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+
+ LV2_State_Make_Path make_path = {&dirs, make_scratch_path};
+ LV2_Feature make_path_feature = {LV2_STATE__makePath, &make_path};
+
+ const LV2_Feature* const instance_features[] = {
+ &ctx->map_feature, &ctx->free_path_feature, &make_path_feature, NULL};
+
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, instance_features);
+
+ assert(instance);
+
+ // Get state
+ char* const bundle_1_path = lilv_path_join(dirs.top, "state1.lv2");
+ LilvState* const state_1 =
+ state_from_instance(plugin, instance, ctx, &dirs, bundle_1_path);
+
+ // Save state to a bundle
+ assert(!lilv_state_save(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ state_1,
+ "http://example.org/state1",
+ bundle_1_path,
+ "state.ttl"));
+
+ // Check that a manifest exists
+ char* const manifest_path = lilv_path_join(bundle_1_path, "manifest.ttl");
+ assert(lilv_path_exists(manifest_path));
+
+ // Check that the state file exists
+ char* const state_path = lilv_path_join(bundle_1_path, "state.ttl");
+ assert(lilv_path_exists(state_path));
+
+ // Check that the expected statements are in the files
+ assert(count_statements(manifest_path) == 3);
+ assert(count_statements(state_path) == 21);
+
+ // Save state again to the same bundle
+ assert(!lilv_state_save(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ state_1,
+ "http://example.org/state1",
+ bundle_1_path,
+ "state.ttl"));
+
+ // Check that everything is the same
+ assert(lilv_path_exists(manifest_path));
+ assert(lilv_path_exists(state_path));
+ assert(count_statements(manifest_path) == 3);
+ assert(count_statements(state_path) == 21);
+
+ lilv_instance_free(instance);
+ lilv_dir_for_each(bundle_1_path, NULL, remove_file);
+ lilv_remove(bundle_1_path);
+ cleanup_test_directories(dirs);
+
+ free(state_path);
+ free(manifest_path);
+ lilv_state_free(state_1);
+ free(bundle_1_path);
+ test_context_free(ctx);
}
static void
test_files_round_trip(void)
{
- TestContext* const ctx = test_context_new();
- TestDirectories dirs = create_test_directories();
- const LilvPlugin* const plugin = load_test_plugin(ctx);
-
- LV2_State_Make_Path make_path = {&dirs, make_scratch_path};
- LV2_Feature make_path_feature = {LV2_STATE__makePath, &make_path};
-
- const LV2_Feature* const instance_features[] = {&ctx->map_feature,
- &ctx->free_path_feature,
- &make_path_feature,
- NULL};
-
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, instance_features);
-
- assert(instance);
-
- // Run plugin to generate some recording file data
- lilv_instance_activate(instance);
- lilv_instance_connect_port(instance, 0, &ctx->in);
- lilv_instance_connect_port(instance, 1, &ctx->out);
- lilv_instance_run(instance, 1);
- lilv_instance_run(instance, 2);
- assert(ctx->in == 1.0);
- assert(ctx->out == 1.0);
-
- // Save first state to a bundle
- char* const bundle_1_1_path = lilv_path_join(dirs.top, "state1_1.lv2");
- LilvState* const state_1_1 =
- state_from_instance(plugin, instance, ctx, &dirs, bundle_1_1_path);
-
- assert(!lilv_state_save(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- state_1_1,
- NULL,
- bundle_1_1_path,
- "state.ttl"));
-
- // Save first state to another bundle
- char* const bundle_1_2_path = lilv_path_join(dirs.top, "state1_2.lv2");
- LilvState* const state_1_2 =
- state_from_instance(plugin, instance, ctx, &dirs, bundle_1_2_path);
-
- assert(!lilv_state_save(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- state_1_2,
- NULL,
- bundle_1_2_path,
- "state.ttl"));
-
- // Load both first state bundles and check that the results are equal
- char* const state_1_1_path = lilv_path_join(bundle_1_1_path, "state.ttl");
- char* const state_1_2_path = lilv_path_join(bundle_1_2_path, "state.ttl");
-
- LilvState* state_1_1_loaded = lilv_state_new_from_file(ctx->env->world,
- &ctx->map,
- NULL,
- state_1_1_path);
-
- LilvState* state_1_2_loaded = lilv_state_new_from_file(ctx->env->world,
- &ctx->map,
- NULL,
- state_1_2_path);
-
- assert(state_1_1_loaded);
- assert(state_1_2_loaded);
- assert(lilv_state_equals(state_1_1_loaded, state_1_2_loaded));
-
- // Run plugin again to modify recording file data
- lilv_instance_run(instance, 2);
-
- // Save updated state to a bundle
- char* const bundle_2_path = lilv_path_join(dirs.top, "state2.lv2");
- LilvState* const state_2 =
- state_from_instance(plugin, instance, ctx, &dirs, bundle_2_path);
-
- assert(!lilv_state_save(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- state_2,
- NULL,
- bundle_2_path,
- "state.ttl"));
-
- // Load updated state bundle and check that it differs from the others
- char* const state_2_path = lilv_path_join(bundle_2_path, "state.ttl");
-
- LilvState* state_2_loaded = lilv_state_new_from_file(ctx->env->world,
- &ctx->map,
- NULL,
- state_2_path);
-
- assert(state_2_loaded);
- assert(!lilv_state_equals(state_1_1_loaded, state_2_loaded));
-
- lilv_instance_free(instance);
- lilv_dir_for_each(bundle_1_1_path, NULL, remove_file);
- lilv_dir_for_each(bundle_1_2_path, NULL, remove_file);
- lilv_dir_for_each(bundle_2_path, NULL, remove_file);
- lilv_remove(bundle_1_1_path);
- lilv_remove(bundle_1_2_path);
- lilv_remove(bundle_2_path);
- cleanup_test_directories(dirs);
-
- lilv_state_free(state_2_loaded);
- free(state_2_path);
- lilv_state_free(state_2);
- free(bundle_2_path);
- lilv_state_free(state_1_2_loaded);
- lilv_state_free(state_1_1_loaded);
- free(state_1_2_path);
- free(state_1_1_path);
- lilv_state_free(state_1_2);
- free(bundle_1_2_path);
- lilv_state_free(state_1_1);
- free(bundle_1_1_path);
- test_context_free(ctx);
+ TestContext* const ctx = test_context_new();
+ TestDirectories dirs = create_test_directories();
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+
+ LV2_State_Make_Path make_path = {&dirs, make_scratch_path};
+ LV2_Feature make_path_feature = {LV2_STATE__makePath, &make_path};
+
+ const LV2_Feature* const instance_features[] = {
+ &ctx->map_feature, &ctx->free_path_feature, &make_path_feature, NULL};
+
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, instance_features);
+
+ assert(instance);
+
+ // Run plugin to generate some recording file data
+ lilv_instance_activate(instance);
+ lilv_instance_connect_port(instance, 0, &ctx->in);
+ lilv_instance_connect_port(instance, 1, &ctx->out);
+ lilv_instance_run(instance, 1);
+ lilv_instance_run(instance, 2);
+ assert(ctx->in == 1.0);
+ assert(ctx->out == 1.0);
+
+ // Save first state to a bundle
+ char* const bundle_1_1_path = lilv_path_join(dirs.top, "state1_1.lv2");
+ LilvState* const state_1_1 =
+ state_from_instance(plugin, instance, ctx, &dirs, bundle_1_1_path);
+
+ assert(!lilv_state_save(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ state_1_1,
+ NULL,
+ bundle_1_1_path,
+ "state.ttl"));
+
+ // Save first state to another bundle
+ char* const bundle_1_2_path = lilv_path_join(dirs.top, "state1_2.lv2");
+ LilvState* const state_1_2 =
+ state_from_instance(plugin, instance, ctx, &dirs, bundle_1_2_path);
+
+ assert(!lilv_state_save(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ state_1_2,
+ NULL,
+ bundle_1_2_path,
+ "state.ttl"));
+
+ // Load both first state bundles and check that the results are equal
+ char* const state_1_1_path = lilv_path_join(bundle_1_1_path, "state.ttl");
+ char* const state_1_2_path = lilv_path_join(bundle_1_2_path, "state.ttl");
+
+ LilvState* state_1_1_loaded =
+ lilv_state_new_from_file(ctx->env->world, &ctx->map, NULL, state_1_1_path);
+
+ LilvState* state_1_2_loaded =
+ lilv_state_new_from_file(ctx->env->world, &ctx->map, NULL, state_1_2_path);
+
+ assert(state_1_1_loaded);
+ assert(state_1_2_loaded);
+ assert(lilv_state_equals(state_1_1_loaded, state_1_2_loaded));
+
+ // Run plugin again to modify recording file data
+ lilv_instance_run(instance, 2);
+
+ // Save updated state to a bundle
+ char* const bundle_2_path = lilv_path_join(dirs.top, "state2.lv2");
+ LilvState* const state_2 =
+ state_from_instance(plugin, instance, ctx, &dirs, bundle_2_path);
+
+ assert(!lilv_state_save(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ state_2,
+ NULL,
+ bundle_2_path,
+ "state.ttl"));
+
+ // Load updated state bundle and check that it differs from the others
+ char* const state_2_path = lilv_path_join(bundle_2_path, "state.ttl");
+
+ LilvState* state_2_loaded =
+ lilv_state_new_from_file(ctx->env->world, &ctx->map, NULL, state_2_path);
+
+ assert(state_2_loaded);
+ assert(!lilv_state_equals(state_1_1_loaded, state_2_loaded));
+
+ lilv_instance_free(instance);
+ lilv_dir_for_each(bundle_1_1_path, NULL, remove_file);
+ lilv_dir_for_each(bundle_1_2_path, NULL, remove_file);
+ lilv_dir_for_each(bundle_2_path, NULL, remove_file);
+ lilv_remove(bundle_1_1_path);
+ lilv_remove(bundle_1_2_path);
+ lilv_remove(bundle_2_path);
+ cleanup_test_directories(dirs);
+
+ lilv_state_free(state_2_loaded);
+ free(state_2_path);
+ lilv_state_free(state_2);
+ free(bundle_2_path);
+ lilv_state_free(state_1_2_loaded);
+ lilv_state_free(state_1_1_loaded);
+ free(state_1_2_path);
+ free(state_1_1_path);
+ lilv_state_free(state_1_2);
+ free(bundle_1_2_path);
+ lilv_state_free(state_1_1);
+ free(bundle_1_1_path);
+ test_context_free(ctx);
}
static void
test_world_round_trip(void)
{
- TestContext* const ctx = test_context_new();
- LilvWorld* const world = ctx->env->world;
- TestDirectories dirs = create_test_directories();
- const LilvPlugin* const plugin = load_test_plugin(ctx);
- static const char* const state_uri = "http://example.org/worldState";
-
- LV2_State_Make_Path make_path = {&dirs, make_scratch_path};
- LV2_Feature make_path_feature = {LV2_STATE__makePath, &make_path};
-
- const LV2_Feature* const instance_features[] = {&ctx->map_feature,
- &ctx->free_path_feature,
- &make_path_feature,
- NULL};
-
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, instance_features);
-
- assert(instance);
-
- // Run plugin to generate some recording file data
- lilv_instance_activate(instance);
- lilv_instance_connect_port(instance, 0, &ctx->in);
- lilv_instance_connect_port(instance, 1, &ctx->out);
- lilv_instance_run(instance, 1);
- lilv_instance_run(instance, 2);
- assert(ctx->in == 1.0);
- assert(ctx->out == 1.0);
-
- // Save state to a bundle
- char* const bundle_path = lilv_path_join(dirs.top, "state.lv2/");
- LilvState* const start_state =
- state_from_instance(plugin, instance, ctx, &dirs, bundle_path);
-
- assert(!lilv_state_save(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- start_state,
- state_uri,
- bundle_path,
- "state.ttl"));
-
- // Load state bundle into world
- SerdNode bundle_uri =
- serd_node_new_file_uri((const uint8_t*)bundle_path, 0, 0, true);
- LilvNode* const bundle_node =
- lilv_new_uri(world, (const char*)bundle_uri.buf);
- LilvNode* const state_node = lilv_new_uri(world, state_uri);
- lilv_world_load_bundle(world, bundle_node);
- lilv_world_load_resource(world, state_node);
-
- // Ensure the state loaded from the world matches
- LilvState* const restored =
- lilv_state_new_from_world(world, &ctx->map, state_node);
- assert(lilv_state_equals(start_state, restored));
-
- // Unload state from world
- lilv_world_unload_resource(world, state_node);
- lilv_world_unload_bundle(world, bundle_node);
-
- // Ensure that it is no longer present
- assert(!lilv_state_new_from_world(world, &ctx->map, state_node));
-
- lilv_instance_free(instance);
- lilv_state_delete(world, start_state);
- cleanup_test_directories(dirs);
-
- lilv_state_free(restored);
- lilv_node_free(state_node);
- lilv_node_free(bundle_node);
- serd_node_free(&bundle_uri);
- lilv_state_free(start_state);
- free(bundle_path);
- test_context_free(ctx);
+ TestContext* const ctx = test_context_new();
+ LilvWorld* const world = ctx->env->world;
+ TestDirectories dirs = create_test_directories();
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+ static const char* const state_uri = "http://example.org/worldState";
+
+ LV2_State_Make_Path make_path = {&dirs, make_scratch_path};
+ LV2_Feature make_path_feature = {LV2_STATE__makePath, &make_path};
+
+ const LV2_Feature* const instance_features[] = {
+ &ctx->map_feature, &ctx->free_path_feature, &make_path_feature, NULL};
+
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, instance_features);
+
+ assert(instance);
+
+ // Run plugin to generate some recording file data
+ lilv_instance_activate(instance);
+ lilv_instance_connect_port(instance, 0, &ctx->in);
+ lilv_instance_connect_port(instance, 1, &ctx->out);
+ lilv_instance_run(instance, 1);
+ lilv_instance_run(instance, 2);
+ assert(ctx->in == 1.0);
+ assert(ctx->out == 1.0);
+
+ // Save state to a bundle
+ char* const bundle_path = lilv_path_join(dirs.top, "state.lv2/");
+ LilvState* const start_state =
+ state_from_instance(plugin, instance, ctx, &dirs, bundle_path);
+
+ assert(!lilv_state_save(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ start_state,
+ state_uri,
+ bundle_path,
+ "state.ttl"));
+
+ // Load state bundle into world
+ SerdNode bundle_uri =
+ serd_node_new_file_uri((const uint8_t*)bundle_path, 0, 0, true);
+ LilvNode* const bundle_node =
+ lilv_new_uri(world, (const char*)bundle_uri.buf);
+ LilvNode* const state_node = lilv_new_uri(world, state_uri);
+ lilv_world_load_bundle(world, bundle_node);
+ lilv_world_load_resource(world, state_node);
+
+ // Ensure the state loaded from the world matches
+ LilvState* const restored =
+ lilv_state_new_from_world(world, &ctx->map, state_node);
+ assert(lilv_state_equals(start_state, restored));
+
+ // Unload state from world
+ lilv_world_unload_resource(world, state_node);
+ lilv_world_unload_bundle(world, bundle_node);
+
+ // Ensure that it is no longer present
+ assert(!lilv_state_new_from_world(world, &ctx->map, state_node));
+
+ lilv_instance_free(instance);
+ lilv_state_delete(world, start_state);
+ cleanup_test_directories(dirs);
+
+ lilv_state_free(restored);
+ lilv_node_free(state_node);
+ lilv_node_free(bundle_node);
+ serd_node_free(&bundle_uri);
+ lilv_state_free(start_state);
+ free(bundle_path);
+ test_context_free(ctx);
}
static void
test_label_round_trip(void)
{
- TestContext* const ctx = test_context_new();
- const TestDirectories dirs = create_test_directories();
- const LilvPlugin* const plugin = load_test_plugin(ctx);
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
-
- assert(instance);
-
- // Get initial state
- LilvState* const state =
- state_from_instance(plugin, instance, ctx, &dirs, NULL);
-
- // Set a label
- lilv_state_set_label(state, "Monopoly on violence");
-
- // Save to a bundle
- char* const bundle_path = lilv_path_join(dirs.top, "state.lv2/");
- assert(!lilv_state_save(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- state,
- NULL,
- bundle_path,
- "state.ttl"));
-
- // Load bundle and check the label and that the states are equal
- char* const state_path = lilv_path_join(bundle_path, "state.ttl");
-
- LilvState* const loaded =
- lilv_state_new_from_file(ctx->env->world, &ctx->map, NULL, state_path);
-
- assert(loaded);
- assert(lilv_state_equals(state, loaded));
- assert(!strcmp(lilv_state_get_label(loaded), "Monopoly on violence"));
-
- lilv_instance_free(instance);
- lilv_state_delete(ctx->env->world, state);
- cleanup_test_directories(dirs);
-
- lilv_state_free(loaded);
- free(state_path);
- free(bundle_path);
- lilv_state_free(state);
- test_context_free(ctx);
+ TestContext* const ctx = test_context_new();
+ const TestDirectories dirs = create_test_directories();
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, ctx->features);
+
+ assert(instance);
+
+ // Get initial state
+ LilvState* const state =
+ state_from_instance(plugin, instance, ctx, &dirs, NULL);
+
+ // Set a label
+ lilv_state_set_label(state, "Monopoly on violence");
+
+ // Save to a bundle
+ char* const bundle_path = lilv_path_join(dirs.top, "state.lv2/");
+ assert(!lilv_state_save(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ state,
+ NULL,
+ bundle_path,
+ "state.ttl"));
+
+ // Load bundle and check the label and that the states are equal
+ char* const state_path = lilv_path_join(bundle_path, "state.ttl");
+
+ LilvState* const loaded =
+ lilv_state_new_from_file(ctx->env->world, &ctx->map, NULL, state_path);
+
+ assert(loaded);
+ assert(lilv_state_equals(state, loaded));
+ assert(!strcmp(lilv_state_get_label(loaded), "Monopoly on violence"));
+
+ lilv_instance_free(instance);
+ lilv_state_delete(ctx->env->world, state);
+ cleanup_test_directories(dirs);
+
+ lilv_state_free(loaded);
+ free(state_path);
+ free(bundle_path);
+ lilv_state_free(state);
+ test_context_free(ctx);
}
static void
test_bad_subject(void)
{
- TestContext* const ctx = test_context_new();
- LilvNode* const string = lilv_new_string(ctx->env->world, "Not a URI");
+ TestContext* const ctx = test_context_new();
+ LilvNode* const string = lilv_new_string(ctx->env->world, "Not a URI");
- LilvState* const file_state = lilv_state_new_from_file(ctx->env->world,
- &ctx->map,
- string,
- "/I/do/not/matter");
+ LilvState* const file_state = lilv_state_new_from_file(
+ ctx->env->world, &ctx->map, string, "/I/do/not/matter");
- assert(!file_state);
+ assert(!file_state);
- LilvState* const world_state =
- lilv_state_new_from_world(ctx->env->world, &ctx->map, string);
+ LilvState* const world_state =
+ lilv_state_new_from_world(ctx->env->world, &ctx->map, string);
- assert(!world_state);
+ assert(!world_state);
- lilv_node_free(string);
- test_context_free(ctx);
+ lilv_node_free(string);
+ test_context_free(ctx);
}
static void
count_file(const char* path, const char* name, void* data)
{
- *(unsigned*)data += 1;
+ *(unsigned*)data += 1;
}
static void
test_delete(void)
{
- TestContext* const ctx = test_context_new();
- TestDirectories dirs = create_test_directories();
- const LilvPlugin* const plugin = load_test_plugin(ctx);
-
- LV2_State_Make_Path make_path = {&dirs, make_scratch_path};
- LV2_Feature make_path_feature = {LV2_STATE__makePath, &make_path};
-
- const LV2_Feature* const instance_features[] = {&ctx->map_feature,
- &ctx->free_path_feature,
- &make_path_feature,
- NULL};
-
- LilvInstance* const instance =
- lilv_plugin_instantiate(plugin, 48000.0, instance_features);
-
- assert(instance);
-
- // Run plugin to generate some recording file data
- lilv_instance_activate(instance);
- lilv_instance_connect_port(instance, 0, &ctx->in);
- lilv_instance_connect_port(instance, 1, &ctx->out);
- lilv_instance_run(instance, 1);
- lilv_instance_run(instance, 2);
- assert(ctx->in == 1.0);
- assert(ctx->out == 1.0);
-
- // Save state to a bundle
- char* const bundle_path = lilv_path_join(dirs.top, "state.lv2/");
- LilvState* const state =
- state_from_instance(plugin, instance, ctx, &dirs, bundle_path);
-
- assert(!lilv_state_save(ctx->env->world,
- &ctx->map,
- &ctx->unmap,
- state,
- NULL,
- bundle_path,
- "state.ttl"));
-
- // Count the number of shared files before doing anything
- unsigned n_shared_files_before = 0;
- lilv_dir_for_each(dirs.shared, &n_shared_files_before, count_file);
-
- lilv_instance_free(instance);
-
- // Delete the state
- assert(!lilv_state_delete(ctx->env->world, state));
-
- // Ensure the number of shared files is the same after deletion
- unsigned n_shared_files_after = 0;
- lilv_dir_for_each(dirs.shared, &n_shared_files_after, count_file);
- assert(n_shared_files_before == n_shared_files_after);
-
- // Ensure the state directory has been deleted
- assert(!lilv_path_exists(bundle_path));
-
- cleanup_test_directories(dirs);
-
- lilv_state_free(state);
- free(bundle_path);
- test_context_free(ctx);
+ TestContext* const ctx = test_context_new();
+ TestDirectories dirs = create_test_directories();
+ const LilvPlugin* const plugin = load_test_plugin(ctx);
+
+ LV2_State_Make_Path make_path = {&dirs, make_scratch_path};
+ LV2_Feature make_path_feature = {LV2_STATE__makePath, &make_path};
+
+ const LV2_Feature* const instance_features[] = {
+ &ctx->map_feature, &ctx->free_path_feature, &make_path_feature, NULL};
+
+ LilvInstance* const instance =
+ lilv_plugin_instantiate(plugin, 48000.0, instance_features);
+
+ assert(instance);
+
+ // Run plugin to generate some recording file data
+ lilv_instance_activate(instance);
+ lilv_instance_connect_port(instance, 0, &ctx->in);
+ lilv_instance_connect_port(instance, 1, &ctx->out);
+ lilv_instance_run(instance, 1);
+ lilv_instance_run(instance, 2);
+ assert(ctx->in == 1.0);
+ assert(ctx->out == 1.0);
+
+ // Save state to a bundle
+ char* const bundle_path = lilv_path_join(dirs.top, "state.lv2/");
+ LilvState* const state =
+ state_from_instance(plugin, instance, ctx, &dirs, bundle_path);
+
+ assert(!lilv_state_save(ctx->env->world,
+ &ctx->map,
+ &ctx->unmap,
+ state,
+ NULL,
+ bundle_path,
+ "state.ttl"));
+
+ // Count the number of shared files before doing anything
+ unsigned n_shared_files_before = 0;
+ lilv_dir_for_each(dirs.shared, &n_shared_files_before, count_file);
+
+ lilv_instance_free(instance);
+
+ // Delete the state
+ assert(!lilv_state_delete(ctx->env->world, state));
+
+ // Ensure the number of shared files is the same after deletion
+ unsigned n_shared_files_after = 0;
+ lilv_dir_for_each(dirs.shared, &n_shared_files_after, count_file);
+ assert(n_shared_files_before == n_shared_files_after);
+
+ // Ensure the state directory has been deleted
+ assert(!lilv_path_exists(bundle_path));
+
+ cleanup_test_directories(dirs);
+
+ lilv_state_free(state);
+ free(bundle_path);
+ test_context_free(ctx);
}
int
main(void)
{
- test_instance_state();
- test_equal();
- test_changed_plugin_data();
- test_changed_metadata();
- test_to_string();
- test_string_round_trip();
- test_to_files();
- test_multi_save();
- test_files_round_trip();
- test_world_round_trip();
- test_label_round_trip();
- test_bad_subject();
- test_delete();
-
- return 0;
+ test_instance_state();
+ test_equal();
+ test_changed_plugin_data();
+ test_changed_metadata();
+ test_to_string();
+ test_string_round_trip();
+ test_to_files();
+ test_multi_save();
+ test_files_round_trip();
+ test_world_round_trip();
+ test_label_round_trip();
+ test_bad_subject();
+ test_delete();
+
+ return 0;
}
diff --git a/test/test_string.c b/test/test_string.c
index 9eb2456..e66accf 100644
--- a/test/test_string.c
+++ b/test/test_string.c
@@ -21,9 +21,9 @@
#include "../src/lilv_internal.h"
#ifdef _WIN32
-# include <windows.h>
-# define setenv(n, v, r) SetEnvironmentVariable((n), (v))
-# define unsetenv(n) SetEnvironmentVariable((n), NULL)
+# include <windows.h>
+# define setenv(n, v, r) SetEnvironmentVariable((n), (v))
+# define unsetenv(n) SetEnvironmentVariable((n), NULL)
#endif
#include <assert.h>
@@ -34,23 +34,23 @@ int
main(void)
{
#ifndef _WIN32
- char* s = NULL;
-
- setenv("LILV_TEST_1", "test", 1);
- char* home_foo = lilv_strjoin(getenv("HOME"), "/foo", NULL);
- assert(!strcmp((s = lilv_expand("$LILV_TEST_1")), "test"));
- free(s);
- assert(!strcmp((s = lilv_expand("~")), getenv("HOME")));
- free(s);
- assert(!strcmp((s = lilv_expand("~foo")), "~foo"));
- free(s);
- assert(!strcmp((s = lilv_expand("~/foo")), home_foo));
- free(s);
- assert(!strcmp((s = lilv_expand("$NOT_A_VAR")), "$NOT_A_VAR"));
- free(s);
- free(home_foo);
- unsetenv("LILV_TEST_1");
+ char* s = NULL;
+
+ setenv("LILV_TEST_1", "test", 1);
+ char* home_foo = lilv_strjoin(getenv("HOME"), "/foo", NULL);
+ assert(!strcmp((s = lilv_expand("$LILV_TEST_1")), "test"));
+ free(s);
+ assert(!strcmp((s = lilv_expand("~")), getenv("HOME")));
+ free(s);
+ assert(!strcmp((s = lilv_expand("~foo")), "~foo"));
+ free(s);
+ assert(!strcmp((s = lilv_expand("~/foo")), home_foo));
+ free(s);
+ assert(!strcmp((s = lilv_expand("$NOT_A_VAR")), "$NOT_A_VAR"));
+ free(s);
+ free(home_foo);
+ unsetenv("LILV_TEST_1");
#endif
- return 0;
+ return 0;
}
diff --git a/test/test_ui.c b/test/test_ui.c
index 6230318..032bfbc 100644
--- a/test/test_ui.c
+++ b/test/test_ui.c
@@ -86,95 +86,95 @@ static const char* const plugin_ttl = "\
static unsigned
ui_supported(const char* container_type_uri, const char* ui_type_uri)
{
- return !strcmp(container_type_uri, ui_type_uri);
+ return !strcmp(container_type_uri, ui_type_uri);
}
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(plug);
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* plug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ assert(plug);
- LilvUIs* uis = lilv_plugin_get_uis(plug);
- assert(lilv_uis_size(uis) == 4);
+ LilvUIs* uis = lilv_plugin_get_uis(plug);
+ assert(lilv_uis_size(uis) == 4);
- const LilvUI* ui0 = lilv_uis_get(uis, lilv_uis_begin(uis));
- assert(ui0);
+ const LilvUI* ui0 = lilv_uis_get(uis, lilv_uis_begin(uis));
+ assert(ui0);
- LilvNode* ui_uri = lilv_new_uri(world, "http://example.org/ui");
- LilvNode* ui2_uri = lilv_new_uri(world, "http://example.org/ui3");
- LilvNode* ui3_uri = lilv_new_uri(world, "http://example.org/ui4");
- LilvNode* noui_uri = lilv_new_uri(world, "http://example.org/notaui");
+ LilvNode* ui_uri = lilv_new_uri(world, "http://example.org/ui");
+ LilvNode* ui2_uri = lilv_new_uri(world, "http://example.org/ui3");
+ LilvNode* ui3_uri = lilv_new_uri(world, "http://example.org/ui4");
+ LilvNode* noui_uri = lilv_new_uri(world, "http://example.org/notaui");
- const LilvUI* ui0_2 = lilv_uis_get_by_uri(uis, ui_uri);
- assert(ui0 == ui0_2);
- assert(lilv_node_equals(lilv_ui_get_uri(ui0_2), ui_uri));
+ const LilvUI* ui0_2 = lilv_uis_get_by_uri(uis, ui_uri);
+ assert(ui0 == ui0_2);
+ assert(lilv_node_equals(lilv_ui_get_uri(ui0_2), ui_uri));
- const LilvUI* ui2 = lilv_uis_get_by_uri(uis, ui2_uri);
- assert(ui2 != ui0);
+ const LilvUI* ui2 = lilv_uis_get_by_uri(uis, ui2_uri);
+ assert(ui2 != ui0);
- const LilvUI* ui3 = lilv_uis_get_by_uri(uis, ui3_uri);
- assert(ui3 != ui0);
+ const LilvUI* ui3 = lilv_uis_get_by_uri(uis, ui3_uri);
+ assert(ui3 != ui0);
- const LilvUI* noui = lilv_uis_get_by_uri(uis, noui_uri);
- assert(noui == NULL);
+ const LilvUI* noui = lilv_uis_get_by_uri(uis, noui_uri);
+ assert(noui == NULL);
- const LilvNodes* classes = lilv_ui_get_classes(ui0);
- assert(lilv_nodes_size(classes) == 1);
+ const LilvNodes* classes = lilv_ui_get_classes(ui0);
+ assert(lilv_nodes_size(classes) == 1);
- LilvNode* ui_class_uri =
- lilv_new_uri(world, "http://lv2plug.in/ns/extensions/ui#GtkUI");
+ LilvNode* ui_class_uri =
+ lilv_new_uri(world, "http://lv2plug.in/ns/extensions/ui#GtkUI");
- LilvNode* unknown_ui_class_uri =
- lilv_new_uri(world, "http://example.org/mysteryUI");
+ LilvNode* unknown_ui_class_uri =
+ lilv_new_uri(world, "http://example.org/mysteryUI");
- assert(lilv_node_equals(lilv_nodes_get_first(classes), ui_class_uri));
- assert(lilv_ui_is_a(ui0, ui_class_uri));
+ assert(lilv_node_equals(lilv_nodes_get_first(classes), ui_class_uri));
+ assert(lilv_ui_is_a(ui0, ui_class_uri));
- const LilvNode* ui_type = NULL;
- assert(lilv_ui_is_supported(ui0, ui_supported, ui_class_uri, &ui_type));
- assert(!lilv_ui_is_supported(
- ui0, ui_supported, unknown_ui_class_uri, &ui_type));
- assert(lilv_node_equals(ui_type, ui_class_uri));
+ const LilvNode* ui_type = NULL;
+ assert(lilv_ui_is_supported(ui0, ui_supported, ui_class_uri, &ui_type));
+ assert(
+ !lilv_ui_is_supported(ui0, ui_supported, unknown_ui_class_uri, &ui_type));
+ assert(lilv_node_equals(ui_type, ui_class_uri));
- const LilvNode* plug_bundle_uri = lilv_plugin_get_bundle_uri(plug);
- const LilvNode* ui_bundle_uri = lilv_ui_get_bundle_uri(ui0);
- assert(lilv_node_equals(plug_bundle_uri, ui_bundle_uri));
+ const LilvNode* plug_bundle_uri = lilv_plugin_get_bundle_uri(plug);
+ const LilvNode* ui_bundle_uri = lilv_ui_get_bundle_uri(ui0);
+ assert(lilv_node_equals(plug_bundle_uri, ui_bundle_uri));
- const size_t ui_binary_uri_str_len =
- strlen(lilv_node_as_string(plug_bundle_uri)) + strlen("ui" SHLIB_EXT);
+ const size_t ui_binary_uri_str_len =
+ strlen(lilv_node_as_string(plug_bundle_uri)) + strlen("ui" SHLIB_EXT);
- char* ui_binary_uri_str = (char*)calloc(1, ui_binary_uri_str_len + 1);
- snprintf(ui_binary_uri_str,
- ui_binary_uri_str_len + 1,
- "%s%s",
- lilv_node_as_string(plug_bundle_uri),
- "ui" SHLIB_EXT);
+ char* ui_binary_uri_str = (char*)calloc(1, ui_binary_uri_str_len + 1);
+ snprintf(ui_binary_uri_str,
+ ui_binary_uri_str_len + 1,
+ "%s%s",
+ lilv_node_as_string(plug_bundle_uri),
+ "ui" SHLIB_EXT);
- const LilvNode* ui_binary_uri = lilv_ui_get_binary_uri(ui0);
+ const LilvNode* ui_binary_uri = lilv_ui_get_binary_uri(ui0);
- LilvNode* expected_uri = lilv_new_uri(world, ui_binary_uri_str);
- assert(lilv_node_equals(expected_uri, ui_binary_uri));
+ LilvNode* expected_uri = lilv_new_uri(world, ui_binary_uri_str);
+ assert(lilv_node_equals(expected_uri, ui_binary_uri));
- free(ui_binary_uri_str);
- lilv_node_free(unknown_ui_class_uri);
- lilv_node_free(ui_class_uri);
- lilv_node_free(ui_uri);
- lilv_node_free(ui2_uri);
- lilv_node_free(ui3_uri);
- lilv_node_free(noui_uri);
- lilv_node_free(expected_uri);
- lilv_uis_free(uis);
+ free(ui_binary_uri_str);
+ lilv_node_free(unknown_ui_class_uri);
+ lilv_node_free(ui_class_uri);
+ lilv_node_free(ui_uri);
+ lilv_node_free(ui2_uri);
+ lilv_node_free(ui3_uri);
+ lilv_node_free(noui_uri);
+ lilv_node_free(expected_uri);
+ lilv_uis_free(uis);
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_util.c b/test/test_util.c
index 9055e88..db7eaed 100644
--- a/test/test_util.c
+++ b/test/test_util.c
@@ -19,14 +19,14 @@
#undef NDEBUG
#ifdef _WIN32
-# include "lilv_internal.h"
+# include "lilv_internal.h"
#endif
#include "../src/filesystem.h"
#ifdef _WIN32
-# include <io.h>
-# define mkstemp(pat) _mktemp(pat)
+# include <io.h>
+# define mkstemp(pat) _mktemp(pat)
#endif
#include <assert.h>
@@ -37,31 +37,31 @@
int
main(void)
{
- assert(!lilv_path_canonical(NULL));
+ assert(!lilv_path_canonical(NULL));
- char a_path[16];
- char b_path[16];
- strncpy(a_path, "copy_a_XXXXXX", sizeof(a_path));
- strncpy(b_path, "copy_b_XXXXXX", sizeof(b_path));
- mkstemp(a_path);
- mkstemp(b_path);
+ char a_path[16];
+ char b_path[16];
+ strncpy(a_path, "copy_a_XXXXXX", sizeof(a_path));
+ strncpy(b_path, "copy_b_XXXXXX", sizeof(b_path));
+ mkstemp(a_path);
+ mkstemp(b_path);
- FILE* fa = fopen(a_path, "w");
- FILE* fb = fopen(b_path, "w");
- fprintf(fa, "AA\n");
- fprintf(fb, "AB\n");
- fclose(fa);
- fclose(fb);
+ FILE* fa = fopen(a_path, "w");
+ FILE* fb = fopen(b_path, "w");
+ fprintf(fa, "AA\n");
+ fprintf(fb, "AB\n");
+ fclose(fa);
+ fclose(fb);
- assert(lilv_copy_file("does/not/exist", "copy"));
- assert(lilv_copy_file(a_path, "not/a/dir/copy"));
- assert(!lilv_copy_file(a_path, "copy_c"));
- assert(!lilv_file_equals(a_path, b_path));
- assert(lilv_file_equals(a_path, a_path));
- assert(lilv_file_equals(a_path, "copy_c"));
- assert(!lilv_file_equals("does/not/exist", b_path));
- assert(!lilv_file_equals(a_path, "does/not/exist"));
- assert(!lilv_file_equals("does/not/exist", "/does/not/either"));
+ assert(lilv_copy_file("does/not/exist", "copy"));
+ assert(lilv_copy_file(a_path, "not/a/dir/copy"));
+ assert(!lilv_copy_file(a_path, "copy_c"));
+ assert(!lilv_file_equals(a_path, b_path));
+ assert(lilv_file_equals(a_path, a_path));
+ assert(lilv_file_equals(a_path, "copy_c"));
+ assert(!lilv_file_equals("does/not/exist", b_path));
+ assert(!lilv_file_equals(a_path, "does/not/exist"));
+ assert(!lilv_file_equals("does/not/exist", "/does/not/either"));
- return 0;
+ return 0;
}
diff --git a/test/test_value.c b/test/test_value.c
index a6a1fd0..1b3a63e 100644
--- a/test/test_value.c
+++ b/test/test_value.c
@@ -39,135 +39,135 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
-
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
-
- LilvNode* uval = lilv_new_uri(world, "http://example.org");
- LilvNode* sval = lilv_new_string(world, "Foo");
- LilvNode* ival = lilv_new_int(world, 42);
- LilvNode* fval = lilv_new_float(world, 1.6180f);
-
- assert(lilv_node_is_uri(uval));
- assert(lilv_node_is_string(sval));
- assert(lilv_node_is_int(ival));
- assert(lilv_node_is_float(fval));
-
- assert(!lilv_node_is_literal(NULL));
- assert(!lilv_node_is_literal(uval));
- assert(lilv_node_is_literal(sval));
- assert(lilv_node_is_literal(ival));
- assert(lilv_node_is_literal(fval));
- assert(!lilv_node_get_path(fval, NULL));
-
- assert(!strcmp(lilv_node_as_uri(uval), "http://example.org"));
- assert(!strcmp(lilv_node_as_string(sval), "Foo"));
- assert(lilv_node_as_int(ival) == 42);
- assert(fabs(lilv_node_as_float(fval) - 1.6180) < FLT_EPSILON);
- assert(isnan(lilv_node_as_float(sval)));
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
+
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
+
+ LilvNode* uval = lilv_new_uri(world, "http://example.org");
+ LilvNode* sval = lilv_new_string(world, "Foo");
+ LilvNode* ival = lilv_new_int(world, 42);
+ LilvNode* fval = lilv_new_float(world, 1.6180f);
+
+ assert(lilv_node_is_uri(uval));
+ assert(lilv_node_is_string(sval));
+ assert(lilv_node_is_int(ival));
+ assert(lilv_node_is_float(fval));
+
+ assert(!lilv_node_is_literal(NULL));
+ assert(!lilv_node_is_literal(uval));
+ assert(lilv_node_is_literal(sval));
+ assert(lilv_node_is_literal(ival));
+ assert(lilv_node_is_literal(fval));
+ assert(!lilv_node_get_path(fval, NULL));
+
+ assert(!strcmp(lilv_node_as_uri(uval), "http://example.org"));
+ assert(!strcmp(lilv_node_as_string(sval), "Foo"));
+ assert(lilv_node_as_int(ival) == 42);
+ assert(fabs(lilv_node_as_float(fval) - 1.6180) < FLT_EPSILON);
+ assert(isnan(lilv_node_as_float(sval)));
#if defined(__clang__)
-# pragma clang diagnostic push
-# pragma clang diagnostic ignored "-Wdeprecated-declarations"
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__) && __GNUC__ > 4
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
- assert(!strcmp(lilv_uri_to_path("file:///foo"), "/foo"));
+ assert(!strcmp(lilv_uri_to_path("file:///foo"), "/foo"));
#if defined(__clang__)
-# pragma clang diagnostic pop
+# pragma clang diagnostic pop
#elif defined(__GNUC__) && __GNUC__ > 4
-# pragma GCC diagnostic pop
+# pragma GCC diagnostic pop
#endif
- LilvNode* loc_abs = lilv_new_file_uri(world, NULL, "/foo/bar");
- LilvNode* loc_rel = lilv_new_file_uri(world, NULL, "foo");
- LilvNode* host_abs = lilv_new_file_uri(world, "host", "/foo/bar");
- LilvNode* host_rel = lilv_new_file_uri(world, "host", "foo");
-
- assert(!strcmp(lilv_node_as_uri(loc_abs), "file:///foo/bar"));
- assert(!strncmp(lilv_node_as_uri(loc_rel), "file:///", 8));
- assert(!strcmp(lilv_node_as_uri(host_abs), "file://host/foo/bar"));
- assert(!strncmp(lilv_node_as_uri(host_rel), "file://host/", 12));
-
- lilv_node_free(host_rel);
- lilv_node_free(host_abs);
- lilv_node_free(loc_rel);
- lilv_node_free(loc_abs);
-
- char* tok = lilv_node_get_turtle_token(uval);
- assert(!strcmp(tok, "<http://example.org>"));
- lilv_free(tok);
- tok = lilv_node_get_turtle_token(sval);
- assert(!strcmp(tok, "Foo"));
- lilv_free(tok);
- tok = lilv_node_get_turtle_token(ival);
- assert(!strcmp(tok, "42"));
- lilv_free(tok);
- tok = lilv_node_get_turtle_token(fval);
- assert(!strncmp(tok, "1.6180", 6));
- lilv_free(tok);
-
- LilvNode* uval_e = lilv_new_uri(world, "http://example.org");
- LilvNode* sval_e = lilv_new_string(world, "Foo");
- LilvNode* ival_e = lilv_new_int(world, 42);
- LilvNode* fval_e = lilv_new_float(world, 1.6180f);
- LilvNode* uval_ne = lilv_new_uri(world, "http://no-example.org");
- LilvNode* sval_ne = lilv_new_string(world, "Bar");
- LilvNode* ival_ne = lilv_new_int(world, 24);
- LilvNode* fval_ne = lilv_new_float(world, 3.14159f);
-
- assert(lilv_node_equals(uval, uval_e));
- assert(lilv_node_equals(sval, sval_e));
- assert(lilv_node_equals(ival, ival_e));
- assert(lilv_node_equals(fval, fval_e));
-
- assert(!lilv_node_equals(uval, uval_ne));
- assert(!lilv_node_equals(sval, sval_ne));
- assert(!lilv_node_equals(ival, ival_ne));
- assert(!lilv_node_equals(fval, fval_ne));
-
- assert(!lilv_node_equals(uval, sval));
- assert(!lilv_node_equals(sval, ival));
- assert(!lilv_node_equals(ival, fval));
-
- LilvNode* uval_dup = lilv_node_duplicate(uval);
- assert(lilv_node_equals(uval, uval_dup));
-
- LilvNode* ifval = lilv_new_float(world, 42.0);
- assert(!lilv_node_equals(ival, ifval));
- lilv_node_free(ifval);
-
- LilvNode* nil = NULL;
- assert(!lilv_node_equals(uval, nil));
- assert(!lilv_node_equals(nil, uval));
- assert(lilv_node_equals(nil, nil));
-
- LilvNode* nil2 = lilv_node_duplicate(nil);
- assert(lilv_node_equals(nil, nil2));
-
- lilv_node_free(uval);
- lilv_node_free(sval);
- lilv_node_free(ival);
- lilv_node_free(fval);
- lilv_node_free(uval_e);
- lilv_node_free(sval_e);
- lilv_node_free(ival_e);
- lilv_node_free(fval_e);
- lilv_node_free(uval_ne);
- lilv_node_free(sval_ne);
- lilv_node_free(ival_ne);
- lilv_node_free(fval_ne);
- lilv_node_free(uval_dup);
- lilv_node_free(nil2);
-
- delete_bundle(env);
- lilv_test_env_free(env);
-
- return 0;
+ LilvNode* loc_abs = lilv_new_file_uri(world, NULL, "/foo/bar");
+ LilvNode* loc_rel = lilv_new_file_uri(world, NULL, "foo");
+ LilvNode* host_abs = lilv_new_file_uri(world, "host", "/foo/bar");
+ LilvNode* host_rel = lilv_new_file_uri(world, "host", "foo");
+
+ assert(!strcmp(lilv_node_as_uri(loc_abs), "file:///foo/bar"));
+ assert(!strncmp(lilv_node_as_uri(loc_rel), "file:///", 8));
+ assert(!strcmp(lilv_node_as_uri(host_abs), "file://host/foo/bar"));
+ assert(!strncmp(lilv_node_as_uri(host_rel), "file://host/", 12));
+
+ lilv_node_free(host_rel);
+ lilv_node_free(host_abs);
+ lilv_node_free(loc_rel);
+ lilv_node_free(loc_abs);
+
+ char* tok = lilv_node_get_turtle_token(uval);
+ assert(!strcmp(tok, "<http://example.org>"));
+ lilv_free(tok);
+ tok = lilv_node_get_turtle_token(sval);
+ assert(!strcmp(tok, "Foo"));
+ lilv_free(tok);
+ tok = lilv_node_get_turtle_token(ival);
+ assert(!strcmp(tok, "42"));
+ lilv_free(tok);
+ tok = lilv_node_get_turtle_token(fval);
+ assert(!strncmp(tok, "1.6180", 6));
+ lilv_free(tok);
+
+ LilvNode* uval_e = lilv_new_uri(world, "http://example.org");
+ LilvNode* sval_e = lilv_new_string(world, "Foo");
+ LilvNode* ival_e = lilv_new_int(world, 42);
+ LilvNode* fval_e = lilv_new_float(world, 1.6180f);
+ LilvNode* uval_ne = lilv_new_uri(world, "http://no-example.org");
+ LilvNode* sval_ne = lilv_new_string(world, "Bar");
+ LilvNode* ival_ne = lilv_new_int(world, 24);
+ LilvNode* fval_ne = lilv_new_float(world, 3.14159f);
+
+ assert(lilv_node_equals(uval, uval_e));
+ assert(lilv_node_equals(sval, sval_e));
+ assert(lilv_node_equals(ival, ival_e));
+ assert(lilv_node_equals(fval, fval_e));
+
+ assert(!lilv_node_equals(uval, uval_ne));
+ assert(!lilv_node_equals(sval, sval_ne));
+ assert(!lilv_node_equals(ival, ival_ne));
+ assert(!lilv_node_equals(fval, fval_ne));
+
+ assert(!lilv_node_equals(uval, sval));
+ assert(!lilv_node_equals(sval, ival));
+ assert(!lilv_node_equals(ival, fval));
+
+ LilvNode* uval_dup = lilv_node_duplicate(uval);
+ assert(lilv_node_equals(uval, uval_dup));
+
+ LilvNode* ifval = lilv_new_float(world, 42.0);
+ assert(!lilv_node_equals(ival, ifval));
+ lilv_node_free(ifval);
+
+ LilvNode* nil = NULL;
+ assert(!lilv_node_equals(uval, nil));
+ assert(!lilv_node_equals(nil, uval));
+ assert(lilv_node_equals(nil, nil));
+
+ LilvNode* nil2 = lilv_node_duplicate(nil);
+ assert(lilv_node_equals(nil, nil2));
+
+ lilv_node_free(uval);
+ lilv_node_free(sval);
+ lilv_node_free(ival);
+ lilv_node_free(fval);
+ lilv_node_free(uval_e);
+ lilv_node_free(sval_e);
+ lilv_node_free(ival_e);
+ lilv_node_free(fval_e);
+ lilv_node_free(uval_ne);
+ lilv_node_free(sval_ne);
+ lilv_node_free(ival_ne);
+ lilv_node_free(fval_ne);
+ lilv_node_free(uval_dup);
+ lilv_node_free(nil2);
+
+ delete_bundle(env);
+ lilv_test_env_free(env);
+
+ return 0;
}
diff --git a/test/test_verify.c b/test/test_verify.c
index dd88ba5..bce2919 100644
--- a/test/test_verify.c
+++ b/test/test_verify.c
@@ -36,22 +36,21 @@ static const char* const plugin_ttl = "\
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
- return 1;
- }
+ if (start_bundle(env, SIMPLE_MANIFEST_TTL, plugin_ttl)) {
+ return 1;
+ }
- const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
- const LilvPlugin* explug =
- lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
+ const LilvPlugins* plugins = lilv_world_get_all_plugins(world);
+ const LilvPlugin* explug = lilv_plugins_get_by_uri(plugins, env->plugin1_uri);
- assert(explug);
- assert(lilv_plugin_verify(explug));
+ assert(explug);
+ assert(lilv_plugin_verify(explug));
- delete_bundle(env);
- lilv_test_env_free(env);
+ delete_bundle(env);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}
diff --git a/test/test_world.c b/test/test_world.c
index b8572d2..57518ca 100644
--- a/test/test_world.c
+++ b/test/test_world.c
@@ -26,26 +26,26 @@
int
main(void)
{
- LilvTestEnv* const env = lilv_test_env_new();
- LilvWorld* const world = env->world;
+ LilvTestEnv* const env = lilv_test_env_new();
+ LilvWorld* const world = env->world;
- LilvNode* num = lilv_new_int(env->world, 4);
- LilvNode* uri = lilv_new_uri(env->world, "http://example.org/object");
+ LilvNode* num = lilv_new_int(env->world, 4);
+ LilvNode* uri = lilv_new_uri(env->world, "http://example.org/object");
- LilvNodes* matches = lilv_world_find_nodes(world, num, NULL, NULL);
- assert(!matches);
+ LilvNodes* matches = lilv_world_find_nodes(world, num, NULL, NULL);
+ assert(!matches);
- matches = lilv_world_find_nodes(world, NULL, num, NULL);
- assert(!matches);
+ matches = lilv_world_find_nodes(world, NULL, num, NULL);
+ assert(!matches);
- matches = lilv_world_find_nodes(world, NULL, uri, NULL);
- assert(!matches);
+ matches = lilv_world_find_nodes(world, NULL, uri, NULL);
+ assert(!matches);
- lilv_node_free(uri);
- lilv_node_free(num);
+ lilv_node_free(uri);
+ lilv_node_free(num);
- lilv_world_unload_bundle(world, NULL);
- lilv_test_env_free(env);
+ lilv_world_unload_bundle(world, NULL);
+ lilv_test_env_free(env);
- return 0;
+ return 0;
}