From c8a89182621aebc9ce5cf65d72a64d08f118fc1b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 13 Dec 2008 19:50:44 +0000 Subject: Test querying for float values. Fix slv2_plugin_get_value_for_subject test. git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@1868 a436a847-0d15-0410-975c-d299462d15a1 --- ChangeLog | 3 ++- src/plugin.c | 6 +++--- src/query.c | 5 +++-- test/slv2_test.c | 17 ++++++++++++++--- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9b9194..4f771c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,8 @@ slv2 (0.6.3) unstable; urgency=low * Fix illegal output of slv2_value_get_turtle_token for floats. * Fix slv2_plugin_get_value_for_subject - * Add test suite + * Add test suite and coverage instrumentation + * Upgrade to waf 1.5.1 -- Dave Robillard Sat, 13 Dec 2008 14:13:43 -0500 diff --git a/src/plugin.c b/src/plugin.c index 7b5845b..6593029 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -470,9 +470,9 @@ slv2_plugin_get_value_by_qname_i18n(SLV2Plugin p, SLV2Values -slv2_plugin_get_value_for_subject(SLV2Plugin p, - SLV2Value subject, - SLV2Value predicate) +slv2_plugin_get_value_for_subject(SLV2Plugin p, + SLV2Value subject, + SLV2Value predicate) { if ( ! slv2_value_is_uri(subject)) { fprintf(stderr, "slv2_plugin_get_value_for_subject error: " diff --git a/src/query.c b/src/query.c index f4a6a0d..f32c4e0 100644 --- a/src/query.c +++ b/src/query.c @@ -53,7 +53,7 @@ slv2_query_get_variable_bindings(SLV2World world, librdf_node* node = librdf_query_results_get_binding_value(results, variable); - if (!node) { + if (node == NULL) { fprintf(stderr, "SLV2 ERROR: Variable %d bound to NULL.\n", variable); librdf_query_results_next(results); continue; @@ -168,7 +168,8 @@ slv2_plugin_query_variable(SLV2Plugin plugin, librdf_query_results* results = slv2_plugin_query(plugin, sparql_str); - SLV2Values ret = slv2_query_get_variable_bindings(plugin->world, results, (int)variable); + SLV2Values ret = slv2_query_get_variable_bindings(plugin->world, + results, (int)variable); librdf_free_query_results(results); diff --git a/test/slv2_test.c b/test/slv2_test.c index 8484961..7a2abc6 100644 --- a/test/slv2_test.c +++ b/test/slv2_test.c @@ -574,6 +574,7 @@ test_plugin() LICENSE_GPL " ; " "lv2:optionalFeature lv2:hardRtCapable ; " "lv2:requiredFeature ; " + ":foo 1.6180 ; " "doap:maintainer [ foaf:name \"David Robillard\" ; " " foaf:homepage ; foaf:mbox ] ; " "lv2:port [ " @@ -669,6 +670,13 @@ test_plugin() TEST_ASSERT(slv2_values_size(supported) == 2); TEST_ASSERT(slv2_values_size(required) == 1); TEST_ASSERT(slv2_values_size(optional) == 1); + + SLV2Value foo_p = slv2_value_new_uri(world, "http://example.org/foo"); + SLV2Values foos = slv2_plugin_get_value(plug, foo_p); + TEST_ASSERT(slv2_values_size(foos) == 1); + TEST_ASSERT(fabs(slv2_value_as_float(slv2_values_get_at(foos, 0)) - 1.6180) < FLT_EPSILON); + slv2_value_free(foo_p); + slv2_values_free(foos); SLV2Value author_name = slv2_plugin_get_author_name(plug); TEST_ASSERT(!strcmp(slv2_value_as_string(author_name), "David Robillard")); @@ -684,12 +692,15 @@ test_plugin() SLV2Value thing_uri = slv2_value_new_uri(world, "http://example.org/thing"); SLV2Value name_p = slv2_value_new_uri(world, "http://usefulinc.com/ns/doap#name"); - SLV2Value thing_name = slv2_plugin_get_value_for_subject(plug, thing_uri, name_p); - //TEST_ASSERT(!strcmp(slv2_value_as_string(thing_name), "Something else")); + SLV2Values thing_names = slv2_plugin_get_value_for_subject(plug, thing_uri, name_p); + TEST_ASSERT(slv2_values_size(thing_names) == 1); + SLV2Value thing_name = slv2_values_get_at(thing_names, 0); + TEST_ASSERT(thing_name); + TEST_ASSERT(slv2_value_is_string(thing_name)); + TEST_ASSERT(!strcmp(slv2_value_as_string(thing_name), "Something else")); slv2_value_free(thing_uri); slv2_value_free(name_p); - //slv2_value_free(thing_name); slv2_value_free(control_class); slv2_value_free(audio_class); slv2_value_free(in_class); -- cgit v1.2.1