[tracker/wip/carlosg/sparql-parser-ng: 50/50] tests: Add some tests for the supported property paths



commit dc6c0851bb7f61f7923beaacf03f9a967806b5f0
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Nov 4 15:22:21 2018 +0100

    tests: Add some tests for the supported property paths
    
    Inverse and sequence paths are tested thus far.

 tests/libtracker-data/property-paths/data.ttl      | 32 ++++++++++++++++++++
 .../property-paths/inverse-path-1.out              |  3 ++
 .../property-paths/inverse-path-1.rq               |  1 +
 .../property-paths/inverse-path-2.out              |  6 ++++
 .../property-paths/inverse-path-2.rq               |  1 +
 .../mixed-inverse-and-sequence-1.out               |  1 +
 .../property-paths/mixed-inverse-and-sequence-1.rq |  1 +
 .../mixed-inverse-and-sequence-2.out               |  1 +
 .../property-paths/mixed-inverse-and-sequence-2.rq |  1 +
 tests/libtracker-data/property-paths/query-1.rq    |  0
 .../property-paths/sequence-path-1.out             |  2 ++
 .../property-paths/sequence-path-1.rq              |  1 +
 .../property-paths/sequence-path-2.out             |  4 +++
 .../property-paths/sequence-path-2.rq              |  1 +
 .../property-paths/sequence-path-3.out             |  1 +
 .../property-paths/sequence-path-3.rq              |  1 +
 tests/libtracker-data/property-paths/test.ontology | 34 ++++++++++++++++++++++
 tests/libtracker-data/tracker-sparql-test.c        |  8 +++++
 18 files changed, 99 insertions(+)
---
diff --git a/tests/libtracker-data/property-paths/data.ttl b/tests/libtracker-data/property-paths/data.ttl
new file mode 100644
index 000000000..5088a80d3
--- /dev/null
+++ b/tests/libtracker-data/property-paths/data.ttl
@@ -0,0 +1,32 @@
+@prefix foaf:       <http://xmlns.com/foaf/0.1/> .
+@prefix rdf:        <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs:      <http://www.w3.org/2000/01/rdf-schema#> .
+
+_:alice
+    rdf:type        foaf:Person ;
+    foaf:name       "Alice" ;
+    foaf:mbox       <mailto:alice@work> ;
+    foaf:knows      _:bob ;
+    foaf:member     [ a foaf:Group ; foaf:name "Foo" ] ;
+    .
+
+_:bob
+    rdf:type        foaf:Person ;
+    foaf:name       "Bob" ; 
+    foaf:knows      _:alice ;
+    foaf:mbox       <mailto:bob@work> ;
+    foaf:mbox       <mailto:bob@home> ;
+    foaf:member     [ a foaf:Group ; foaf:name "Foo" ] ;
+    .
+
+
+_:eve
+    rdf:type      foaf:Person ;
+    foaf:name     "Eve" ; 
+    foaf:knows    _:fred ;
+    .
+
+_:fred
+    rdf:type      foaf:Person ;
+    foaf:name     "Fred" ;
+    foaf:mbox     <mailto:fred@edu> .
diff --git a/tests/libtracker-data/property-paths/inverse-path-1.out 
b/tests/libtracker-data/property-paths/inverse-path-1.out
new file mode 100644
index 000000000..0a9f74d4f
--- /dev/null
+++ b/tests/libtracker-data/property-paths/inverse-path-1.out
@@ -0,0 +1,3 @@
+"Bob"  "Alice"
+"Alice"        "Bob"
+"Fred" "Eve"
diff --git a/tests/libtracker-data/property-paths/inverse-path-1.rq 
b/tests/libtracker-data/property-paths/inverse-path-1.rq
new file mode 100644
index 000000000..1aaf070ce
--- /dev/null
+++ b/tests/libtracker-data/property-paths/inverse-path-1.rq
@@ -0,0 +1 @@
+select foaf:name(?a) foaf:name(?b) { ?a ^foaf:knows ?b }
\ No newline at end of file
diff --git a/tests/libtracker-data/property-paths/inverse-path-2.out 
b/tests/libtracker-data/property-paths/inverse-path-2.out
new file mode 100644
index 000000000..b74164513
--- /dev/null
+++ b/tests/libtracker-data/property-paths/inverse-path-2.out
@@ -0,0 +1,6 @@
+"1"    "Alice" "Bob"
+"1"    "Bob"   "Alice"
+"1"    "Fred"  "Eve"
+"2"    "Alice" "Bob"
+"2"    "Bob"   "Alice"
+"2"    "Fred"  "Eve"
diff --git a/tests/libtracker-data/property-paths/inverse-path-2.rq 
b/tests/libtracker-data/property-paths/inverse-path-2.rq
new file mode 100644
index 000000000..e886c8761
--- /dev/null
+++ b/tests/libtracker-data/property-paths/inverse-path-2.rq
@@ -0,0 +1 @@
+select ?s foaf:name(?a) foaf:name(?b) { { select ('1' as ?s) ?a ?b { ?a ^foaf:knows ?b } } union { select 
('2' as ?s) ?a ?b { ?b foaf:knows ?a } } } order by ?s foaf:name(?a) foaf:name(?b)
\ No newline at end of file
diff --git a/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-1.out 
b/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-1.out
new file mode 100644
index 000000000..52c90ceee
--- /dev/null
+++ b/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-1.out
@@ -0,0 +1 @@
+"Fred"
diff --git a/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-1.rq 
b/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-1.rq
new file mode 100644
index 000000000..a77629f6a
--- /dev/null
+++ b/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-1.rq
@@ -0,0 +1 @@
+select foaf:name(?u) { ?u ^foaf:knows/foaf:name 'Eve' }
\ No newline at end of file
diff --git a/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-2.out 
b/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-2.out
new file mode 100644
index 000000000..0686dec37
--- /dev/null
+++ b/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-2.out
@@ -0,0 +1 @@
+"Eve"
diff --git a/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-2.rq 
b/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-2.rq
new file mode 100644
index 000000000..f862af007
--- /dev/null
+++ b/tests/libtracker-data/property-paths/mixed-inverse-and-sequence-2.rq
@@ -0,0 +1 @@
+select foaf:name(?u) { ?u foaf:knows/^foaf:knows/foaf:name 'Eve' }
\ No newline at end of file
diff --git a/tests/libtracker-data/property-paths/query-1.rq b/tests/libtracker-data/property-paths/query-1.rq
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/libtracker-data/property-paths/sequence-path-1.out 
b/tests/libtracker-data/property-paths/sequence-path-1.out
new file mode 100644
index 000000000..d12a7b1c3
--- /dev/null
+++ b/tests/libtracker-data/property-paths/sequence-path-1.out
@@ -0,0 +1,2 @@
+"Alice"        "Alice"
+"Bob"  "Bob"
diff --git a/tests/libtracker-data/property-paths/sequence-path-1.rq 
b/tests/libtracker-data/property-paths/sequence-path-1.rq
new file mode 100644
index 000000000..8900f9d99
--- /dev/null
+++ b/tests/libtracker-data/property-paths/sequence-path-1.rq
@@ -0,0 +1 @@
+select foaf:name(?a) foaf:name(?b) { ?a foaf:knows/foaf:knows ?b }
\ No newline at end of file
diff --git a/tests/libtracker-data/property-paths/sequence-path-2.out 
b/tests/libtracker-data/property-paths/sequence-path-2.out
new file mode 100644
index 000000000..312a17008
--- /dev/null
+++ b/tests/libtracker-data/property-paths/sequence-path-2.out
@@ -0,0 +1,4 @@
+"1"    "Alice" "Alice"
+"1"    "Bob"   "Bob"
+"2"    "Alice" "Alice"
+"2"    "Bob"   "Bob"
diff --git a/tests/libtracker-data/property-paths/sequence-path-2.rq 
b/tests/libtracker-data/property-paths/sequence-path-2.rq
new file mode 100644
index 000000000..2fbc0642f
--- /dev/null
+++ b/tests/libtracker-data/property-paths/sequence-path-2.rq
@@ -0,0 +1 @@
+select ?s foaf:name(?a) foaf:name(?b) { { select ('1' as ?s) ?a ?b { ?a foaf:knows/foaf:knows ?b } } union { 
select ('2' as ?s) ?a ?b { ?a foaf:knows ?y . ?y foaf:knows ?b } } } order by ?s foaf:name(?a) foaf:name(?b)
\ No newline at end of file
diff --git a/tests/libtracker-data/property-paths/sequence-path-3.out 
b/tests/libtracker-data/property-paths/sequence-path-3.out
new file mode 100644
index 000000000..0686dec37
--- /dev/null
+++ b/tests/libtracker-data/property-paths/sequence-path-3.out
@@ -0,0 +1 @@
+"Eve"
diff --git a/tests/libtracker-data/property-paths/sequence-path-3.rq 
b/tests/libtracker-data/property-paths/sequence-path-3.rq
new file mode 100644
index 000000000..3cdee92a9
--- /dev/null
+++ b/tests/libtracker-data/property-paths/sequence-path-3.rq
@@ -0,0 +1 @@
+select foaf:name(?u) { ?u foaf:knows/foaf:name 'Fred' }
\ No newline at end of file
diff --git a/tests/libtracker-data/property-paths/test.ontology 
b/tests/libtracker-data/property-paths/test.ontology
new file mode 100644
index 000000000..de0a07b06
--- /dev/null
+++ b/tests/libtracker-data/property-paths/test.ontology
@@ -0,0 +1,34 @@
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@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#> .
+
+foaf: a tracker:Namespace ;
+       tracker:prefix "foaf" .
+
+foaf:Agent a rdfs:Class ;
+       rdfs:subClassOf rdfs:Resource .
+
+foaf:Person a rdfs:Class ;
+       rdfs:subClassOf foaf:Agent .
+
+foaf:Group a rdfs:Class ;
+       rdfs:subClassOf foaf:Agent .
+
+foaf:knows a rdf:Property ;
+       rdfs:domain foaf:Person ;
+       rdfs:range foaf:Person .
+
+foaf:mbox a rdf:Property ;
+       rdfs:domain foaf:Person ;
+       rdfs:range rdfs:Resource .
+
+foaf:name a rdf:Property ;
+       rdfs:domain foaf:Agent ;
+       rdfs:range xsd:string .
+
+foaf:member a rdf:Property ;
+       rdfs:domain foaf:Person ;
+       rdfs:range foaf:Group .
+
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index f52b9106a..1bfb5a4a4 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -146,6 +146,14 @@ const TestInfo tests[] = {
        { "bind/bind2", "bind/data", FALSE },
        { "bind/bind3", "bind/data", FALSE },
        { "bind/bind4", "bind/data", FALSE },
+       /* Property paths */
+       { "property-paths/inverse-path-1", "property-paths/data", FALSE },
+       { "property-paths/inverse-path-2", "property-paths/data", FALSE },
+       { "property-paths/sequence-path-1", "property-paths/data", FALSE },
+       { "property-paths/sequence-path-2", "property-paths/data", FALSE },
+       { "property-paths/sequence-path-3", "property-paths/data", FALSE },
+       { "property-paths/mixed-inverse-and-sequence-1", "property-paths/data", FALSE },
+       { "property-paths/mixed-inverse-and-sequence-2", "property-paths/data", FALSE },
        /* Update tests */
        { "update/insert-data-query-1", "update/insert-data-1", FALSE, FALSE },
        { "update/insert-data-query-2", "update/insert-data-2", FALSE, TRUE },


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