123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- # 2009 February 24
- #
- # 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 regression tests for SQLite library.
- #
- # This file implements tests for the compile time diagnostic
- # functions.
- #
- set testdir [file dirname $argv0]
- source $testdir/tester.tcl
- # Test organization:
- #
- # ctime-1.*: Test pragma support.
- # ctime-2.*: Test function support.
- #
- ifcapable !pragma||!compileoption_diags {
- finish_test
- return
- }
- #####################
- # ctime-1.*: Test pragma support.
- do_test ctime-1.1.1 {
- catchsql {
- PRAGMA compile_options();
- }
- } {1 {near ")": syntax error}}
- do_test ctime-1.1.2 {
- catchsql {
- PRAGMA compile_options(NULL);
- }
- } {1 {near "NULL": syntax error}}
- do_test ctime-1.1.3 {
- catchsql {
- PRAGMA compile_options *;
- }
- } {1 {near "*": syntax error}}
- do_test ctime-1.2.1 {
- set ans [ catchsql {
- PRAGMA compile_options;
- } ]
- list [ lindex $ans 0 ]
- } {0}
- # the results should be in sorted order already
- do_test ctime-1.2.2 {
- set ans [ catchsql {
- PRAGMA compile_options;
- } ]
- list [ lindex $ans 0 ] [ expr { [lsort [lindex $ans 1]]==[lindex $ans 1] } ]
- } {0 1}
- # SQLITE_THREADSAFE should pretty much always be defined
- # one way or the other, and it must have a value of 0 or 1.
- do_test ctime-1.4.1 {
- catchsql {
- SELECT sqlite_compileoption_used('SQLITE_THREADSAFE');
- }
- } {0 1}
- do_test ctime-1.4.2 {
- catchsql {
- SELECT sqlite_compileoption_used('THREADSAFE');
- }
- } {0 1}
- do_test ctime-1.4.3 {
- catchsql {
- SELECT sqlite_compileoption_used("THREADSAFE");
- }
- } {0 1}
- do_test ctime-1.5 {
- set ans1 [ catchsql {
- SELECT sqlite_compileoption_used('THREADSAFE=0');
- } ]
- set ans2 [ catchsql {
- SELECT sqlite_compileoption_used('THREADSAFE=1');
- } ]
- set ans3 [ catchsql {
- SELECT sqlite_compileoption_used('THREADSAFE=2');
- } ]
- lsort [ list $ans1 $ans2 $ans3 ]
- } {{0 0} {0 0} {0 1}}
- do_test ctime-1.6 {
- execsql {
- SELECT sqlite_compileoption_used('THREADSAFE=');
- }
- } {0}
- do_test ctime-1.7.1 {
- execsql {
- SELECT sqlite_compileoption_used('SQLITE_OMIT_COMPILEOPTION_DIAGS');
- }
- } {0}
- do_test ctime-1.7.2 {
- execsql {
- SELECT sqlite_compileoption_used('OMIT_COMPILEOPTION_DIAGS');
- }
- } {0}
- #####################
- # ctime-2.*: Test function support.
- do_test ctime-2.1.1 {
- catchsql {
- SELECT sqlite_compileoption_used();
- }
- } {1 {wrong number of arguments to function sqlite_compileoption_used()}}
- do_test ctime-2.1.2 {
- catchsql {
- SELECT sqlite_compileoption_used(NULL);
- }
- } {0 {{}}}
- do_test ctime-2.1.3 {
- catchsql {
- SELECT sqlite_compileoption_used("");
- }
- } {0 0}
- do_test ctime-2.1.4 {
- catchsql {
- SELECT sqlite_compileoption_used('');
- }
- } {0 0}
- do_test ctime-2.1.5 {
- catchsql {
- SELECT sqlite_compileoption_used(foo);
- }
- } {1 {no such column: foo}}
- do_test ctime-2.1.6 {
- catchsql {
- SELECT sqlite_compileoption_used('THREADSAFE', 0);
- }
- } {1 {wrong number of arguments to function sqlite_compileoption_used()}}
- do_test ctime-2.1.7 {
- catchsql {
- SELECT sqlite_compileoption_used(0);
- }
- } {0 0}
- do_test ctime-2.1.8 {
- catchsql {
- SELECT sqlite_compileoption_used('0');
- }
- } {0 0}
- do_test ctime-2.1.9 {
- catchsql {
- SELECT sqlite_compileoption_used(1.0);
- }
- } {0 0}
- do_test ctime-2.2.1 {
- catchsql {
- SELECT sqlite_compileoption_get();
- }
- } {1 {wrong number of arguments to function sqlite_compileoption_get()}}
- do_test ctime-2.2.2 {
- catchsql {
- SELECT sqlite_compileoption_get(0, 0);
- }
- } {1 {wrong number of arguments to function sqlite_compileoption_get()}}
- # This assumes there is at least 1 compile time option
- # (see SQLITE_THREADSAFE above).
- do_test ctime-2.3 {
- catchsql {
- SELECT sqlite_compileoption_used(sqlite_compileoption_get(0));
- }
- } {0 1}
- # This assumes there is at least 1 compile time option
- # (see SQLITE_THREADSAFE above).
- do_test ctime-2.4 {
- set ans [ catchsql {
- SELECT sqlite_compileoption_get(0);
- } ]
- list [lindex $ans 0]
- } {0}
- # Get the list of defines using the pragma,
- # then try querying each one with the functions.
- set ans [ catchsql {
- PRAGMA compile_options;
- } ]
- set opts [ lindex $ans 1 ]
- set tc 1
- foreach opt $opts {
- do_test ctime-2.5.$tc {
- set N [ expr {$tc-1} ]
- set ans1 [ catchsql {
- SELECT sqlite_compileoption_get($N);
- } ]
- set ans2 [ catchsql {
- SELECT sqlite_compileoption_used($opt);
- } ]
- list [ lindex $ans1 0 ] [ expr { [lindex $ans1 1]==$opt } ] \
- [ expr { $ans2 } ]
- } {0 1 {0 1}}
- incr tc 1
- }
- # test 1 past array bounds
- do_test ctime-2.5.$tc {
- set N [ expr {$tc-1} ]
- set ans [ catchsql {
- SELECT sqlite_compileoption_get($N);
- } ]
- } {0 {{}}}
- incr tc 1
- # test 1 before array bounds (N=-1)
- do_test ctime-2.5.$tc {
- set N -1
- set ans [ catchsql {
- SELECT sqlite_compileoption_get($N);
- } ]
- } {0 {{}}}
- finish_test
|