blob: 470d635da080bec1ecfc6bd3360713ea9ba40a0b [file] [log] [blame]
drh522efc62009-11-10 17:24:37 +00001# 2009 November 10
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11# This file implements regression tests for SQLite library.
12#
13# This file implements tests for the "intarray" object implemented
14# in test_intarray.c.
15#
16
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19
20ifcapable !vtab {
21 return
22}
23
24do_test intarray-1.0 {
25 db eval {
26 CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
27 }
28 for {set i 1} {$i<=999} {incr i} {
29 set b [format {x%03d} $i]
30 db eval {INSERT INTO t1(a,b) VALUES($i,$b)}
31 }
32 db eval {
33 SELECT b FROM t1 WHERE a IN (12,34,56,78) ORDER BY a
34 }
35} {x012 x034 x056 x078}
36
37do_test intarray-1.1 {
38 set ia1 [sqlite3_intarray_create db ia1]
39 set ia2 [sqlite3_intarray_create db ia2]
40 set ia3 [sqlite3_intarray_create db ia3]
41 set ia4 [sqlite3_intarray_create db ia4]
42 db eval {
43 SELECT type, name FROM sqlite_temp_master
44 ORDER BY name
45 }
46} {table ia1 table ia2 table ia3 table ia4}
47
48do_test intarray-1.2 {
49 db eval {
50 SELECT b FROM t1 WHERE a IN ia3 ORDER BY a
51 }
52} {}
53
54do_test intarray-1.3 {
55 sqlite3_intarray_bind $ia3 45 123 678
56 db eval {
57 SELECT b FROM t1 WHERE a IN ia3 ORDER BY a
58 }
59} {x045 x123 x678}
60
61
62finish_test