diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lilv_test_uri_map.h | 6 | ||||
-rw-r--r-- | test/lilv_test_utils.c | 13 | ||||
-rw-r--r-- | test/lilv_test_utils.h | 4 | ||||
-rw-r--r-- | test/test_plugin.c | 6 | ||||
-rw-r--r-- | test/test_replace_version.c | 6 | ||||
-rw-r--r-- | test/test_string.c | 4 |
6 files changed, 27 insertions, 12 deletions
diff --git a/test/lilv_test_uri_map.h b/test/lilv_test_uri_map.h index b4fba0f..d7f3e20 100644 --- a/test/lilv_test_uri_map.h +++ b/test/lilv_test_uri_map.h @@ -4,8 +4,6 @@ #ifndef LILV_TEST_URI_MAP_H #define LILV_TEST_URI_MAP_H -#include "../src/lilv_internal.h" - #include "lv2/urid/urid.h" #include "serd/serd.h" @@ -49,10 +47,12 @@ map_uri(LV2_URID_Map_Handle handle, const char* uri) } } + const size_t uri_len = strlen(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); + map->uris[map->n_uris - 1] = calloc(1, uri_len + 1); + memcpy(map->uris[map->n_uris - 1], uri, uri_len + 1); return map->n_uris; } diff --git a/test/lilv_test_utils.c b/test/lilv_test_utils.c index c3c47f0..3063449 100644 --- a/test/lilv_test_utils.c +++ b/test/lilv_test_utils.c @@ -189,3 +189,16 @@ lilv_create_temporary_directory(const char* pattern) return result; } + +char* +string_concat(const char* const head, const char* const tail) +{ + const size_t head_len = strlen(head); + const size_t tail_len = strlen(tail); + char* const result = (char*)calloc(1U, head_len + tail_len + 1U); + if (result) { + memcpy(result, head, head_len + 1U); + memcpy(result + head_len, tail, tail_len + 1U); + } + return result; +} diff --git a/test/lilv_test_utils.h b/test/lilv_test_utils.h index 73ee2ba..a389959 100644 --- a/test/lilv_test_utils.h +++ b/test/lilv_test_utils.h @@ -85,4 +85,8 @@ ZIX_MALLOC_FUNC char* lilv_create_temporary_directory(const char* pattern); +// Return a new string that is a concatenation of two given strings +char* +string_concat(const char* head, const char* tail); + #endif // LILV_TEST_UTILS_H diff --git a/test/test_plugin.c b/test/test_plugin.c index 32e356b..2652159 100644 --- a/test/test_plugin.c +++ b/test/test_plugin.c @@ -5,8 +5,6 @@ #include "lilv_test_utils.h" -#include "../src/lilv_internal.h" - #include "lilv/lilv.h" #include <assert.h> @@ -105,10 +103,10 @@ main(void) assert(!project); char* manifest_uri = - lilv_strjoin(lilv_node_as_string(plug_bundle_uri), "manifest.ttl", NULL); + string_concat(lilv_node_as_string(plug_bundle_uri), "manifest.ttl"); char* data_uri = - lilv_strjoin(lilv_node_as_string(plug_bundle_uri), "plugin.ttl", NULL); + string_concat(lilv_node_as_string(plug_bundle_uri), "plugin.ttl"); LilvNode* manifest_uri_val = lilv_new_uri(world, manifest_uri); assert(lilv_nodes_contains(data_uris, manifest_uri_val)); diff --git a/test/test_replace_version.c b/test/test_replace_version.c index c6fb3e6..dc2a75f 100644 --- a/test/test_replace_version.c +++ b/test/test_replace_version.c @@ -5,8 +5,6 @@ #include "lilv_test_utils.h" -#include "../src/lilv_internal.h" - #include "lilv/lilv.h" #include "lv2/core/lv2.h" @@ -26,7 +24,7 @@ main(void) LilvNode* minor = NULL; LilvNode* micro = NULL; - char* old_bundle_path = lilv_strjoin(LILV_TEST_DIR, "old_version.lv2/", 0); + char* old_bundle_path = string_concat(LILV_TEST_DIR, "old_version.lv2/"); // Load plugin from old bundle LilvNode* old_bundle = lilv_new_file_uri(world, NULL, old_bundle_path); @@ -44,7 +42,7 @@ main(void) lilv_node_free(micro); lilv_node_free(minor); - char* new_bundle_path = lilv_strjoin(LILV_TEST_DIR, "new_version.lv2/", 0); + char* new_bundle_path = string_concat(LILV_TEST_DIR, "new_version.lv2/"); // Load plugin from new bundle LilvNode* new_bundle = lilv_new_file_uri(world, NULL, new_bundle_path); diff --git a/test/test_string.c b/test/test_string.c index 1ed387c..e20669d 100644 --- a/test/test_string.c +++ b/test/test_string.c @@ -3,6 +3,8 @@ #undef NDEBUG +#include "lilv_test_utils.h" + #include "../src/lilv_internal.h" #ifdef _WIN32 @@ -36,7 +38,7 @@ main(void) check_expansion("$LILV_TEST_1", "test"); if (home) { - char* const home_foo = lilv_strjoin(home, "/foo", NULL); + char* const home_foo = string_concat(home, "/foo"); check_expansion("~", home); check_expansion("~foo", "~foo"); check_expansion("~/foo", home_foo); |