1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Test cases to improve coverage of vdbe.c. (CVS 2193)

FossilOrigin-Name: a6b45722071bde543c4ea28a432339d8708a5cac
This commit is contained in:
danielk1977
2005-01-11 13:02:33 +00:00
parent 1400b52838
commit 01427a6214
7 changed files with 103 additions and 34 deletions

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing built-in functions.
#
# $Id: func.test,v 1.29 2004/08/20 18:34:20 drh Exp $
# $Id: func.test,v 1.30 2005/01/11 13:02:34 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -452,4 +452,10 @@ do_test func-14.2 {
}
} {1}
do_test func-15.1 {
catchsql {
select test_error(NULL);
}
} {1 {user function error}}
finish_test

View File

@ -15,7 +15,7 @@
# The tests in this file use special facilities that are only
# available in the SQLite test fixture.
#
# $Id: ioerr.test,v 1.9 2005/01/11 10:25:07 danielk1977 Exp $
# $Id: ioerr.test,v 1.10 2005/01/11 13:02:34 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -174,4 +174,33 @@ for {set n 1} {$go} {incr n} {
}
set ::sqlite_io_error_pending 0
set ::go 1
for {set n 1} {$go} {incr n} {
do_test ioerr-4.$n.1 {
set ::sqlite_io_error_pending 0
db close
catch {file delete -force test.db}
catch {file delete -force test.db-journal}
sqlite3 db test.db
set sql "CREATE TABLE abc(a1"
for {set i 2} {$i<1300} {incr i} {
append sql ", a$i"
}
append sql ");"
execsql $sql
execsql {INSERT INTO abc (a1) VALUES(NULL)}
} {}
do_test ioerr-4.$n.2 [subst {
set ::sqlite_io_error_pending $n
}] $n
do_test ioerr-4.$n.3 {
set r [catch {db eval {
SELECT * FROM abc;
}} msg]
set ::go [expr {$::sqlite_io_error_pending<=0}]
expr {$::sqlite_io_error_pending>0 || $r!=0}
} {1}
}
set ::sqlite_io_error_pending 0
finish_test

View File

@ -14,7 +14,7 @@
# special feature is used to see what happens in the library if a malloc
# were to really fail due to an out-of-memory situation.
#
# $Id: malloc.test,v 1.12 2005/01/03 01:33:00 drh Exp $
# $Id: malloc.test,v 1.13 2005/01/11 13:02:34 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -304,6 +304,36 @@ for {set go 1; set i 1} {$go} {incr i} {
} {1 1}
}
for {set go 1; set i 1} {$go} {incr i} {
do_test malloc-7.$i {
sqlite_malloc_fail 0
catch {db close}
catch {file delete -force test.db}
catch {file delete -force test.db-journal}
sqlite3 db test.db
execsql {
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(1, 2);
INSERT INTO t1 VALUES(3, 4);
INSERT INTO t1 VALUES(5, 6);
}
sqlite_malloc_fail $i
set v [catch {execsql {
SELECT min(a) FROM t1 GROUP BY b;
}} msg]
set leftover [lindex [sqlite_malloc_stat] 2]
if {$leftover>0} {
if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"}
set ::go 0
set v {1 1}
} else {
set v2 [expr {$msg=="" || $msg=="out of memory"}]
if {!$v2} {puts "\nError message returned: $msg"}
lappend v $v2
}
} {1 1}
}
# Ensure that no file descriptors were leaked.
do_test malloc-6.X {
catch {db close}