[tracker] tests: Test cases for fn:replace() with regular expression support.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tests: Test cases for fn:replace() with regular expression support.
- Date: Sun, 8 May 2016 17:45:41 +0000 (UTC)
commit e8b8e328463399bc47887f69c947a9560155c96b
Author: Kevin Haller <kevin haller outofbits com>
Date: Sun Sep 13 20:45:49 2015 +0200
tests: Test cases for fn:replace() with regular expression support.
Add five test cases, which shall check the behaviour of the
replace function.
https://bugzilla.gnome.org/show_bug.cgi?id=754961
tests/libtracker-data/functions/Makefile.am | 12 ++++-
tests/libtracker-data/functions/data-4.ontology | 28 ++++++++++
tests/libtracker-data/functions/data-4.ttl | 53 ++++++++++++++++++++
.../functions/functions-xpath-10.out | 10 ++++
.../functions/functions-xpath-10.rq | 12 +++++
.../functions/functions-xpath-11.out | 10 ++++
.../functions/functions-xpath-11.rq | 10 ++++
.../functions/functions-xpath-12.out | 1 +
.../functions/functions-xpath-12.rq | 10 ++++
.../functions/functions-xpath-13.out | 1 +
.../functions/functions-xpath-13.rq | 4 ++
.../functions/functions-xpath-14.out | 1 +
.../functions/functions-xpath-14.rq | 7 +++
tests/libtracker-data/tracker-sparql-test.c | 5 ++
14 files changed, 163 insertions(+), 1 deletions(-)
---
diff --git a/tests/libtracker-data/functions/Makefile.am b/tests/libtracker-data/functions/Makefile.am
index 6cd9637..24d992f 100644
--- a/tests/libtracker-data/functions/Makefile.am
+++ b/tests/libtracker-data/functions/Makefile.am
@@ -32,4 +32,14 @@ EXTRA_DIST += \
functions-xpath-8.rq \
functions-xpath-8.out \
functions-xpath-9.rq \
- functions-xpath-9.out
+ functions-xpath-9.out \
+ functions-xpath-10.rq \
+ functions-xpath-10.out \
+ functions-xpath-11.rq \
+ functions-xpath-11.out \
+ functions-xpath-12.rq \
+ functions-xpath-12.out \
+ functions-xpath-13.rq \
+ functions-xpath-13.out \
+ functions-xpath-14.rq \
+ functions-xpath-14.out
diff --git a/tests/libtracker-data/functions/data-4.ontology b/tests/libtracker-data/functions/data-4.ontology
new file mode 100644
index 0000000..222106f
--- /dev/null
+++ b/tests/libtracker-data/functions/data-4.ontology
@@ -0,0 +1,28 @@
+ prefix e: <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#> .
+
+e: a tracker:Namespace ;
+ tracker:prefix "example" .
+
+e:Person a rdfs:Class ;
+ rdfs:subClassOf rdfs:Resource .
+
+e:name a rdf:Property ;
+ rdfs:domain e:Person ;
+ rdfs:range xsd:string .
+
+e:familyName a rdf:Property ;
+ rdfs:domain e:Person ;
+ rdfs:range xsd:string .
+
+e:givenName a rdf:Property ;
+ rdfs:domain e:Person ;
+ rdfs:range xsd:string .
+
+e:description a rdf:Property ;
+ rdfs:domain e:Person ;
+ rdfs:range xsd:string .
diff --git a/tests/libtracker-data/functions/data-4.ttl b/tests/libtracker-data/functions/data-4.ttl
new file mode 100644
index 0000000..dfe8d49
--- /dev/null
+++ b/tests/libtracker-data/functions/data-4.ttl
@@ -0,0 +1,53 @@
+ prefix : <http://example/> .
+
+:p1 a :Person ;
+ :name " Maximilian Muster " ;
+ :familyName "Muster" ;
+ :givenName "Maximilian" .
+
+:p2 a :Person ;
+ :name "Amelie Colbert" ;
+ :familyName "Colbert" ;
+ :givenName "Amelie" .
+
+:p3 a :Person ;
+ :name "Alice Hyatt" ;
+ :familyName "Hyatt" ;
+ :givenName "Alice" .
+
+:p4 a :Person ;
+ :name " Mia Simpson " ;
+ :familyName "Simpson" ;
+ :givenName "Mia" .
+
+:p5 a :Person ;
+ :name " Kathlene Beckmann " ;
+ :familyName "Beckmann" ;
+ :givenName "Kathlene" .
+
+:p6 a :Person ;
+ :name "'Jule Wolk'" ;
+ :familyName "Wolk" ;
+ :givenName "Jule" .
+
+:p7 a :Person ;
+ :name " Torie Baumeister " ;
+ :familyName "Baumeister" ;
+ :givenName "Torie" .
+
+:p8 a :Person ;
+ :name " Dell Quesada " ;
+ :familyName "Queseda" ;
+ :givenName "Dell" .
+
+:p9 a :Person ;
+ :name "Fritz Fischer" ;
+ :familyName "Fischer" ;
+ :givenName "Fritz" ;
+ :description "Fischers Fritz fischt frische Fische." .
+
+:p10 a :Person ;
+ :name "Emily Schwartz" ;
+ :familyName "Schwartz" ;
+ :givenName "Emily" ;
+ :description "Emily is a software engineer." .
diff --git a/tests/libtracker-data/functions/functions-xpath-10.out
b/tests/libtracker-data/functions/functions-xpath-10.out
new file mode 100644
index 0000000..b51344a
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-10.out
@@ -0,0 +1,10 @@
+"Alice Hyatt"
+"Amelie Colbert"
+" Dell Quesada "
+"Emily Schwartz"
+"Fritz Fischer"
+"'Jule Wolk'"
+" Kathlene Beckmann "
+" Maximilian Muster "
+" Mia Simpson "
+" Torie Baumeister "
diff --git a/tests/libtracker-data/functions/functions-xpath-10.rq
b/tests/libtracker-data/functions/functions-xpath-10.rq
new file mode 100644
index 0000000..58b10ee
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-10.rq
@@ -0,0 +1,12 @@
+PREFIX ex: <http://example/>
+PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
+
+# Tests the replace function.
+# The punctuation shall be removed to alphabetize
+# the names of the persons corectly.
+SELECT ?name
+WHERE
+{
+ ?s ex:name ?name .
+}
+ORDER BY fn:replace(?name, "^[ ,'\".]+", "")
diff --git a/tests/libtracker-data/functions/functions-xpath-11.out
b/tests/libtracker-data/functions/functions-xpath-11.out
new file mode 100644
index 0000000..ce30269
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-11.out
@@ -0,0 +1,10 @@
+"Maximilian Muster"
+"Emily Schwartz"
+"Amelie Colbert"
+"Alice Hyatt"
+"Mia Simpson"
+"Kathlene Beckmann"
+"Jule Wolk"
+"Torie Baumeister"
+"Dell Quesada"
+"Fritz Fischer"
diff --git a/tests/libtracker-data/functions/functions-xpath-11.rq
b/tests/libtracker-data/functions/functions-xpath-11.rq
new file mode 100644
index 0000000..516cff4
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-11.rq
@@ -0,0 +1,10 @@
+PREFIX ex: <http://example/>
+PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
+# Tests the replace function.
+# Trims whitespaces and punctuations.
+SELECT fn:replace(?name, "^[ ,'\".]+|[ ,'\".]+$", "")
+WHERE
+{
+ ?s ex:name ?name .
+}
+ORDER BY ?s
diff --git a/tests/libtracker-data/functions/functions-xpath-12.out
b/tests/libtracker-data/functions/functions-xpath-12.out
new file mode 100644
index 0000000..ec19712
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-12.out
@@ -0,0 +1 @@
+"Laxers Fritz Laxt frische Laxe."
diff --git a/tests/libtracker-data/functions/functions-xpath-12.rq
b/tests/libtracker-data/functions/functions-xpath-12.rq
new file mode 100644
index 0000000..43de53b
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-12.rq
@@ -0,0 +1,10 @@
+PREFIX ex: <http://example/>
+PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
+# Tests the replace function.
+# Use of the regex flags.
+SELECT fn:replace(?desc_value, "fisch", "Lax", "i")
+WHERE
+{
+ ?s ex:name "Fritz Fischer" ;
+ ex:description ?desc_value .
+}
diff --git a/tests/libtracker-data/functions/functions-xpath-13.out
b/tests/libtracker-data/functions/functions-xpath-13.out
new file mode 100644
index 0000000..4fa476a
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-13.out
@@ -0,0 +1 @@
+"carted"
diff --git a/tests/libtracker-data/functions/functions-xpath-13.rq
b/tests/libtracker-data/functions/functions-xpath-13.rq
new file mode 100644
index 0000000..1d2f4f6
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-13.rq
@@ -0,0 +1,4 @@
+PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
+# Tests the replace function.
+# Uses backreferences.
+SELECT fn:replace("darted", "^(.*?)d(.*)$", "$1c$2") {}
diff --git a/tests/libtracker-data/functions/functions-xpath-14.out
b/tests/libtracker-data/functions/functions-xpath-14.out
new file mode 100644
index 0000000..479855a
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-14.out
@@ -0,0 +1 @@
+"The answer is $42."
diff --git a/tests/libtracker-data/functions/functions-xpath-14.rq
b/tests/libtracker-data/functions/functions-xpath-14.rq
new file mode 100644
index 0000000..b296273
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-14.rq
@@ -0,0 +1,7 @@
+PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
+# Tests the replace function.
+# Uses backreferences and the dollar sign 'as is'.
+# There are only backreferences, so the last digit
+# of the backreference of the replacement string
+# is used 'as is'.
+SELECT fn:replace("4aaaa2cc", "(.)a+((((\\d)a)a)|(((\\d)b)b)|(((\\d)c)c))", "The answer is \\$$12.") {}
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index 57b7a00..1b77ba5 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -101,6 +101,11 @@ const TestInfo tests[] = {
{ "functions/functions-xpath-7", "functions/data-1", FALSE },
{ "functions/functions-xpath-8", "functions/data-1", FALSE },
{ "functions/functions-xpath-9", "functions/data-1", FALSE },
+ { "functions/functions-xpath-10", "functions/data-4", FALSE },
+ { "functions/functions-xpath-11", "functions/data-4", FALSE },
+ { "functions/functions-xpath-12", "functions/data-4", FALSE },
+ { "functions/functions-xpath-13", "functions/data-4", FALSE },
+ { "functions/functions-xpath-14", "functions/data-4", FALSE },
{ "graph/graph-1", "graph/data-1", FALSE },
{ "graph/graph-2", "graph/data-2", FALSE },
{ "graph/graph-3", "graph/data-3", FALSE },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]