CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
carray01.test160 linesDownload Raw Back to test
1# 2020-11-172#3# The author disclaims copyright to this source code.  In place of4# 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# 12# This file implements tests for CARRAY extension13#14 15set testdir [file dirname $argv0]16source $testdir/tester.tcl17set testprefix carray0118 19ifcapable !vtab {20  finish_test21  return22}23#load_static_extension db carray24 25# Parameter $stmt must be a prepared statement created using26# the sqlite3_prepare_v2 command and with parameters fully bound.27# This routine simply runs the statement, gathers the result, and28# returns a list containing the result.29#30# If the optional second argument is true, then the stmt is finalized31# after it is run.32#33proc run_stmt {stmt} {34  set r {}35  while {[sqlite3_step $stmt]=="SQLITE_ROW"} {36    for {set i 0} {$i<[sqlite3_data_count $stmt]} {incr i} {37      lappend r [sqlite3_column_text $stmt $i]38    }39  }40  sqlite3_reset $stmt41  return $r42}43 44do_test 100 {45  set STMT [sqlite3_prepare_v2 db {SELECT 5 IN carray(?3)} -1]46  sqlite3_carray_bind $STMT 3 1 2 3 4 5 6 747  run_stmt $STMT48} {1}49do_test 101 {50  sqlite3_carray_bind -static $STMT 3 1 2 3 4 5 6 751  run_stmt $STMT52} {1}53do_test 102 {54  set STMT2 [sqlite3_prepare_v2 db {55       SELECT DISTINCT typeof(value) FROM carray(?3)} -1]56  sqlite3_carray_bind $STMT2 3 1 2 3 4 5 6 757  run_stmt $STMT258} {integer}59do_test 110 {60  sqlite3_carray_bind $STMT 3 1 2 3 4 6 761  run_stmt $STMT62} {0}63do_test 120 {64  sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 5 6 765  run_stmt $STMT66} {1}67do_test 120b {68  sqlite3_carray_bind -int64 $STMT2 3 1 2 3 4 5 6 769  run_stmt $STMT270} {integer}71do_test 121 {72  sqlite3_carray_bind -int64 -transient $STMT 3 1 2 3 4 5 6 773  run_stmt $STMT74} {1}75do_test 122 {76  sqlite3_carray_bind -int64 -static $STMT 3 1 2 3 4 5 6 777  run_stmt $STMT78} {1}79do_test 123 {80  sqlite3_carray_bind -int32 -transient $STMT 3 1 2 3 4 5 6 781  run_stmt $STMT82} {1}83do_test 124 {84  sqlite3_carray_bind -int32 -static $STMT 3 1 2 3 4 5 6 785  run_stmt $STMT86} {1}87do_test 125 {88  sqlite3_carray_bind -int32 $STMT 3 1 2 3 4 5 6 789  run_stmt $STMT90} {1}91do_test 130 {92  sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 6 793  run_stmt $STMT94} {0}95do_test 131 {96  sqlite3_carray_bind -int64 -transient $STMT 3 1 2 3 4 6 797  run_stmt $STMT98} {0}99do_test 131 {100  sqlite3_carray_bind -int64 -static $STMT 3 1 2 3 4 6 7101  run_stmt $STMT102} {0}103do_test 140 {104  sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7105  run_stmt $STMT106} {1}107do_test 141 {108  sqlite3_carray_bind -double -transient $STMT 3 1 2 3 4 5 6 7109  run_stmt $STMT110} {1}111do_test 142 {112  sqlite3_carray_bind -double -static $STMT 3 1 2 3 4 5 6 7113  run_stmt $STMT114} {1}115do_test 143 {116  sqlite3_carray_bind -double $STMT2 3 1 2 3 4 5 6 7117  run_stmt $STMT2118} {real}119do_test 150 {120  sqlite3_carray_bind -double $STMT 3 1 2 3 4 6 7121  run_stmt $STMT122} {0}123do_test 160 {124  sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7125  run_stmt $STMT126} {1}127do_test 170 {128  sqlite3_carray_bind -text -static $STMT 3 1 2 3 4 6 7129  run_stmt $STMT130} {0}131do_test 171 {132  sqlite3_carray_bind -text -static $STMT2 3 1 2 3 4 6 7133  run_stmt $STMT2134} {text}135do_test 180 {136  sqlite3_carray_bind -text -transient $STMT 3 1 2 3 4 5 6 7137  run_stmt $STMT138} {0}139do_test 190 {140  sqlite3_carray_bind -blob -static $STMT 3 1 2 3 4 5 6 7141  run_stmt $STMT142} {0}143do_test 191 {144  sqlite3_carray_bind -blob -static $STMT2 3 1 2 3 4 5 6 7145  run_stmt $STMT2146} {blob}147do_test 200 {148  sqlite3_carray_bind -blob -transient $STMT 3 1 2 3 4 5 6 7149  run_stmt $STMT150} {0}151do_test 300 {152  sqlite3_carray_bind $STMT 3153  run_stmt $STMT154} {0}155 156sqlite3_finalize $STMT157sqlite3_finalize $STMT2158 159finish_test160