[tracker/wip/carlosg/more-tests: 1/3] tests: Add tests for FTS functions
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/more-tests: 1/3] tests: Add tests for FTS functions
- Date: Thu, 10 Mar 2022 20:23:55 +0000 (UTC)
commit 93284bcc91c670bb3528d270ea7b091694fb4bef
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Mar 10 17:08:05 2022 +0100
tests: Add tests for FTS functions
Test behavior and output of FTS rank/offsets/snippet functions.
tests/libtracker-fts/data.ontology | 7 +++++++
tests/libtracker-fts/functions/offsets-1.out | 4 ++++
tests/libtracker-fts/functions/offsets-1.rq | 1 +
tests/libtracker-fts/functions/offsets-2.out | 2 ++
tests/libtracker-fts/functions/offsets-2.rq | 1 +
tests/libtracker-fts/functions/offsets-3.out | 3 +++
tests/libtracker-fts/functions/offsets-3.rq | 1 +
tests/libtracker-fts/functions/offsets-data.rq | 9 +++++++++
tests/libtracker-fts/functions/rank-1.out | 4 ++++
tests/libtracker-fts/functions/rank-1.rq | 1 +
tests/libtracker-fts/functions/rank-2.out | 2 ++
tests/libtracker-fts/functions/rank-2.rq | 1 +
tests/libtracker-fts/functions/rank-data.rq | 9 +++++++++
tests/libtracker-fts/functions/snippet-1.out | 4 ++++
tests/libtracker-fts/functions/snippet-1.rq | 1 +
tests/libtracker-fts/functions/snippet-2.out | 4 ++++
tests/libtracker-fts/functions/snippet-2.rq | 1 +
tests/libtracker-fts/functions/snippet-3.out | 4 ++++
tests/libtracker-fts/functions/snippet-3.rq | 1 +
tests/libtracker-fts/functions/snippet-4.out | 4 ++++
tests/libtracker-fts/functions/snippet-4.rq | 1 +
tests/libtracker-fts/functions/snippet-5.out | 4 ++++
tests/libtracker-fts/functions/snippet-5.rq | 1 +
tests/libtracker-fts/functions/snippet-data.rq | 9 +++++++++
tests/libtracker-fts/tracker-fts-test.c | 3 +++
25 files changed, 82 insertions(+)
---
diff --git a/tests/libtracker-fts/data.ontology b/tests/libtracker-fts/data.ontology
index 8ce8b6627..84bf4fcf4 100644
--- a/tests/libtracker-fts/data.ontology
+++ b/tests/libtracker-fts/data.ontology
@@ -21,6 +21,7 @@ test:p a rdf:Property ;
nrl:maxCardinality 1 ;
rdfs:domain test:A ;
rdfs:range xsd:string ;
+ nrl:weight 20 ;
nrl:fulltextIndexed true .
test:o a rdf:Property ;
@@ -28,3 +29,9 @@ test:o a rdf:Property ;
rdfs:domain test:A ;
rdfs:range xsd:string ;
nrl:fulltextIndexed true .
+
+test:q a rdf:Property ;
+ rdfs:domain test:A ;
+ rdfs:range xsd:string ;
+ nrl:weight 2 ;
+ nrl:fulltextIndexed true .
diff --git a/tests/libtracker-fts/functions/offsets-1.out b/tests/libtracker-fts/functions/offsets-1.out
new file mode 100644
index 000000000..42b059e27
--- /dev/null
+++ b/tests/libtracker-fts/functions/offsets-1.out
@@ -0,0 +1,4 @@
+"http://www.example.org/test#1" "test:p,0"
+"http://www.example.org/test#2" "test:p,0,test:p,8"
+"http://www.example.org/test#4" "test:o,0,test:p,0"
+"http://www.example.org/test#3" "test:o,0"
diff --git a/tests/libtracker-fts/functions/offsets-1.rq b/tests/libtracker-fts/functions/offsets-1.rq
new file mode 100644
index 000000000..b18570d11
--- /dev/null
+++ b/tests/libtracker-fts/functions/offsets-1.rq
@@ -0,0 +1 @@
+SELECT ?u fts:offsets(?u) { ?u fts:match 'bananas' } order by desc fts:rank(?u)
diff --git a/tests/libtracker-fts/functions/offsets-2.out b/tests/libtracker-fts/functions/offsets-2.out
new file mode 100644
index 000000000..f9a587b6c
--- /dev/null
+++ b/tests/libtracker-fts/functions/offsets-2.out
@@ -0,0 +1,2 @@
+"http://www.example.org/test#5" "test:p,0"
+"http://www.example.org/test#6" "test:q,0,test:q,0"
diff --git a/tests/libtracker-fts/functions/offsets-2.rq b/tests/libtracker-fts/functions/offsets-2.rq
new file mode 100644
index 000000000..f273db100
--- /dev/null
+++ b/tests/libtracker-fts/functions/offsets-2.rq
@@ -0,0 +1 @@
+SELECT ?u fts:offsets(?u) { ?u fts:match 'oranges' } order by desc fts:rank(?u)
diff --git a/tests/libtracker-fts/functions/offsets-3.out b/tests/libtracker-fts/functions/offsets-3.out
new file mode 100644
index 000000000..5954669de
--- /dev/null
+++ b/tests/libtracker-fts/functions/offsets-3.out
@@ -0,0 +1,3 @@
+"http://www.example.org/test#1" "test:p,8,test:p,15"
+"http://www.example.org/test#2" "test:p,16"
+"http://www.example.org/test#4" "test:o,8"
diff --git a/tests/libtracker-fts/functions/offsets-3.rq b/tests/libtracker-fts/functions/offsets-3.rq
new file mode 100644
index 000000000..f726e325f
--- /dev/null
+++ b/tests/libtracker-fts/functions/offsets-3.rq
@@ -0,0 +1 @@
+SELECT ?u fts:offsets(?u) { ?u fts:match 'lemons' } order by desc fts:rank(?u)
diff --git a/tests/libtracker-fts/functions/offsets-data.rq b/tests/libtracker-fts/functions/offsets-data.rq
new file mode 100644
index 000000000..7cfeccaca
--- /dev/null
+++ b/tests/libtracker-fts/functions/offsets-data.rq
@@ -0,0 +1,9 @@
+INSERT {
+ test:1 a test:A ; test:p "bananas lemons lemons" .
+ test:2 a test:A ; test:p "bananas bananas lemons" .
+ test:3 a test:A ; test:o "bananas" .
+ test:4 a test:A ; test:p "bananas" ; test:o "bananas lemons" .
+
+ test:5 a test:A ; test:p "oranges!" .
+ test:6 a test:A ; test:q "oranges", "apples and oranges" .
+}
diff --git a/tests/libtracker-fts/functions/rank-1.out b/tests/libtracker-fts/functions/rank-1.out
new file mode 100644
index 000000000..4d04bba3c
--- /dev/null
+++ b/tests/libtracker-fts/functions/rank-1.out
@@ -0,0 +1,4 @@
+"http://www.example.org/test#1" "20.0"
+"http://www.example.org/test#2" "20.0"
+"http://www.example.org/test#4" "20.0"
+"http://www.example.org/test#3" "0.0"
diff --git a/tests/libtracker-fts/functions/rank-1.rq b/tests/libtracker-fts/functions/rank-1.rq
new file mode 100644
index 000000000..54acbe62d
--- /dev/null
+++ b/tests/libtracker-fts/functions/rank-1.rq
@@ -0,0 +1 @@
+SELECT ?u fts:rank(?u) { ?u fts:match 'bananas' } order by desc fts:rank(?u)
diff --git a/tests/libtracker-fts/functions/rank-2.out b/tests/libtracker-fts/functions/rank-2.out
new file mode 100644
index 000000000..237f1616f
--- /dev/null
+++ b/tests/libtracker-fts/functions/rank-2.out
@@ -0,0 +1,2 @@
+"http://www.example.org/test#5" "20.0"
+"http://www.example.org/test#6" "2.0"
diff --git a/tests/libtracker-fts/functions/rank-2.rq b/tests/libtracker-fts/functions/rank-2.rq
new file mode 100644
index 000000000..8438b74ce
--- /dev/null
+++ b/tests/libtracker-fts/functions/rank-2.rq
@@ -0,0 +1 @@
+SELECT ?u fts:rank(?u) { ?u fts:match 'oranges' } order by desc fts:rank(?u)
diff --git a/tests/libtracker-fts/functions/rank-data.rq b/tests/libtracker-fts/functions/rank-data.rq
new file mode 100644
index 000000000..2a8ffb1c0
--- /dev/null
+++ b/tests/libtracker-fts/functions/rank-data.rq
@@ -0,0 +1,9 @@
+INSERT {
+ test:1 a test:A ; test:p "bananas lemons lemons" .
+ test:2 a test:A ; test:p "bananas bananas lemons" .
+ test:3 a test:A ; test:o "bananas" .
+ test:4 a test:A ; test:p "bananas" ; test:o "bananas lemons" .
+
+ test:5 a test:A ; test:p "oranges!" .
+ test:6 a test:A ; test:q "oranges", "oranges and oranges" .
+}
diff --git a/tests/libtracker-fts/functions/snippet-1.out b/tests/libtracker-fts/functions/snippet-1.out
new file mode 100644
index 000000000..db1fae0c2
--- /dev/null
+++ b/tests/libtracker-fts/functions/snippet-1.out
@@ -0,0 +1,4 @@
+"http://www.example.org/test#1" "bananas lemons lemons"
+"http://www.example.org/test#2" "bananas bananas lemons"
+"http://www.example.org/test#4" "bananas lemons"
+"http://www.example.org/test#3" "bananas"
diff --git a/tests/libtracker-fts/functions/snippet-1.rq b/tests/libtracker-fts/functions/snippet-1.rq
new file mode 100644
index 000000000..37cedaf0f
--- /dev/null
+++ b/tests/libtracker-fts/functions/snippet-1.rq
@@ -0,0 +1 @@
+SELECT ?u fts:snippet(?u) { ?u fts:match 'bananas' } order by desc fts:rank(?u)
diff --git a/tests/libtracker-fts/functions/snippet-2.out b/tests/libtracker-fts/functions/snippet-2.out
new file mode 100644
index 000000000..8cdc6f4b8
--- /dev/null
+++ b/tests/libtracker-fts/functions/snippet-2.out
@@ -0,0 +1,4 @@
+"http://www.example.org/test#1" ">>>bananas<<< lemons lemons"
+"http://www.example.org/test#2" ">>>bananas<<< >>>bananas<<< lemons"
+"http://www.example.org/test#4" ">>>bananas<<< lemons"
+"http://www.example.org/test#3" ">>>bananas<<<"
diff --git a/tests/libtracker-fts/functions/snippet-2.rq b/tests/libtracker-fts/functions/snippet-2.rq
new file mode 100644
index 000000000..59cd8c306
--- /dev/null
+++ b/tests/libtracker-fts/functions/snippet-2.rq
@@ -0,0 +1 @@
+SELECT ?u fts:snippet(?u, '>>>', '<<<') { ?u fts:match 'bananas' } order by desc fts:rank(?u)
diff --git a/tests/libtracker-fts/functions/snippet-3.out b/tests/libtracker-fts/functions/snippet-3.out
new file mode 100644
index 000000000..9c869b89a
--- /dev/null
+++ b/tests/libtracker-fts/functions/snippet-3.out
@@ -0,0 +1,4 @@
+"http://www.example.org/test#1" ">>>bananas<<<..."
+"http://www.example.org/test#2" ">>>bananas<<< >>>bananas<<<..."
+"http://www.example.org/test#4" ">>>bananas<<<..."
+"http://www.example.org/test#3" ">>>bananas<<<"
diff --git a/tests/libtracker-fts/functions/snippet-3.rq b/tests/libtracker-fts/functions/snippet-3.rq
new file mode 100644
index 000000000..bb235264f
--- /dev/null
+++ b/tests/libtracker-fts/functions/snippet-3.rq
@@ -0,0 +1 @@
+SELECT ?u fts:snippet(?u, '>>>', '<<<', '...', 1) { ?u fts:match 'bananas' } order by desc fts:rank(?u)
diff --git a/tests/libtracker-fts/functions/snippet-4.out b/tests/libtracker-fts/functions/snippet-4.out
new file mode 100644
index 000000000..e3650f67a
--- /dev/null
+++ b/tests/libtracker-fts/functions/snippet-4.out
@@ -0,0 +1,4 @@
+"http://www.example.org/test#1"
+"http://www.example.org/test#2" ">>>bananas<<< >>>bananas<<<..."
+"http://www.example.org/test#4" ">>>bananas<<<..."
+"http://www.example.org/test#3" ">>>bananas<<<..."
diff --git a/tests/libtracker-fts/functions/snippet-4.rq b/tests/libtracker-fts/functions/snippet-4.rq
new file mode 100644
index 000000000..1b542b57c
--- /dev/null
+++ b/tests/libtracker-fts/functions/snippet-4.rq
@@ -0,0 +1 @@
+SELECT ?u fts:snippet(?u, '>>>', '<<<', '...', 0) { ?u fts:match 'bananas' } order by desc fts:rank(?u)
diff --git a/tests/libtracker-fts/functions/snippet-5.out b/tests/libtracker-fts/functions/snippet-5.out
new file mode 100644
index 000000000..b7e42e2f1
--- /dev/null
+++ b/tests/libtracker-fts/functions/snippet-5.out
@@ -0,0 +1,4 @@
+"http://www.example.org/test#1"
+"http://www.example.org/test#2"
+"http://www.example.org/test#4"
+"http://www.example.org/test#3"
diff --git a/tests/libtracker-fts/functions/snippet-5.rq b/tests/libtracker-fts/functions/snippet-5.rq
new file mode 100644
index 000000000..564f52d01
--- /dev/null
+++ b/tests/libtracker-fts/functions/snippet-5.rq
@@ -0,0 +1 @@
+SELECT ?u fts:snippet(?u, '>>>', '<<<', '...', -1) { ?u fts:match 'bananas' } order by desc fts:rank(?u)
diff --git a/tests/libtracker-fts/functions/snippet-data.rq b/tests/libtracker-fts/functions/snippet-data.rq
new file mode 100644
index 000000000..2a8ffb1c0
--- /dev/null
+++ b/tests/libtracker-fts/functions/snippet-data.rq
@@ -0,0 +1,9 @@
+INSERT {
+ test:1 a test:A ; test:p "bananas lemons lemons" .
+ test:2 a test:A ; test:p "bananas bananas lemons" .
+ test:3 a test:A ; test:o "bananas" .
+ test:4 a test:A ; test:p "bananas" ; test:o "bananas lemons" .
+
+ test:5 a test:A ; test:p "oranges!" .
+ test:6 a test:A ; test:q "oranges", "oranges and oranges" .
+}
diff --git a/tests/libtracker-fts/tracker-fts-test.c b/tests/libtracker-fts/tracker-fts-test.c
index edac25010..c0bca75ef 100644
--- a/tests/libtracker-fts/tracker-fts-test.c
+++ b/tests/libtracker-fts/tracker-fts-test.c
@@ -41,6 +41,9 @@ const TestInfo tests[] = {
{ "prefix/fts3prefix", 3 },
{ "limits/fts3limits", 4 },
{ "input/fts3input", 3 },
+ { "functions/rank", 2 },
+ { "functions/offsets", 3 },
+ { "functions/snippet", 5 },
{ NULL }
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]