From bf23b9f975ec97d20ba6381f2457e7b7d6ec0369 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 2 Feb 2013 20:14:05 +0000 Subject: Require a URI for lilv_state_to_string() and fail gracefully otherwise. Fail gracefully when lilv_state_new_from_string() is called on NULL. Fixes #865. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@5030 a436a847-0d15-0410-975c-d299462d15a1 --- test/lilv_test.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/lilv_test.c') diff --git a/test/lilv_test.c b/test/lilv_test.c index f6976f6..0033885 100644 --- a/test/lilv_test.c +++ b/test/lilv_test.c @@ -1227,6 +1227,15 @@ test_state(void) // Ensure they are equal TEST_ASSERT(lilv_state_equals(state, state2)); + // Check that we can't save a state with no URI + char* bad_state_str = lilv_state_to_string( + world, &map, &unmap, state, NULL, NULL); + TEST_ASSERT(!bad_state_str); + + // Check that we can't restore the NULL string (and it doesn't crash) + LilvState* bad_state = lilv_state_new_from_string(world, &map, NULL); + TEST_ASSERT(!bad_state); + // Save state to a string char* state1_str = lilv_state_to_string( world, &map, &unmap, state, "http://example.org/state1", NULL); -- cgit v1.2.1