From e36d23a85ebff914d74bb541558c2b6082b78edb Mon Sep 17 00:00:00 2001 From: dan miller Date: Sat, 20 Oct 2007 02:49:29 +0000 Subject: sqlite source (unix build) added to libraries --- .../unix/sqlite-3.5.1/test/incrblob_err.test | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 libraries/sqlite/unix/sqlite-3.5.1/test/incrblob_err.test (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/incrblob_err.test') diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/incrblob_err.test b/libraries/sqlite/unix/sqlite-3.5.1/test/incrblob_err.test new file mode 100644 index 0000000..397b291 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/test/incrblob_err.test @@ -0,0 +1,102 @@ +# 2007 May 1 +# +# 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. +# +#*********************************************************************** +# +# $Id: incrblob_err.test,v 1.8 2007/09/12 17:01:45 danielk1977 Exp $ +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +ifcapable {!incrblob || !memdebug || !tclvar} { + finish_test + return +} + +source $testdir/malloc_common.tcl + +set ::fd [open [info script]] +set ::data [read $::fd] +close $::fd + +do_malloc_test 1 -tclprep { + set bytes [file size [info script]] + execsql { + CREATE TABLE blobs(k, v BLOB); + INSERT INTO blobs VALUES(1, zeroblob($::bytes)); + } +} -tclbody { + set ::blob [db incrblob blobs v 1] + set rc [catch {puts -nonewline $::blob $::data}] + if {$rc} { error "out of memory" } +} + +do_malloc_test 2 -tclprep { + execsql { + CREATE TABLE blobs(k, v BLOB); + INSERT INTO blobs VALUES(1, $::data); + } +} -tclbody { + set ::blob [db incrblob blobs v 1] + set rc [catch {set ::r [read $::blob]}] + if {$rc} { + error "out of memory" + } elseif {$::r ne $::data} { + error "Bad data read..." + } +} + +do_malloc_test 3 -tclprep { + execsql { + CREATE TABLE blobs(k, v BLOB); + INSERT INTO blobs VALUES(1, $::data); + } +} -tclbody { + set ::blob [db incrblob blobs v 1] + set rc [catch {set ::r [read $::blob]}] + if {$rc} { + error "out of memory" + } elseif {$::r ne $::data} { + error "Bad data read..." + } + set rc [catch {close $::blob}] + if {$rc} { + error "out of memory" + } +} + +do_ioerr_test incrblob_err-4 -cksum 1 -sqlprep { + CREATE TABLE blobs(k, v BLOB); + INSERT INTO blobs VALUES(1, $::data); +} -tclbody { + set ::blob [db incrblob blobs v 1] + read $::blob +} + +do_ioerr_test incrblob_err-5 -cksum 1 -sqlprep { + CREATE TABLE blobs(k, v BLOB); + INSERT INTO blobs VALUES(1, zeroblob(length(CAST($::data AS BLOB)))); +} -tclbody { + set ::blob [db incrblob blobs v 1] + puts -nonewline $::blob $::data + close $::blob +} + +do_ioerr_test incrblob_err-6 -cksum 1 -sqlprep { + CREATE TABLE blobs(k, v BLOB); + INSERT INTO blobs VALUES(1, $::data || $::data || $::data); +} -tclbody { + set ::blob [db incrblob blobs v 1] + seek $::blob -20 end + puts -nonewline $::blob "12345678900987654321" + close $::blob +} + +finish_test -- cgit v1.1