mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
Improved test coverage for util.c. (CVS 2194)
FossilOrigin-Name: ad451a2ddc7993035768f2801d590311807f4397
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
# This file implements tests for miscellanous features that were
|
||||
# left out of other test files.
|
||||
#
|
||||
# $Id: misc4.test,v 1.8 2004/11/22 13:35:42 danielk1977 Exp $
|
||||
# $Id: misc4.test,v 1.9 2005/01/11 15:28:33 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -99,5 +99,4 @@ do_test misc4-3.1 {
|
||||
} {{} {} 1 x 1 z}
|
||||
} ;# ifcapable compound
|
||||
|
||||
|
||||
finish_test
|
||||
|
69
test/safety.test
Normal file
69
test/safety.test
Normal file
@ -0,0 +1,69 @@
|
||||
# 2005 January 11
|
||||
#
|
||||
# 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. The
|
||||
# focus of this file is testing the sqlite3SafetyOn and sqlite3SafetyOff
|
||||
# functions. Those routines are not strictly necessary - they are
|
||||
# designed to detect misuse of the library.
|
||||
#
|
||||
# $Id: safety.test,v 1.1 2005/01/11 15:28:33 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
do_test safety-1.1 {
|
||||
db close
|
||||
set DB [sqlite3 db test.db]
|
||||
db eval {CREATE TABLE t1(a)}
|
||||
sqlite_set_magic $DB SQLITE_MAGIC_BUSY
|
||||
catchsql {
|
||||
SELECT name FROM sqlite_master;
|
||||
}
|
||||
} {1 {library routine called out of sequence}}
|
||||
do_test safety-1.2 {
|
||||
sqlite_set_magic $DB SQLITE_MAGIC_OPEN
|
||||
catchsql {
|
||||
SELECT name FROM sqlite_master
|
||||
}
|
||||
} {0 t1}
|
||||
|
||||
do_test safety-2.1 {
|
||||
proc safety_on {} "sqlite_set_magic $DB SQLITE_MAGIC_BUSY"
|
||||
db function safety_on safety_on
|
||||
catchsql {
|
||||
SELECT safety_on(), name FROM sqlite_master
|
||||
}
|
||||
} {1 {library routine called out of sequence}}
|
||||
do_test safety-2.2 {
|
||||
catchsql {
|
||||
SELECT 'hello'
|
||||
}
|
||||
} {1 {library routine called out of sequence}}
|
||||
do_test safety-2.3 {
|
||||
sqlite3_close $DB
|
||||
} {SQLITE_MISUSE}
|
||||
do_test safety-2.4 {
|
||||
sqlite_set_magic $DB SQLITE_MAGIC_OPEN
|
||||
execsql {
|
||||
SELECT name FROM sqlite_master
|
||||
}
|
||||
} {t1}
|
||||
|
||||
do_test safety-3.1 {
|
||||
set rc [catch {
|
||||
db eval {SELECT name FROM sqlite_master} {
|
||||
sqlite_set_magic $DB SQLITE_MAGIC_BUSY
|
||||
}
|
||||
} msg]
|
||||
lappend rc $msg
|
||||
} {1 {library routine called out of sequence}}
|
||||
sqlite_set_magic $DB SQLITE_MAGIC_OPEN
|
||||
|
||||
finish_test
|
Reference in New Issue
Block a user