xref: /illumos-gate/usr/src/lib/libsqlite/test/bind.test (revision 012e6ce759c490003aed29439cc47d3d73a99ad3)
1#
2# 2003 September 6
3#
4# The author disclaims copyright to this source code.  In place of
5# a legal notice, here is a blessing:
6#
7#    May you do good and not evil.
8#    May you find forgiveness for yourself and forgive others.
9#    May you share freely, never taking more than you give.
10#
11#***********************************************************************
12# This file implements regression tests for SQLite library.  The
13# focus of this script testing the sqlite_bind API.
14#
15# $Id: bind.test,v 1.1 2003/09/06 22:45:21 drh Exp $
16#
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20
21do_test bind-1.1 {
22  db close
23  set DB [sqlite db test.db]
24  execsql {CREATE TABLE t1(a,b,c)}
25  set VM [sqlite_compile $DB {INSERT INTO t1 VALUES(?,?,?)} TAIL]
26  set TAIL
27} {}
28do_test bind-1.2 {
29  sqlite_step $VM N VALUES COLNAMES
30} {SQLITE_DONE}
31do_test bind-1.3 {
32  execsql {SELECT rowid, * FROM t1}
33} {1 {} {} {}}
34do_test bind-1.4 {
35  sqlite_reset $VM
36  sqlite_bind $VM 1 {test value 1} normal
37  sqlite_step $VM N VALUES COLNAMES
38} SQLITE_DONE
39do_test bind-1.5 {
40  execsql {SELECT rowid, * FROM t1}
41} {1 {} {} {} 2 {test value 1} {} {}}
42do_test bind-1.6 {
43  sqlite_reset $VM
44  sqlite_bind $VM 3 {'test value 2'} normal
45  sqlite_step $VM N VALUES COLNAMES
46} SQLITE_DONE
47do_test bind-1.7 {
48  execsql {SELECT rowid, * FROM t1}
49} {1 {} {} {} 2 {test value 1} {} {} 3 {test value 1} {} {'test value 2'}}
50do_test bind-1.8 {
51  sqlite_reset $VM
52  set sqlite_static_bind_value 123
53  sqlite_bind $VM 1 {} static
54  sqlite_bind $VM 2 {abcdefg} normal
55  sqlite_bind $VM 3 {} null
56  execsql {DELETE FROM t1}
57  sqlite_step $VM N VALUES COLNAMES
58  execsql {SELECT rowid, * FROM t1}
59} {1 123 abcdefg {}}
60do_test bind-1.9 {
61  sqlite_reset $VM
62  sqlite_bind $VM 1 {456} normal
63  sqlite_step $VM N VALUES COLNAMES
64  execsql {SELECT rowid, * FROM t1}
65} {1 123 abcdefg {} 2 456 abcdefg {}}
66
67
68do_test bind-1.99 {
69  sqlite_finalize $VM
70} {}
71
72
73finish_test
74