aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/date.test9
-rw-r--r--test/ieee754.test16
-rw-r--r--test/indexexpr1.test16
-rw-r--r--test/json103.test65
-rw-r--r--test/spellfix3.test43
5 files changed, 143 insertions, 6 deletions
diff --git a/test/date.test b/test/date.test
index b1d1c677c..2f48b111e 100644
--- a/test/date.test
+++ b/test/date.test
@@ -336,6 +336,15 @@ if {$tzoffset_new==4} {
datetest 6.8.1 {datetime('2006-04-02 02:00:00','utc')} {2006-04-02 06:00:00}
datetest 6.8.2 {datetime('2007-03-11 02:00:00','utc')} {2007-03-11 06:00:00}
+ # The 'utc' modifier is a no-op if the LHS is known to already be in UTC
+ datetest 6.9.1 {datetime('2015-12-23 12:00:00','utc')} {2015-12-23 17:00:00}
+ datetest 6.9.2 {datetime('2015-12-23 12:00:00z','utc')} {2015-12-23 12:00:00}
+ datetest 6.9.3 {datetime('2015-12-23 12:00:00-03:00','utc')} \
+ {2015-12-23 15:00:00}
+ datetest 6.9.4 {datetime('2015-12-23 12:00:00','utc','utc','utc')} \
+ {2015-12-23 17:00:00}
+
+
datetest 6.10 {datetime('2000-01-01 12:00:00','localtime')} \
{2000-01-01 07:00:00}
datetest 6.11 {datetime('1969-01-01 12:00:00','localtime')} \
diff --git a/test/ieee754.test b/test/ieee754.test
index c0bf9d799..bf0676429 100644
--- a/test/ieee754.test
+++ b/test/ieee754.test
@@ -43,12 +43,16 @@ foreach {id float rep} {
}
}
-do_execsql_test ieee754-110 {
- SELECT ieee754(1,1024), ieee754(4503599627370495,972);
-} {Inf 1.79769313486232e+308}
-do_execsql_test ieee754-111 {
- SELECT ieee754(-1,1024), ieee754(-4503599627370495,972);
-} {-Inf -1.79769313486232e+308}
+do_test ieee754-110 {
+ string tolower [
+ db eval {SELECT ieee754(1,1024), ieee754(4503599627370495,972);}
+ ]
+} {inf 1.79769313486232e+308}
+do_test ieee754-111 {
+ string tolower [
+ db eval {SELECT ieee754(-1,1024), ieee754(-4503599627370495,972);}
+ ]
+} {-inf -1.79769313486232e+308}
do_execsql_test ieee754-112 {
SELECT ieee754(4503599627370495,973) is null;
} {1}
diff --git a/test/indexexpr1.test b/test/indexexpr1.test
index 89bea1877..a8a74f259 100644
--- a/test/indexexpr1.test
+++ b/test/indexexpr1.test
@@ -307,5 +307,21 @@ do_catchsql_test indexexpr1-910 {
INSERT INTO t9(a,b,c,d) VALUES(5,6,7,-8);
} {1 {UNIQUE constraint failed: index 't9x1'}}
+# Test cases derived from a NEVER() maro failure discovered by
+# Jonathan Metzman using AFL
+#
+do_execsql_test indexexpr1-1000 {
+ DROP TABLE IF EXISTS t0;
+ CREATE TABLE t0(a,b,t);
+ CREATE INDEX i ON t0(a in(0,1));
+ INSERT INTO t0 VALUES(0,1,2),(2,3,4),(5,6,7);
+ UPDATE t0 SET b=99 WHERE (a in(0,1))=0;
+ SELECT *, '|' FROM t0 ORDER BY +a;
+} {0 1 2 | 2 99 4 | 5 99 7 |}
+do_execsql_test indexexpr1-1010 {
+ UPDATE t0 SET b=88 WHERE (a in(0,1))=1;
+ SELECT *, '|' FROM t0 ORDER BY +a;
+} {0 88 2 | 2 99 4 | 5 99 7 |}
+
finish_test
diff --git a/test/json103.test b/test/json103.test
new file mode 100644
index 000000000..0f0241e6f
--- /dev/null
+++ b/test/json103.test
@@ -0,0 +1,65 @@
+# 2015-12-30
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements tests for JSON aggregate SQL functions
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !json1 {
+ finish_test
+ return
+}
+
+do_execsql_test json103-100 {
+ CREATE TABLE t1(a,b,c);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b,c) SELECT x, x%3, printf('n%d',x) FROM c;
+ UPDATE t1 SET a='orange' WHERE rowid=39;
+ UPDATE t1 SET a=32.5 WHERE rowid=31;
+ UPDATE t1 SET a=x'303132' WHERE rowid=29;
+ UPDATE t1 SET a=NULL WHERE rowid=37;
+ SELECT json_group_array(a) FROM t1 WHERE a<0 AND typeof(a)!='blob';
+} {{[]}}
+do_catchsql_test json103-101 {
+ SELECT json_group_array(a) FROM t1;
+} {1 {JSON cannot hold BLOB values}}
+do_execsql_test json103-110 {
+ SELECT json_group_array(a) FROM t1
+ WHERE rowid BETWEEN 31 AND 39;
+} {{[32.5,32,33,34,35,36,null,38,"orange"]}}
+do_execsql_test json103-111 {
+ SELECT json_array_length(json_group_array(a)) FROM t1
+ WHERE rowid BETWEEN 31 AND 39;
+} {9}
+do_execsql_test json103-120 {
+ SELECT b, json_group_array(a) FROM t1 WHERE rowid<10 GROUP BY b ORDER BY b;
+} {0 {[3,6,9]} 1 {[1,4,7]} 2 {[2,5,8]}}
+
+do_execsql_test json103-200 {
+ SELECT json_group_object(c,a) FROM t1 WHERE a<0 AND typeof(a)!='blob';
+} {{{}}}
+do_catchsql_test json103-201 {
+ SELECT json_group_object(c,a) FROM t1;
+} {1 {JSON cannot hold BLOB values}}
+
+do_execsql_test json103-210 {
+ SELECT json_group_object(c,a) FROM t1
+ WHERE rowid BETWEEN 31 AND 39 AND rowid%2==1;
+} {{{"n31":32.5,"n33":33,"n35":35,"n37":null,"n39":"orange"}}}
+do_execsql_test json103-220 {
+ SELECT b, json_group_object(c,a) FROM t1
+ WHERE rowid<7 GROUP BY b ORDER BY b;
+} {0 {{"n3":3,"n6":6}} 1 {{"n1":1,"n4":4}} 2 {{"n2":2,"n5":5}}}
+
+
+
+finish_test
diff --git a/test/spellfix3.test b/test/spellfix3.test
new file mode 100644
index 000000000..ce002edd4
--- /dev/null
+++ b/test/spellfix3.test
@@ -0,0 +1,43 @@
+# 2015-12-17
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix spellfix3
+
+ifcapable !vtab { finish_test ; return }
+
+load_static_extension db spellfix
+
+do_execsql_test 100 {
+ SELECT spellfix1_scriptcode('And God said, “Let there be light”');
+} {215}
+do_execsql_test 110 {
+ SELECT spellfix1_scriptcode('Бог сказал: "Да будет свет"');
+} {220}
+do_execsql_test 120 {
+ SELECT spellfix1_scriptcode('και ειπεν ο θεος γενηθητω φως και εγενετο φως');
+} {200}
+do_execsql_test 130 {
+ SELECT spellfix1_scriptcode('וַיֹּ֥אמֶר אֱלֹהִ֖ים יְהִ֣י א֑וֹר וַֽיְהִי־אֽוֹר׃');
+} {125}
+do_execsql_test 140 {
+ SELECT spellfix1_scriptcode('فِي ذَلِكَ الوَقتِ، قالَ اللهُ: لِيَكُنْ نُورٌ. فَصَارَ نُورٌ.');
+} {160}
+do_execsql_test 200 {
+ SELECT spellfix1_scriptcode('+3.14159');
+} {999}
+do_execsql_test 210 {
+ SELECT spellfix1_scriptcode('And God said: "Да будет свет"');
+} {998}
+
+finish_test