1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
# 2020-11-17
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file implements tests for CARRAY extension
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix carray01
ifcapable !vtab {
finish_test
return
}
load_static_extension db carray
# Parameter $stmt must be a prepared statement created using
# the sqlite3_prepare_v2 command and with parameters fully bound.
# This routine simply runs the statement, gathers the result, and
# returns a list containing the result.
#
# If the optional second argument is true, then the stmt is finalized
# after it is run.
#
proc run_stmt {stmt} {
set r {}
while {[sqlite3_step $stmt]=="SQLITE_ROW"} {
for {set i 0} {$i<[sqlite3_data_count $stmt]} {incr i} {
lappend r [sqlite3_column_text $stmt $i]
}
}
sqlite3_reset $stmt
return $r
}
do_test 100 {
set STMT [sqlite3_prepare_v2 db {SELECT 5 IN carray(?3)} -1]
sqlite3_carray_bind $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 101 {
sqlite3_carray_bind -static $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 102 {
set STMT2 [sqlite3_prepare_v2 db {
SELECT DISTINCT typeof(value) FROM carray(?3)} -1]
sqlite3_carray_bind $STMT2 3 1 2 3 4 5 6 7
run_stmt $STMT2
} {integer}
do_test 110 {
sqlite3_carray_bind $STMT 3 1 2 3 4 6 7
run_stmt $STMT
} {0}
do_test 120 {
sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 120b {
sqlite3_carray_bind -int64 $STMT2 3 1 2 3 4 5 6 7
run_stmt $STMT2
} {integer}
do_test 121 {
sqlite3_carray_bind -int64 -transient $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 122 {
sqlite3_carray_bind -int64 -static $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 123 {
sqlite3_carray_bind -int32 -transient $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 124 {
sqlite3_carray_bind -int32 -static $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 125 {
sqlite3_carray_bind -int32 $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 130 {
sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 6 7
run_stmt $STMT
} {0}
do_test 131 {
sqlite3_carray_bind -int64 -transient $STMT 3 1 2 3 4 6 7
run_stmt $STMT
} {0}
do_test 131 {
sqlite3_carray_bind -int64 -static $STMT 3 1 2 3 4 6 7
run_stmt $STMT
} {0}
do_test 140 {
sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 141 {
sqlite3_carray_bind -double -transient $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 142 {
sqlite3_carray_bind -double -static $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 143 {
sqlite3_carray_bind -double $STMT2 3 1 2 3 4 5 6 7
run_stmt $STMT2
} {real}
do_test 150 {
sqlite3_carray_bind -double $STMT 3 1 2 3 4 6 7
run_stmt $STMT
} {0}
do_test 160 {
sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {1}
do_test 170 {
sqlite3_carray_bind -text -static $STMT 3 1 2 3 4 6 7
run_stmt $STMT
} {0}
do_test 171 {
sqlite3_carray_bind -text -static $STMT2 3 1 2 3 4 6 7
run_stmt $STMT2
} {text}
do_test 180 {
sqlite3_carray_bind -text -transient $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {0}
do_test 190 {
sqlite3_carray_bind -blob -static $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {0}
do_test 191 {
sqlite3_carray_bind -blob -static $STMT2 3 1 2 3 4 5 6 7
run_stmt $STMT2
} {blob}
do_test 200 {
sqlite3_carray_bind -blob -transient $STMT 3 1 2 3 4 5 6 7
run_stmt $STMT
} {0}
do_test 300 {
sqlite3_carray_bind $STMT 3
run_stmt $STMT
} {0}
sqlite3_finalize $STMT
sqlite3_finalize $STMT2
finish_test
|