gitlab.com/CoiaPrant/sqlite3@v1.19.1/testdata/tcl/uri2.test (about) 1 # 2016 October 26 2 # 3 # The author disclaims copyright to this source code. In place of 4 # 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 # Tests for SQLITE_ENABLE_URI_00_ERROR builds. 13 14 set testdir [file dirname $argv0] 15 source $testdir/tester.tcl 16 17 ifcapable !uri_00_error { 18 finish_test 19 return 20 } 21 22 set testprefix uri2 23 db close 24 sqlite3_shutdown 25 sqlite3_config_uri 1 26 27 foreach {tn uri} { 28 1 file:test.db%00trailing 29 2 file:test.db?%00trailing=1 30 3 file:test.db?trailing=1%00 31 4 file:test.db?trailing=1&abc%00def 32 5 file:test.db?trailing=1&abc%00def 33 } { 34 do_test 1.$tn.1 { 35 set rc [catch { sqlite3 db $uri } msg] 36 list $rc $msg 37 } {1 {unexpected %00 in uri}} 38 39 do_test 1.$tn.2 { 40 set DB2 [sqlite3_open $uri] 41 sqlite3_errcode $DB2 42 } {SQLITE_ERROR} 43 44 catch { sqlite3_close $DB2 } 45 46 do_test 1.$tn.2 { 47 sqlite3 db "" 48 catchsql { ATTACH $uri AS aux } 49 } {1 {unexpected %00 in uri}} 50 51 do_test 1.$tn.3 { 52 sqlite3_errcode db 53 } {SQLITE_ERROR} 54 55 catch { db close } 56 } 57 58 reset_db 59 do_test 2.0 { 60 expr {[lsearch [execsql {PRAGMA compile_options}] ENABLE_URI_00_ERROR] >= 0} 61 } 1 62 63 finish_test