diff options
author | David Robillard <d@drobilla.net> | 2012-01-04 19:21:12 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-01-04 19:21:12 +0000 |
commit | 7823f743ee0c748ff4ced56838cd737516d857ab (patch) | |
tree | 083bcfd6edb27c53aa217da644f650e86f270070 /test/lilv_test.c | |
parent | 2f71e8570bcd37ad681bde7d51c433701a0028ab (diff) | |
download | lilv-7823f743ee0c748ff4ced56838cd737516d857ab.tar.gz lilv-7823f743ee0c748ff4ced56838cd737516d857ab.tar.bz2 lilv-7823f743ee0c748ff4ced56838cd737516d857ab.zip |
Implement proper support for LV2_STATE_BUNDLE.
Test saving state to default bundle path.
Fix memory leaks.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3915 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'test/lilv_test.c')
-rw-r--r-- | test/lilv_test.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/lilv_test.c b/test/lilv_test.c index 6751be4..0a8a226 100644 --- a/test/lilv_test.c +++ b/test/lilv_test.c @@ -1140,15 +1140,49 @@ test_state(void) // Load state from file LilvState* state5 = lilv_state_new_from_file(world, &map, NULL, "state.ttl"); TEST_ASSERT(lilv_state_equals(state, state5)); // Round trip accuracy + + // Save state to default bundle + setenv("LV2_STATE_BUNDLE", "lv2/lilv-test-state.lv2", 1); + const char* state_uri = "http://example.org/test-state"; + ret = lilv_state_save(world, &unmap, state, state_uri, NULL, NULL); + TEST_ASSERT(!ret); + + // Load default bundle into world and load state from it + LilvNode* test_state_bundle = lilv_new_uri(world, "lv2/lilv-test-state.lv2/"); + LilvNode* test_state_node = lilv_new_uri(world, state_uri); + lilv_world_load_bundle(world, test_state_bundle); + lilv_world_load_resource(world, test_state_node); + + LilvState* state6 = lilv_state_new_from_world(world, &map, test_state_node); + TEST_ASSERT(lilv_state_equals(state, state6)); // Round trip accuracy + unsetenv("LV2_STATE_BUNDLE"); + + LilvNode* num = lilv_new_int(world, 5); + LilvState* nostate = lilv_state_new_from_file(world, &map, num, "/junk"); + TEST_ASSERT(!nostate); + + lilv_node_free(num); + lilv_node_free(test_state_bundle); + lilv_node_free(test_state_node); + lilv_state_free(state); lilv_state_free(state2); lilv_state_free(state3); lilv_state_free(state4); lilv_state_free(state5); + lilv_state_free(state6); + + // Free URI map + for (size_t i = 0; i < n_uris; ++i) { + free(uris[i]); + } + free(uris); + n_uris = 0; lilv_instance_free(instance); + lilv_node_free(plugin_uri); lilv_node_free(bundle_uri); lilv_world_free(world); |