guard against zero block size if provider initialization fails
[sqlcipher.git] / test / carray01.test
blobd6243eb2743bb0d7cf3c1b6934edee3381f6e2bf
1 # 2020-11-17
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11
12 # This file implements tests for CARRAY extension
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set testprefix carray01
19 ifcapable !vtab {
20   finish_test
21   return
23 load_static_extension db carray
25 # Parameter $stmt must be a prepared statement created using
26 # the sqlite3_prepare_v2 command and with parameters fullly bound.
27 # This routine simply runs the statement, gathers the result, and
28 # returns a list containing the result.
30 # If the optional second argument is true, then the stmt is finalized
31 # after it is run.
33 proc run_stmt {stmt {finalizeFlag 0}} {
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   if {$finalizeFlag} {
41     sqlite3_finalize $stmt
42   } else {
43     sqlite3_reset $stmt
44   }
45   return $r
48 do_test 100 {
49   set STMT [sqlite3_prepare_v2 db {SELECT 5 IN carray(?3)} -1]
50   sqlite3_carray_bind $STMT 3 1 2 3 4 5 6 7
51   run_stmt $STMT 0
52 } {1}
53 do_test 101 {
54   sqlite3_carray_bind -static $STMT 3 1 2 3 4 5 6 7
55   run_stmt $STMT 0
56 } {1}
57 do_test 110 {
58   sqlite3_carray_bind $STMT 3 1 2 3 4 6 7
59   run_stmt $STMT 0
60 } {0}
61 do_test 120 {
62   sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 5 6 7
63   run_stmt $STMT 0
64 } {1}
65 do_test 121 {
66   sqlite3_carray_bind -int64 -transient $STMT 3 1 2 3 4 5 6 7
67   run_stmt $STMT 0
68 } {1}
69 do_test 122 {
70   sqlite3_carray_bind -int64 -static $STMT 3 1 2 3 4 5 6 7
71   run_stmt $STMT 0
72 } {1}
73 do_test 123 {
74   sqlite3_carray_bind -int32 -transient $STMT 3 1 2 3 4 5 6 7
75   run_stmt $STMT 0
76 } {1}
77 do_test 124 {
78   sqlite3_carray_bind -int32 -static $STMT 3 1 2 3 4 5 6 7
79   run_stmt $STMT 0
80 } {1}
81 do_test 125 {
82   sqlite3_carray_bind -int32 $STMT 3 1 2 3 4 5 6 7
83   run_stmt $STMT 0
84 } {1}
85 do_test 130 {
86   sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 6 7
87   run_stmt $STMT 0
88 } {0}
89 do_test 131 {
90   sqlite3_carray_bind -int64 -transient $STMT 3 1 2 3 4 6 7
91   run_stmt $STMT 0
92 } {0}
93 do_test 131 {
94   sqlite3_carray_bind -int64 -static $STMT 3 1 2 3 4 6 7
95   run_stmt $STMT 0
96 } {0}
97 do_test 140 {
98   sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7
99   run_stmt $STMT 0
100 } {1}
101 do_test 141 {
102   sqlite3_carray_bind -double -transient $STMT 3 1 2 3 4 5 6 7
103   run_stmt $STMT 0
104 } {1}
105 do_test 142 {
106   sqlite3_carray_bind -double -static $STMT 3 1 2 3 4 5 6 7
107   run_stmt $STMT 0
108 } {1}
109 do_test 150 {
110   sqlite3_carray_bind -double $STMT 3 1 2 3 4 6 7
111   run_stmt $STMT 0
112 } {0}
113 do_test 160 {
114   sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7
115   run_stmt $STMT 0
116 } {1}
117 do_test 170 {
118   sqlite3_carray_bind -text -static $STMT 3 1 2 3 4 6 7
119   run_stmt $STMT 0
120 } {0}
121 do_test 180 {
122   sqlite3_carray_bind -text -transient $STMT 3 1 2 3 4 5 6 7
123   run_stmt $STMT 0
124 } {0}
125 do_test 190 {
126   sqlite3_carray_bind $STMT 3
127   run_stmt $STMT 0
128 } {0}
130 sqlite3_finalize $STMT
132 finish_test