[tracker/harmattan: 1904/2240] Add tests for sparql functions



commit 05a87a8a63ce323acc632a979061f1ba99da826f
Author: Mikael Ottela <mikael ottela ixonos com>
Date:   Fri Dec 18 00:57:53 2009 +0200

    Add tests for sparql functions

 configure.ac                                       |    1 +
 tests/libtracker-data/Makefile.am                  |    1 +
 tests/libtracker-data/functions/Makefile.am        |   13 ++++++
 tests/libtracker-data/functions/data-1.ontology    |   39 +++++++++++++++++
 tests/libtracker-data/functions/data-1.ttl         |   46 ++++++++++++++++++++
 .../functions/functions-property-1.out             |    7 +++
 .../functions/functions-property-1.rq              |    8 +++
 .../functions/functions-tracker-1.out              |    7 +++
 .../functions/functions-tracker-1.rq               |   10 ++++
 .../functions/functions-xpath-1.out                |    4 ++
 .../libtracker-data/functions/functions-xpath-1.rq |    7 +++
 .../functions/functions-xpath-2.out                |    1 +
 .../libtracker-data/functions/functions-xpath-2.rq |    7 +++
 tests/libtracker-data/tracker-sparql-test.c        |    5 ++
 14 files changed, 156 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index eb2cfca..e037308 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1693,6 +1693,7 @@ AC_CONFIG_FILES([
 	tests/libtracker-data/bnode-coreference/Makefile
 	tests/libtracker-data/bound/Makefile
 	tests/libtracker-data/expr-ops/Makefile
+	tests/libtracker-data/functions/Makefile
 	tests/libtracker-data/nie/Makefile
 	tests/libtracker-data/nmo/Makefile
 	tests/libtracker-data/optional/Makefile
diff --git a/tests/libtracker-data/Makefile.am b/tests/libtracker-data/Makefile.am
index 18cac27..8146c12 100644
--- a/tests/libtracker-data/Makefile.am
+++ b/tests/libtracker-data/Makefile.am
@@ -6,6 +6,7 @@ SUBDIRS = 			\
 	bnode-coreference	\
 	bound 			\
 	expr-ops		\
+	functions		\
 	nie			\
 	nmo			\
 	optional		\
diff --git a/tests/libtracker-data/functions/Makefile.am b/tests/libtracker-data/functions/Makefile.am
new file mode 100644
index 0000000..1548615
--- /dev/null
+++ b/tests/libtracker-data/functions/Makefile.am
@@ -0,0 +1,13 @@
+include $(top_srcdir)/Makefile.decl
+
+EXTRA_DIST = 				\
+	data-1.ontology			\
+	data-1.ttl			\
+	functions-property-1.out	\
+	functions-property-1.rq		\
+	functions-tracker-1.out		\
+	functions-tracker-1.rq		\
+	functions-xpath-1.out		\
+	functions-xpath-1.rq		\
+	functions-xpath-1.out		\
+	functions-xpath-1.rq
diff --git a/tests/libtracker-data/functions/data-1.ontology b/tests/libtracker-data/functions/data-1.ontology
new file mode 100644
index 0000000..5ed05fc
--- /dev/null
+++ b/tests/libtracker-data/functions/data-1.ontology
@@ -0,0 +1,39 @@
+ prefix example: <http://example/> .
+ prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+ prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+ prefix tracker: <http://www.tracker-project.org/ontologies/tracker#> .
+ prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+ prefix ns: <http://www.w3.org/2005/xpath-functions#> .
+
+example: a tracker:Namespace ;
+	tracker:prefix "example" .
+
+example:A a rdfs:Class ;
+	rdfs:subClassOf rdfs:Resource .
+
+example:B a rdfs:Class ;
+	rdfs:subClassOf rdfs:Resource .
+
+example:s a rdf:Property ;
+	rdfs:domain example:A ;
+	rdfs:range xsd:string .
+
+example:t a rdf:Property ;
+	rdfs:domain example:A ;
+	rdfs:range xsd:string .
+
+example:u a rdf:Property ;
+	rdfs:domain example:A ;
+	rdfs:range xsd:string .
+
+example:i a rdf:Property ;
+	rdfs:domain example:A ;
+	rdfs:range xsd:integer .
+
+example:o a rdf:Property ;
+	rdfs:domain example:B ;
+	rdfs:range xsd:string .
+
+example:a a rdf:Property ;
+	rdfs:domain example:B ;
+	rdfs:range example:A .
diff --git a/tests/libtracker-data/functions/data-1.ttl b/tests/libtracker-data/functions/data-1.ttl
new file mode 100644
index 0000000..2722076
--- /dev/null
+++ b/tests/libtracker-data/functions/data-1.ttl
@@ -0,0 +1,46 @@
+ prefix : <http://example/> .
+ prefix xsd:        <http://www.w3.org/2001/XMLSchema#> .
+
+:x a :A .
+:x :s "first" .
+:x :t "Test" .
+:x :u "optional" .
+
+:y a :A .
+:y :s "second" .
+:y :t "Text" .
+
+:z a :A .
+:z :s "third" .
+:z :t "for" .
+:z :u "optional for third" .
+
+:q a :A .
+:q :s "fourth" .
+:q :t "testing" .
+
+:w a :A .
+:w :s "fifth" .
+:w :t "purposes" .
+
+:e a :A .
+:e :s "other" .
+
+:r a :A .
+
+:ba a :B .
+:ba :o "First group" .
+:ba :a :x .
+:ba :a :y .
+:ba :a :z .
+:ba :a :e .
+
+:bb a :B .
+:bb :o "Second group" .
+:bb :a :q .
+:bb :a :w .
+:bb :a :e .
+
+:bc a :B .
+:bc :o "Third group" .
+
diff --git a/tests/libtracker-data/functions/functions-property-1.out b/tests/libtracker-data/functions/functions-property-1.out
new file mode 100644
index 0000000..575a280
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-property-1.out
@@ -0,0 +1,7 @@
+"First group"	"first"
+"First group"	"second"
+"First group"	"third"
+"First group"	"other"
+"Second group"	"fourth"
+"Second group"	"fifth"
+"Second group"	"other"
diff --git a/tests/libtracker-data/functions/functions-property-1.rq b/tests/libtracker-data/functions/functions-property-1.rq
new file mode 100644
index 0000000..153f9fd
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-property-1.rq
@@ -0,0 +1,8 @@
+PREFIX ex: <http://example/>
+PREFIX ns: <http://www.w3.org/2005/xpath-functions#>
+
+SELECT ex:o(?b) ex:s(?a)
+{ ?b a ex:B ;
+  ex:a ?a
+}
+
diff --git a/tests/libtracker-data/functions/functions-tracker-1.out b/tests/libtracker-data/functions/functions-tracker-1.out
new file mode 100644
index 0000000..d8c2484
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-tracker-1.out
@@ -0,0 +1,7 @@
+"Text"
+"default"
+"optional"
+"optional for third"
+"other"
+"purposes"
+"testing"
diff --git a/tests/libtracker-data/functions/functions-tracker-1.rq b/tests/libtracker-data/functions/functions-tracker-1.rq
new file mode 100644
index 0000000..3bd02f7
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-tracker-1.rq
@@ -0,0 +1,10 @@
+PREFIX ex: <http://example/>
+PREFIX ns: <http://www.w3.org/2005/xpath-functions#>
+
+SELECT tracker:coalesce(?u, ?t, ?s, "default")
+{ ?_x a ex:A .
+  OPTIONAL { ?_x ex:s ?s }
+  OPTIONAL { ?_x ex:t ?t }
+  OPTIONAL { ?_x ex:u ?u }
+}
+ORDER BY tracker:coalesce(?u, ?t, ?s, "default")
diff --git a/tests/libtracker-data/functions/functions-xpath-1.out b/tests/libtracker-data/functions/functions-xpath-1.out
new file mode 100644
index 0000000..488aa9a
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-1.out
@@ -0,0 +1,4 @@
+"fifth"
+"fourth"
+"other"
+"third"
diff --git a/tests/libtracker-data/functions/functions-xpath-1.rq b/tests/libtracker-data/functions/functions-xpath-1.rq
new file mode 100644
index 0000000..0145b9d
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-1.rq
@@ -0,0 +1,7 @@
+PREFIX ex: <http://example/>
+PREFIX ns: <http://www.w3.org/2005/xpath-functions#>
+
+SELECT ?s
+{ ?_x ex:s ?s .
+  FILTER (ns:contains(?s, "th")) }
+ORDER BY ?s
diff --git a/tests/libtracker-data/functions/functions-xpath-2.out b/tests/libtracker-data/functions/functions-xpath-2.out
new file mode 100644
index 0000000..76c3d93
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-2.out
@@ -0,0 +1 @@
+"fifth"
diff --git a/tests/libtracker-data/functions/functions-xpath-2.rq b/tests/libtracker-data/functions/functions-xpath-2.rq
new file mode 100644
index 0000000..ac48407
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-2.rq
@@ -0,0 +1,7 @@
+PREFIX ex: <http://example/>
+PREFIX ns: <http://www.w3.org/2005/xpath-functions#>
+
+SELECT ?s
+{ ?_x ex:s ?s .
+  FILTER (ns:starts-with(?s, "fi") && ns:ends-with(?s, "h")) }
+ORDER BY ?s
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index 90a330d..2b193b0 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -63,6 +63,10 @@ const TestInfo tests[] = {
 	{ "expr-ops/query-plus-1", "expr-ops/data", FALSE },
 	{ "expr-ops/query-unminus-1", "expr-ops/data", FALSE },
 	{ "expr-ops/query-unplus-1", "expr-ops/data", FALSE },
+	{ "functions/functions-property-1", "functions/data-1", FALSE },
+	{ "functions/functions-tracker-1", "functions/data-1", FALSE },
+	{ "functions/functions-xpath-1", "functions/data-1", FALSE },
+	{ "functions/functions-xpath-2", "functions/data-1", FALSE },
 	{ "optional/q-opt-complex-1", "optional/complex-data-1", FALSE },
 	{ "regex/regex-query-001", "regex/regex-data-01", FALSE },
 	{ "regex/regex-query-002", "regex/regex-data-01", FALSE },
@@ -137,6 +141,7 @@ test_sparql_query (gconstpointer test_data)
 	/* perform actual query */
 
 	result_set = tracker_data_query_sparql (query, &error);
+
 	if (test_info->expect_error) {
 		comparer = strstr_i;
 		g_assert (error != NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]