summaryrefslogtreecommitdiff
path: root/components/external/SQLite-3.8.1/test/intarray.test
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2013-11-30 03:36:56 -0800
committerBernard Xiong <[email protected]>2013-11-30 03:36:56 -0800
commitbe2f628160fa1262b6cc10df3823c5f984bc3c48 (patch)
tree6a96d2f30c979713b5f175b08c90a03f359faeb6 /components/external/SQLite-3.8.1/test/intarray.test
parent35d83be62ff504d2b595288e0a377160604e71a8 (diff)
parent9326719a12cf54f3418e292835e37ddc3afa92fd (diff)
Merge pull request #205 from geniusgogo/sqlite
Sqlite
Diffstat (limited to 'components/external/SQLite-3.8.1/test/intarray.test')
-rw-r--r--components/external/SQLite-3.8.1/test/intarray.test109
1 files changed, 109 insertions, 0 deletions
diff --git a/components/external/SQLite-3.8.1/test/intarray.test b/components/external/SQLite-3.8.1/test/intarray.test
new file mode 100644
index 0000000000..2aba080bd4
--- /dev/null
+++ b/components/external/SQLite-3.8.1/test/intarray.test
@@ -0,0 +1,109 @@
+# 2009 November 10
+#
+# 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 regression tests for SQLite library.
+#
+# This file implements tests for the "intarray" object implemented
+# in test_intarray.c.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+ return
+}
+
+do_test intarray-1.0 {
+ db eval {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ }
+ for {set i 1} {$i<=999} {incr i} {
+ set b [format {x%03d} $i]
+ db eval {INSERT INTO t1(a,b) VALUES($i,$b)}
+ }
+ db eval {
+ CREATE TABLE t2(x INTEGER PRIMARY KEY, y);
+ INSERT INTO t2 SELECT * FROM t1;
+ SELECT b FROM t1 WHERE a IN (12,34,56,78) ORDER BY a
+ }
+} {x012 x034 x056 x078}
+
+do_test intarray-1.1 {
+ set ia1 [sqlite3_intarray_create db ia1]
+ set ia2 [sqlite3_intarray_create db ia2]
+ set ia3 [sqlite3_intarray_create db ia3]
+ set ia4 [sqlite3_intarray_create db ia4]
+ db eval {
+ SELECT type, name FROM sqlite_temp_master
+ ORDER BY name
+ }
+} {table ia1 table ia2 table ia3 table ia4}
+
+do_test intarray-1.2 {
+ db eval {
+ SELECT b FROM t1 WHERE a IN ia3 ORDER BY a
+ }
+} {}
+
+do_test intarray-1.3 {
+ sqlite3_intarray_bind $ia3 45 123 678
+ db eval {
+ SELECT b FROM t1 WHERE a IN ia3 ORDER BY a
+ }
+} {x045 x123 x678}
+
+do_test intarray-1.4 {
+ db eval {
+ SELECT count(b) FROM t1 WHERE a NOT IN ia3 ORDER BY a
+ }
+} {996}
+
+#explain {SELECT b FROM t1 WHERE a NOT IN ia3}
+
+do_test intarray-1.5 {
+ set cmd sqlite3_intarray_bind
+ lappend cmd $ia1
+ for {set i 1} {$i<=999} {incr i} {
+ lappend cmd $i
+ lappend cmd [expr {$i+1000}]
+ lappend cmd [expr {$i+2000}]
+ }
+ eval $cmd
+ db eval {
+ REPLACE INTO t1 SELECT * FROM t2;
+ DELETE FROM t1 WHERE a NOT IN ia1;
+ SELECT count(*) FROM t1;
+ }
+} {999}
+
+do_test intarray-1.6 {
+ db eval {
+ DELETE FROM t1 WHERE a IN ia1;
+ SELECT count(*) FROM t1;
+ }
+} {0}
+
+do_test intarray-2.1 {
+ db eval {
+ CREATE TEMP TABLE t3(p,q);
+ INSERT INTO t3 SELECT * FROM t2;
+ SELECT count(*) FROM t3 WHERE p IN ia1;
+ }
+} {999}
+
+do_test intarray-2.2 {
+ set ia5 [sqlite3_intarray_create db ia5]
+ db eval {
+ SELECT count(*) FROM t3 WHERE p IN ia1;
+ }
+} {999}
+
+finish_test