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 # This file implements regression tests for SQLite library.
13 # This file implements tests for the compile time diagnostic
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
22 # ctime-1.*: Test pragma support.
23 # ctime-2.*: Test function support.
26 ifcapable !pragma||!compileoption_diags {
32 # ctime-1.*: Test pragma support.
36 PRAGMA compile_options();
38 } {1 {near ")": syntax error}}
41 PRAGMA compile_options(NULL);
43 } {1 {near "NULL": syntax error}}
46 PRAGMA compile_options *;
48 } {1 {near "*": syntax error}}
52 PRAGMA compile_options;
54 list [ lindex $ans 0 ]
56 # the results should be in sorted order already
59 PRAGMA compile_options;
61 list [ lindex $ans 0 ] [ expr { [lsort [lindex $ans 1]]==[lindex $ans 1] } ]
64 # SQLITE_THREADSAFE should pretty much always be defined
65 # one way or the other, and it must have a value of 0 or 1.
68 SELECT sqlite_compileoption_used('SQLITE_THREADSAFE');
73 SELECT sqlite_compileoption_used('THREADSAFE');
78 SELECT sqlite_compileoption_used("THREADSAFE");
84 SELECT sqlite_compileoption_used('THREADSAFE=0');
87 SELECT sqlite_compileoption_used('THREADSAFE=1');
90 SELECT sqlite_compileoption_used('THREADSAFE=2');
92 lsort [ list $ans1 $ans2 $ans3 ]
97 SELECT sqlite_compileoption_used('THREADSAFE=');
101 do_test ctime-1.7.1 {
103 SELECT sqlite_compileoption_used('SQLITE_OMIT_COMPILEOPTION_DIAGS');
106 do_test ctime-1.7.2 {
108 SELECT sqlite_compileoption_used('OMIT_COMPILEOPTION_DIAGS');
112 #####################
113 # ctime-2.*: Test function support.
115 do_test ctime-2.1.1 {
117 SELECT sqlite_compileoption_used();
119 } {1 {wrong number of arguments to function sqlite_compileoption_used()}}
120 do_test ctime-2.1.2 {
122 SELECT sqlite_compileoption_used(NULL);
125 do_test ctime-2.1.3 {
127 SELECT sqlite_compileoption_used("");
130 do_test ctime-2.1.4 {
132 SELECT sqlite_compileoption_used('');
135 do_test ctime-2.1.5 {
137 SELECT sqlite_compileoption_used(foo);
139 } {1 {no such column: foo}}
140 do_test ctime-2.1.6 {
142 SELECT sqlite_compileoption_used('THREADSAFE', 0);
144 } {1 {wrong number of arguments to function sqlite_compileoption_used()}}
145 do_test ctime-2.1.7 {
147 SELECT sqlite_compileoption_used(0);
150 do_test ctime-2.1.8 {
152 SELECT sqlite_compileoption_used('0');
155 do_test ctime-2.1.9 {
157 SELECT sqlite_compileoption_used(1.0);
161 do_test ctime-2.2.1 {
163 SELECT sqlite_compileoption_get();
165 } {1 {wrong number of arguments to function sqlite_compileoption_get()}}
166 do_test ctime-2.2.2 {
168 SELECT sqlite_compileoption_get(0, 0);
170 } {1 {wrong number of arguments to function sqlite_compileoption_get()}}
172 # This assumes there is at least 1 compile time option
173 # (see SQLITE_THREADSAFE above).
176 SELECT sqlite_compileoption_used(sqlite_compileoption_get(0));
180 # This assumes there is at least 1 compile time option
181 # (see SQLITE_THREADSAFE above).
184 SELECT sqlite_compileoption_get(0);
189 # Get the list of defines using the pragma,
190 # then try querying each one with the functions.
192 PRAGMA compile_options;
194 set opts [ lindex $ans 1 ]
197 do_test ctime-2.5.$tc {
198 set N [ expr {$tc-1} ]
199 set ans1 [ catchsql {
200 SELECT sqlite_compileoption_get($N);
202 set ans2 [ catchsql {
203 SELECT sqlite_compileoption_used($opt);
205 list [ lindex $ans1 0 ] [ expr { [lindex $ans1 1]==$opt } ] \
210 # test 1 past array bounds
211 do_test ctime-2.5.$tc {
212 set N [ expr {$tc-1} ]
214 SELECT sqlite_compileoption_get($N);
218 # test 1 before array bounds (N=-1)
219 do_test ctime-2.5.$tc {
222 SELECT sqlite_compileoption_get($N);