summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-12-13 19:10:20 +0000
committerDavid Robillard <d@drobilla.net>2008-12-13 19:10:20 +0000
commit295faf6ffa2df8adc0a78f12906d2f9e1595641e (patch)
tree2b6f143ce5cb7bc7c7e189eb054c3e65009477fc
parentedbffff51f8769c58b977e6d860501928d234f80 (diff)
downloadlilv-295faf6ffa2df8adc0a78f12906d2f9e1595641e.tar.gz
lilv-295faf6ffa2df8adc0a78f12906d2f9e1595641e.tar.bz2
lilv-295faf6ffa2df8adc0a78f12906d2f9e1595641e.zip
Test (and fix) slv2_plugin_get_value_for_subject: 94.3% coverage
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@1867 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--ChangeLog4
-rw-r--r--src/plugin.c22
-rw-r--r--test/slv2_test.c11
3 files changed, 24 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 11abe18..c9b9194 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,10 @@
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
- -- Dave Robillard <dave@drobilla.net> Fri, 12 Dec 2008 23:23:47 -0500
+ -- Dave Robillard <dave@drobilla.net> Sat, 13 Dec 2008 14:13:43 -0500
slv2 (0.6.2) unstable; urgency=high
diff --git a/src/plugin.c b/src/plugin.c
index 0260a02..7b5845b 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -409,14 +409,14 @@ slv2_plugin_get_value(SLV2Plugin p,
if (predicate->type == SLV2_VALUE_URI) {
query = slv2_strjoin(
- "PREFIX slv2predicate: <", slv2_value_as_string(predicate), ">",
- "SELECT DISTINCT ?value WHERE { \n"
- "<> slv2predicate: ?value \n"
+ "PREFIX slv2predicate: <", slv2_value_as_string(predicate), ">\n",
+ "SELECT DISTINCT ?value WHERE {\n"
+ "<> slv2predicate: ?value .\n"
"}\n", NULL);
} else if (predicate->type == SLV2_VALUE_QNAME) {
query = slv2_strjoin(
- "SELECT DISTINCT ?value WHERE { \n"
- "<> ", slv2_value_as_string(predicate), " ?value \n"
+ "SELECT DISTINCT ?value WHERE {\n"
+ "<> ", slv2_value_as_string(predicate), " ?value .\n"
"}\n", NULL);
} else {
fprintf(stderr, "slv2_plugin_get_value error: "
@@ -488,14 +488,14 @@ slv2_plugin_get_value_for_subject(SLV2Plugin p,
if (predicate->type == SLV2_VALUE_URI) {
query = slv2_strjoin(
- "PREFIX slv2predicate: <", predicate, ">",
- "SELECT DISTINCT ?value WHERE { \n",
- subject_token, " slv2predicate: ?value \n"
+ "PREFIX slv2predicate: <", slv2_value_as_string(predicate), ">\n",
+ "SELECT DISTINCT ?value WHERE {\n",
+ subject_token, " slv2predicate: ?value .\n"
"}\n", NULL);
- } else if (predicate->type == SLV2_VALUE_URI) {
+ } else if (predicate->type == SLV2_VALUE_QNAME) {
query = slv2_strjoin(
- "SELECT DISTINCT ?value WHERE { \n",
- subject_token, " ", predicate, " ?value \n"
+ "SELECT DISTINCT ?value WHERE {\n",
+ subject_token, " ", slv2_value_as_string(predicate), " ?value .\n"
"}\n", NULL);
} else {
fprintf(stderr, "slv2_plugin_get_value error: "
diff --git a/test/slv2_test.c b/test/slv2_test.c
index d3324df..8484961 100644
--- a/test/slv2_test.c
+++ b/test/slv2_test.c
@@ -588,7 +588,8 @@ test_plugin()
" a lv2:ControlPort ; a lv2:OutputPort ; "
" lv2:index 2 ; lv2:symbol \"latency\" ; lv2:name \"Latency\" ; "
" lv2:portProperty lv2:reportsLatency "
- "] .",
+ "] . \n"
+ ":thing doap:name \"Something else\" .\n",
1))
return 0;
@@ -681,6 +682,14 @@ test_plugin()
TEST_ASSERT(!strcmp(slv2_value_as_string(author_homepage), "http://drobilla.net"));
slv2_value_free(author_homepage);
+ 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"));
+
+ 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);