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