1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/bindxfer.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,84 @@
1.4 +# 2005 April 21
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library. The
1.15 +# focus of this script testing the sqlite_transfer_bindings() API.
1.16 +#
1.17 +# $Id: bindxfer.test,v 1.5 2008/03/17 16:23:27 drh Exp $
1.18 +#
1.19 +
1.20 +set testdir [file dirname $argv0]
1.21 +source $testdir/tester.tcl
1.22 +
1.23 +proc sqlite_step {stmt VALS COLS} {
1.24 + upvar #0 $VALS vals
1.25 + upvar #0 $COLS cols
1.26 + set vals [list]
1.27 + set cols [list]
1.28 +
1.29 + set rc [sqlite3_step $stmt]
1.30 + for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {
1.31 + lappend cols [sqlite3_column_name $stmt $i]
1.32 + }
1.33 + for {set i 0} {$i < [sqlite3_data_count $stmt]} {incr i} {
1.34 + lappend vals [sqlite3_column_text $stmt $i]
1.35 + }
1.36 +
1.37 + return $rc
1.38 +}
1.39 +
1.40 +do_test bindxfer-1.1 {
1.41 + set DB [sqlite3_connection_pointer db]
1.42 + execsql {CREATE TABLE t1(a,b,c);}
1.43 + set VM1 [sqlite3_prepare $DB {SELECT ?, ?, ?} -1 TAIL]
1.44 + set TAIL
1.45 +} {}
1.46 +do_test bindxfer-1.2 {
1.47 + sqlite3_bind_parameter_count $VM1
1.48 +} 3
1.49 +do_test bindxfer-1.3 {
1.50 + set VM2 [sqlite3_prepare $DB {SELECT ?, ?, ?} -1 TAIL]
1.51 + set TAIL
1.52 +} {}
1.53 +do_test bindxfer-1.4 {
1.54 + sqlite3_bind_parameter_count $VM2
1.55 +} 3
1.56 +do_test bindxfer-1.5 {
1.57 + sqlite_bind $VM1 1 one normal
1.58 + set sqlite_static_bind_value two
1.59 + sqlite_bind $VM1 2 {} static
1.60 + sqlite_bind $VM1 3 {} null
1.61 + sqlite3_transfer_bindings $VM1 $VM2
1.62 + sqlite_step $VM1 VALUES COLNAMES
1.63 +} SQLITE_ROW
1.64 +do_test bindxfer-1.6 {
1.65 + set VALUES
1.66 +} {{} {} {}}
1.67 +do_test bindxfer-1.7 {
1.68 + sqlite_step $VM2 VALUES COLNAMES
1.69 +} SQLITE_ROW
1.70 +do_test bindxfer-1.8 {
1.71 + set VALUES
1.72 +} {one two {}}
1.73 +do_test bindxfer-1.9-misuse {
1.74 + catch {sqlite3_finalize $VM1}
1.75 + catch {sqlite3_finalize $VM2}
1.76 + sqlite3_transfer_bindings $VM1 $VM2
1.77 +} 21 ;# SQLITE_MISUSE
1.78 +do_test bindxfer-1.10 {
1.79 + set VM1 [sqlite3_prepare $DB {SELECT ?, ?, ?} -1 TAIL]
1.80 + set VM2 [sqlite3_prepare $DB {SELECT ?, ?, ?, ?} -1 TAIL]
1.81 + sqlite3_transfer_bindings $VM1 $VM2
1.82 +} 1 ;# SQLITE_ERROR
1.83 +catch {sqlite3_finalize $VM1}
1.84 +catch {sqlite3_finalize $VM2}
1.85 +
1.86 +
1.87 +finish_test