1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
// Copyright 2007-2025 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
#undef NDEBUG
#include "lilv_test_utils.h"
#include <lilv/lilv.h>
#include <assert.h>
#include <stddef.h>
static void
test_set_option(void)
{
LilvTestEnv* const env = lilv_test_env_new();
LilvNode* const not_leaked = lilv_new_string(env->world, "/not/leaked");
LilvNode* const new_path = lilv_new_string(env->world, "/new/path");
lilv_world_set_option(env->world, LILV_OPTION_LV2_PATH, not_leaked);
// Rely on sanitizers to catch a potential memory leak here
lilv_world_set_option(env->world, LILV_OPTION_LV2_PATH, new_path);
lilv_node_free(new_path);
lilv_node_free(not_leaked);
lilv_test_env_free(env);
}
static void
test_load_plugin_classes(void)
{
LilvTestEnv* const env = lilv_test_env_new();
lilv_world_load_all(env->world);
// Rely on sanitizers to catch a potential memory leak here
lilv_world_load_plugin_classes(env->world);
lilv_test_env_free(env);
}
static void
test_search(void)
{
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");
const 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, uri, NULL);
assert(!matches);
lilv_node_free(uri);
lilv_node_free(num);
lilv_world_unload_bundle(world, NULL);
lilv_test_env_free(env);
}
int
main(void)
{
test_set_option();
test_load_plugin_classes();
test_search();
}
|