blob: 639eaaec4c1e158b00357d2ed5cb0995562b47a4 [file] [log] [blame]
drh82a48512003-09-06 22:45:20 +00001# 2003 September 6
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. The
12# focus of this script testing the sqlite_bind API.
13#
14# $Id: bind.test,v 1.1 2003/09/06 22:45:21 drh Exp $
15#
16
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19
20do_test bind-1.1 {
21 db close
22 set DB [sqlite db test.db]
23 execsql {CREATE TABLE t1(a,b,c)}
24 set VM [sqlite_compile $DB {INSERT INTO t1 VALUES(?,?,?)} TAIL]
25 set TAIL
26} {}
27do_test bind-1.2 {
28 sqlite_step $VM N VALUES COLNAMES
29} {SQLITE_DONE}
30do_test bind-1.3 {
31 execsql {SELECT rowid, * FROM t1}
32} {1 {} {} {}}
33do_test bind-1.4 {
34 sqlite_reset $VM
35 sqlite_bind $VM 1 {test value 1} normal
36 sqlite_step $VM N VALUES COLNAMES
37} SQLITE_DONE
38do_test bind-1.5 {
39 execsql {SELECT rowid, * FROM t1}
40} {1 {} {} {} 2 {test value 1} {} {}}
41do_test bind-1.6 {
42 sqlite_reset $VM
43 sqlite_bind $VM 3 {'test value 2'} normal
44 sqlite_step $VM N VALUES COLNAMES
45} SQLITE_DONE
46do_test bind-1.7 {
47 execsql {SELECT rowid, * FROM t1}
48} {1 {} {} {} 2 {test value 1} {} {} 3 {test value 1} {} {'test value 2'}}
49do_test bind-1.8 {
50 sqlite_reset $VM
51 set sqlite_static_bind_value 123
52 sqlite_bind $VM 1 {} static
53 sqlite_bind $VM 2 {abcdefg} normal
54 sqlite_bind $VM 3 {} null
55 execsql {DELETE FROM t1}
56 sqlite_step $VM N VALUES COLNAMES
57 execsql {SELECT rowid, * FROM t1}
58} {1 123 abcdefg {}}
59do_test bind-1.9 {
60 sqlite_reset $VM
61 sqlite_bind $VM 1 {456} normal
62 sqlite_step $VM N VALUES COLNAMES
63 execsql {SELECT rowid, * FROM t1}
64} {1 123 abcdefg {} 2 456 abcdefg {}}
65
66
67do_test bind-1.99 {
68 sqlite_finalize $VM
69} {}
70
71
72finish_test