1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

More coverage testing. (CVS 1754)

FossilOrigin-Name: 332921041040b343b6b568685ff55d21a624f502
This commit is contained in:
danielk1977
2004-06-28 13:09:11 +00:00
parent 2ec81649a5
commit f46188911d
11 changed files with 329 additions and 91 deletions

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script testing the sqlite_bind API.
#
# $Id: bind.test,v 1.13 2004/06/22 12:46:54 drh Exp $
# $Id: bind.test,v 1.14 2004/06/28 13:09:11 danielk1977 Exp $
#
set testdir [file dirname $argv0]
@ -231,6 +231,30 @@ do_test bind-8.7 {
encoding convertfrom unicode [sqlite3_errmsg16 $DB]
} {bind index out of range}
do_test bind-8.8 {
catch { sqlite3_bind_blob $VM 0 "abc" 3 }
} {1}
do_test bind-8.9 {
catch { sqlite3_bind_blob $VM 4 "abc" 3 }
} {1}
do_test bind-8.10 {
catch { sqlite3_bind_text $VM 0 "abc" 3 }
} {1}
do_test bind-8.11 {
catch { sqlite3_bind_text16 $VM 4 "abc" 2 }
} {1}
do_test bind-8.12 {
catch { sqlite3_bind_int $VM 0 5 }
} {1}
do_test bind-8.13 {
catch { sqlite3_bind_int $VM 4 5 }
} {1}
do_test bind-8.14 {
catch { sqlite3_bind_double $VM 0 5.0 }
} {1}
do_test bind-8.15 {
catch { sqlite3_bind_double $VM 4 6.0 }
} {1}
do_test bind-9.99 {
sqlite3_finalize $VM

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script testing the callback-free C/C++ API.
#
# $Id: capi3.test,v 1.13 2004/06/27 01:56:33 drh Exp $
# $Id: capi3.test,v 1.14 2004/06/28 13:09:11 danielk1977 Exp $
#
set testdir [file dirname $argv0]
@ -181,8 +181,8 @@ proc check_header {STMT test names decltypes} {
# a list of column indexes. i.e. If sqlite3_column_count
# is 3, build the list {0 1 2}.
set ::idxlist [list]
set numcols [sqlite3_column_count $STMT]
for {set i 0} {$i < $numcols} {incr i} {lappend ::idxlist $i}
set ::numcols [sqlite3_column_count $STMT]
for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}
# Column names in UTF-8
do_test $test.1 {
@ -232,6 +232,20 @@ proc check_header {STMT test names decltypes} {
set cnamelist
} $decltypes
# Test some out of range conditions:
do_test $test.7 {
list \
[sqlite3_column_name $STMT -1] \
[sqlite3_column_name16 $STMT -1] \
[sqlite3_column_decltype $STMT -1] \
[sqlite3_column_decltype16 $STMT -1] \
[sqlite3_column_name $STMT $numcols] \
[sqlite3_column_name16 $STMT $numcols] \
[sqlite3_column_decltype $STMT $numcols] \
[sqlite3_column_decltype16 $STMT $numcols]
} {{} {} {} {} {} {} {} {}}
}
# This proc is used to test the following APIs:
@ -275,38 +289,52 @@ do_test $test.1 {
# Integers
do_test $test.2 {
set ints [list]
foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]}
foreach i $idxlist {lappend ints [sqlite3_column_int64 $STMT $i]}
set ints
} $ints
# UTF-8
# bytes
set lens [list]
foreach i $::idxlist {
lappend lens [string length [lindex $strings $i]]
}
do_test $test.3 {
set bytes [list]
set lens [list]
foreach i $idxlist {
lappend bytes [sqlite3_column_bytes $STMT $i]
}
set bytes
} $lens
# bytes16
set lens [list]
foreach i $::idxlist {
lappend lens [expr 2 * [string length [lindex $strings $i]]]
}
do_test $test.4 {
set bytes [list]
set lens [list]
foreach i $idxlist {
lappend bytes [sqlite3_column_bytes16 $STMT $i]
}
set bytes
} $lens
# Blob
do_test $test.5 {
set utf8 [list]
foreach i $idxlist {lappend utf8 [sqlite3_column_blob $STMT $i]}
set utf8
} $strings
# UTF-8
do_test $test.6 {
set utf8 [list]
foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}
set utf8
} $strings
# Floats
do_test $test.4 {
set utf8 [list]
foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}
set utf8
} $doubles
# UTF-16
do_test $test.5 {
set utf8 [list]
foreach i $idxlist {lappend utf8 [utf8 [sqlite3_column_text16 $STMT $i]]}
set utf8
} $strings
# Integers
do_test $test.6 {
set ints [list]
foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]}
set ints
} $ints
# Floats
do_test $test.7 {
set utf8 [list]
@ -314,20 +342,49 @@ do_test $test.7 {
set utf8
} $doubles
# UTF-8
# UTF-16
do_test $test.8 {
set utf8 [list]
foreach i $idxlist {lappend utf8 [utf8 [sqlite3_column_text16 $STMT $i]]}
set utf8
} $strings
# Integers
do_test $test.9 {
set ints [list]
foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]}
set ints
} $ints
# Floats
do_test $test.10 {
set utf8 [list]
foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}
set utf8
} $doubles
# UTF-8
do_test $test.11 {
set utf8 [list]
foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}
set utf8
} $strings
# Types
do_test $test.9 {
do_test $test.12 {
set types [list]
foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}
set types
} $types
# Test that an out of range request returns the equivalent of NULL
do_test $test.13 {
sqlite3_column_int $STMT -1
} {0}
do_test $test.13 {
sqlite3_column_text $STMT -1
} {}
}
do_test capi3-5.0 {

57
test/utf16.test Normal file
View File

@ -0,0 +1,57 @@
# 2001 September 15
#
# 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 runs all tests.
#
# $Id: utf16.test,v 1.1 2004/06/28 13:09:11 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
rename finish_test really_finish_test2
proc finish_test {} {}
set ISQUICK 1
set FILES {
func.test
}
rename sqlite3 real_sqlite3
proc sqlite3 {args} {
set r [eval "real_sqlite3 $args"]
if { [llength $args] == 2 } {
[lindex $args 0] eval {pragma encoding = 'UTF-16'}
}
set r
}
rename do_test really_do_test
proc do_test {args} {
set sc [concat really_do_test "utf16-[lindex $args 0]" [lrange $args 1 end]]
eval $sc
}
foreach f $FILES {
set testfile $testdir/$f
source $testfile
catch {db close}
if {$sqlite_open_file_count>0} {
puts "$tail did not close all files: $sqlite_open_file_count"
incr nErr
lappend ::failList $tail
}
}
rename sqlite3 ""
rename real_sqlite3 sqlite3
rename finish_test ""
rename really_finish_test2 finish_test
rename do_test ""
rename really_do_test do_test