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




commit cfe19c00cbfdc11c6ba810bb6e82914fa0e7bba5
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-3.out        |  2 ++
 tests/libtracker-data/aggregates/aggregate-group-3.rq         |  9 +++++++++
 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        |  8 ++++++++
 tests/libtracker-data/aggregates/aggregate-sample-2.out       |  2 ++
 tests/libtracker-data/aggregates/aggregate-sample-2.rq        |  8 ++++++++
 tests/libtracker-data/tracker-sparql-test.c                   |  7 +++++++
 15 files changed, 61 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-3.out 
b/tests/libtracker-data/aggregates/aggregate-group-3.out
new file mode 100644
index 000000000..3b41f134b
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-group-3.out
@@ -0,0 +1,2 @@
+"http://example/x";     "2"     "8"     "string t|string y"
+"http://example/z";     "1"     "13"    "string u"
diff --git a/tests/libtracker-data/aggregates/aggregate-group-3.rq 
b/tests/libtracker-data/aggregates/aggregate-group-3.rq
new file mode 100644
index 000000000..440dceaf9
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-group-3.rq
@@ -0,0 +1,9 @@
+PREFIX : <http://example/>
+
+SELECT ?a COUNT(DISTINCT ?b) SUM(?ib) GROUP_CONCAT(?sb; SEPARATOR="|")
+{ ?a a :A ;
+     :b ?b .
+  ?b :ib ?ib .
+  ?b :sb ?sb .
+  FILTER (?ib>2) }
+GROUP BY ?a
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..c8dc7bef8
--- /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)
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..08d142806
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-sample-1.rq
@@ -0,0 +1,8 @@
+PREFIX : <http://example/>
+
+# All samples have the same length
+SELECT ?a STRLEN(SAMPLE(?s))
+{ ?a :b ?b .
+  ?b :sb ?s . }
+GROUP BY ?a
+ORDER BY ?a
diff --git a/tests/libtracker-data/aggregates/aggregate-sample-2.out 
b/tests/libtracker-data/aggregates/aggregate-sample-2.out
new file mode 100644
index 000000000..5378d4f58
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-sample-2.out
@@ -0,0 +1,2 @@
+"http://example/x";     "8"
+"http://example/z";     "8"
diff --git a/tests/libtracker-data/aggregates/aggregate-sample-2.rq 
b/tests/libtracker-data/aggregates/aggregate-sample-2.rq
new file mode 100644
index 000000000..c95554179
--- /dev/null
+++ b/tests/libtracker-data/aggregates/aggregate-sample-2.rq
@@ -0,0 +1,8 @@
+PREFIX : <http://example/>
+
+# All samples have the same length
+SELECT ?a STRLEN(SAMPLE(DISTINCT ?s))
+{ ?a :b ?b .
+  ?b :sb ?s . }
+GROUP BY ?a
+ORDER BY ?a
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index 0a89e6527..df731a195 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -42,10 +42,17 @@ 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-3", "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 },
+       { "aggregates/aggregate-sample-2", "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]