| OLD | NEW |
| 1 # 2001 September 15 | 1 # 2001 September 15 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
| 4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
| 5 # | 5 # |
| 6 # May you do good and not evil. | 6 # May you do good and not evil. |
| 7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
| 8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
| 9 # | 9 # |
| 10 #*********************************************************************** | 10 #*********************************************************************** |
| 11 # This file implements regression tests for SQLite library. The | 11 # This file implements regression tests for SQLite library. The |
| 12 # focus of this file is exercising the code in main.c. | 12 # focus of this file is exercising the code in main.c. |
| 13 # | 13 # |
| 14 # $Id: main.test,v 1.32 2009/04/28 04:51:29 drh Exp $ | 14 # $Id: main.test,v 1.32 2009/04/28 04:51:29 drh Exp $ |
| 15 | 15 |
| 16 set testdir [file dirname $argv0] | 16 set testdir [file dirname $argv0] |
| 17 source $testdir/tester.tcl | 17 source $testdir/tester.tcl |
| 18 | 18 |
| 19 # Only do the next group of tests if the sqlite3_complete API is available | 19 # Only do the next group of tests if the sqlite3_complete API is available |
| 20 # | 20 # |
| 21 ifcapable {complete} { | 21 ifcapable {complete} { |
| 22 | 22 |
| 23 # Tests of the sqlite_complete() function. | 23 # Tests of the sqlite_complete() function. |
| 24 # | 24 # |
| 25 do_test main-1.1 { | 25 do_test main-1.1 { |
| 26 db complete {This is a test} | 26 db complete {This is a test} |
| 27 } {0} | 27 } {0} |
| 28 do_test main-1.2 { | 28 do_test main-1.2.0 { |
| 29 db complete { | 29 db complete { |
| 30 } | 30 } |
| 31 } {1} | 31 } {0} |
| 32 do_test main-1.3 { | 32 do_test main-1.2.1 { |
| 33 db complete {} |
| 34 } {0} |
| 35 do_test main-1.3.0 { |
| 33 db complete { | 36 db complete { |
| 34 -- a comment ; | 37 -- a comment ; |
| 35 } | 38 } |
| 36 } {1} | 39 } {0} |
| 37 do_test main-1.4 { | 40 do_test main-1.3.1 { |
| 41 db complete { |
| 42 /* a comment ; */ |
| 43 } |
| 44 } {0} |
| 45 do_test main-1.4.0 { |
| 38 db complete { | 46 db complete { |
| 39 -- a comment ; | 47 -- a comment ; |
| 40 ; | 48 ; |
| 41 } | 49 } |
| 42 } {1} | 50 } {1} |
| 51 do_test main-1.4.1 { |
| 52 db complete { |
| 53 /* a comment ; */ |
| 54 ; |
| 55 } |
| 56 } {1} |
| 57 do_test main-1.4.2 { |
| 58 db complete { |
| 59 /* a comment ; */ ; |
| 60 } |
| 61 } {1} |
| 43 do_test main-1.5 { | 62 do_test main-1.5 { |
| 44 db complete {DROP TABLE 'xyz;} | 63 db complete {DROP TABLE 'xyz;} |
| 45 } {0} | 64 } {0} |
| 46 do_test main-1.6 { | 65 do_test main-1.6 { |
| 47 db complete {DROP TABLE 'xyz';} | 66 db complete {DROP TABLE 'xyz';} |
| 48 } {1} | 67 } {1} |
| 49 do_test main-1.7 { | 68 do_test main-1.7 { |
| 50 db complete {DROP TABLE "xyz;} | 69 db complete {DROP TABLE "xyz;} |
| 51 } {0} | 70 } {0} |
| 52 do_test main-1.8 { | 71 do_test main-1.8 { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 db complete "create trigger\200;" | 291 db complete "create trigger\200;" |
| 273 } {1} | 292 } {1} |
| 274 do_test main-1.102 { | 293 do_test main-1.102 { |
| 275 db complete "create \200trigger;" | 294 db complete "create \200trigger;" |
| 276 } {1} | 295 } {1} |
| 277 } | 296 } |
| 278 | 297 |
| 279 | 298 |
| 280 # Try to open a database with a corrupt database file. | 299 # Try to open a database with a corrupt database file. |
| 281 # | 300 # |
| 282 do_test main-2.0 { | 301 if {[permutation] == ""} { |
| 283 catch {db close} | 302 do_test main-2.0 { |
| 284 file delete -force test.db | 303 catch {db close} |
| 285 set fd [open test.db w] | 304 file delete -force test.db |
| 286 puts $fd hi! | 305 set fd [open test.db w] |
| 287 close $fd | 306 puts $fd hi! |
| 288 set v [catch {sqlite3 db test.db} msg] | 307 close $fd |
| 289 if {$v} {lappend v $msg} {lappend v {}} | 308 set v [catch {sqlite3 db test.db} msg] |
| 290 } {0 {}} | 309 if {$v} {lappend v $msg} {lappend v {}} |
| 310 } {0 {}} |
| 311 } |
| 291 | 312 |
| 292 # Here are some tests for tokenize.c. | 313 # Here are some tests for tokenize.c. |
| 293 # | 314 # |
| 294 do_test main-3.1 { | 315 do_test main-3.1 { |
| 295 catch {db close} | 316 catch {db close} |
| 296 foreach f [glob -nocomplain testdb/*] {file delete -force $f} | 317 foreach f [glob -nocomplain testdb/*] {file delete -force $f} |
| 297 file delete -force testdb | 318 file delete -force testdb |
| 298 sqlite3 db testdb | 319 sqlite3 db testdb |
| 299 set v [catch {execsql {SELECT * from T1 where x!!5}} msg] | 320 set v [catch {execsql {SELECT * from T1 where x!!5}} msg] |
| 300 lappend v $msg | 321 lappend v $msg |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 list $rc $msg | 509 list $rc $msg |
| 489 } {1 {no such vfs: crash}} | 510 } {1 {no such vfs: crash}} |
| 490 do_test main-4.3 { | 511 do_test main-4.3 { |
| 491 set rc [catch {sqlite3 db test.db -vfs async} msg] | 512 set rc [catch {sqlite3 db test.db -vfs async} msg] |
| 492 list $rc $msg | 513 list $rc $msg |
| 493 } {1 {no such vfs: async}} | 514 } {1 {no such vfs: async}} |
| 494 } | 515 } |
| 495 } | 516 } |
| 496 | 517 |
| 497 finish_test | 518 finish_test |
| OLD | NEW |