[tracker/wip/carlosg/more-tests: 6/7] tests: Add more aggregate function tests




commit 2ac2b379853e7c326c6c946e036f03e63448270d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Mar 11 00:38:16 2022 +0100

    tests: Add more aggregate function tests

 tests/libtracker-data/aggregates/aggregate-count-1.out        |  1 +
 tests/libtracker-data/aggregates/aggregate-count-1.rq         |  3 +++
 tests/libtracker-data/aggregates/aggregate-count-2.out        |  1 +
 tests/libtracker-data/aggregates/aggregate-count-2.rq         |  3 +++
 tests/libtracker-data/aggregates/aggregate-count-3.out        |  1 +
 tests/libtracker-data/aggregates/aggregate-count-3.rq         |  3 +++
 tests/libtracker-data/aggregates/aggregate-group-having-1.out |  1 +
 tests/libtracker-data/aggregates/aggregate-group-having-1.rq  | 10 ++++++++++
 tests/libtracker-data/aggregates/aggregate-sample-1.out       |  2 ++
 tests/libtracker-data/aggregates/aggregate-sample-1.rq        | 11 +++++++++++
 tests/libtracker-data/tracker-sparql-test.c                   |  5 +++++
 11 files changed, 41 insertions(+)
---
diff --git a/tests/libtracker-data/aggregates/aggregate-count-1.out 
b/tests/libtracker-data/aggregates/aggregate-count-1.out
new file mode 100644
index 000000000..18d17df02
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-count-1.out
@@ -0,0 +1 @@
+"3"
diff --git a/tests/libtracker-data/aggregates/aggregate-count-1.rq 
b/tests/libtracker-data/aggregates/aggregate-count-1.rq
new file mode 100644
index 000000000..dbdb24acf
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-count-1.rq
@@ -0,0 +1,3 @@
+PREFIX : <http://example/>
+
+SELECT COUNT(?u) { [ :i2 ?u ] }
diff --git a/tests/libtracker-data/aggregates/aggregate-count-2.out 
b/tests/libtracker-data/aggregates/aggregate-count-2.out
new file mode 100644
index 000000000..18d17df02
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-count-2.out
@@ -0,0 +1 @@
+"3"
diff --git a/tests/libtracker-data/aggregates/aggregate-count-2.rq 
b/tests/libtracker-data/aggregates/aggregate-count-2.rq
new file mode 100644
index 000000000..dd440145d
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-count-2.rq
@@ -0,0 +1,3 @@
+PREFIX : <http://example/>
+
+SELECT COUNT(*) { [ :i2 ?u ] }
diff --git a/tests/libtracker-data/aggregates/aggregate-count-3.out 
b/tests/libtracker-data/aggregates/aggregate-count-3.out
new file mode 100644
index 000000000..1026c253e
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-count-3.out
@@ -0,0 +1 @@
+"2"
diff --git a/tests/libtracker-data/aggregates/aggregate-count-3.rq 
b/tests/libtracker-data/aggregates/aggregate-count-3.rq
new file mode 100644
index 000000000..73a072b8a
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-count-3.rq
@@ -0,0 +1,3 @@
+PREFIX : <http://example/>
+
+SELECT COUNT(DISTINCT ?u) { [ :i2 ?u ] }
diff --git a/tests/libtracker-data/aggregates/aggregate-group-having-1.out 
b/tests/libtracker-data/aggregates/aggregate-group-having-1.out
new file mode 100644
index 000000000..e66f8d307
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-group-having-1.out
@@ -0,0 +1 @@
+"http://example/x";     "2"     "8"     "string t|string y"
diff --git a/tests/libtracker-data/aggregates/aggregate-group-having-1.rq 
b/tests/libtracker-data/aggregates/aggregate-group-having-1.rq
new file mode 100644
index 000000000..87a2e2a6a
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-group-having-1.rq
@@ -0,0 +1,10 @@
+PREFIX : <http://example/> 
+
+SELECT ?a COUNT(DISTINCT ?b) SUM(?ib) GROUP_CONCAT(?sb, "|")
+{ ?a a :A ;
+     :b ?b .
+  ?b :ib ?ib .
+  ?b :sb ?sb .
+  FILTER (?ib>2) }
+GROUP BY ?a
+HAVING (SUM(?ib)<10)
\ No newline at end of file
diff --git a/tests/libtracker-data/aggregates/aggregate-sample-1.out 
b/tests/libtracker-data/aggregates/aggregate-sample-1.out
new file mode 100644
index 000000000..5378d4f58
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-sample-1.out
@@ -0,0 +1,2 @@
+"http://example/x";     "8"
+"http://example/z";     "8"
diff --git a/tests/libtracker-data/aggregates/aggregate-sample-1.rq 
b/tests/libtracker-data/aggregates/aggregate-sample-1.rq
new file mode 100644
index 000000000..3f8f0aff9
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-sample-1.rq
@@ -0,0 +1,11 @@
+PREFIX : <http://example/> 
+
+# All samples have the same length
+SELECT ?a STRLEN(SAMPLE(?sb))
+{ ?a a :A ;
+     :b ?b .
+  ?b :ib ?ib .
+  ?b :sb ?sb .
+  FILTER (?ib>2) }
+GROUP BY ?a
+ORDER BY ?a
\ No newline at end of file
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index f5c526ed9..2d6a7b42d 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -42,10 +42,15 @@ struct _TestInfo {
 
 const TestInfo tests[] = {
        { "aggregates/aggregate-1", "aggregates/data-1", FALSE },
+       { "aggregates/aggregate-count-1", "aggregates/data-1", FALSE },
+       { "aggregates/aggregate-count-2", "aggregates/data-1", FALSE },
+       { "aggregates/aggregate-count-3", "aggregates/data-1", FALSE },
        { "aggregates/aggregate-distinct-1", "aggregates/data-1", FALSE },
        { "aggregates/aggregate-group-1", "aggregates/data-1", FALSE },
        { "aggregates/aggregate-group-2", "aggregates/data-1", FALSE },
        { "aggregates/aggregate-group-as-1", "aggregates/data-1", FALSE },
+       { "aggregates/aggregate-group-having-1", "aggregates/data-1", FALSE },
+       { "aggregates/aggregate-sample-1", "aggregates/data-1", FALSE },
        { "algebra/two-nested-opt", "algebra/two-nested-opt", FALSE },
        { "algebra/two-nested-opt-alt", "algebra/two-nested-opt", FALSE },
        { "algebra/opt-filter-3", "algebra/opt-filter-3", FALSE },


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