1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt2332.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,67 @@
1.4 +# 2007 May 3
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +#
1.15 +# $Id: tkt2332.test,v 1.4 2007/09/12 17:01:45 danielk1977 Exp $
1.16 +#
1.17 +
1.18 +set testdir [file dirname $argv0]
1.19 +source $testdir/tester.tcl
1.20 +
1.21 +ifcapable !incrblob||!tclvar {
1.22 + finish_test
1.23 + return
1.24 +}
1.25 +
1.26 +do_test tkt2332.1 {
1.27 + execsql {
1.28 + CREATE TABLE blobs (k INTEGER PRIMARY KEY, v BLOB);
1.29 + PRAGMA cache_size = 100;
1.30 + }
1.31 +} {}
1.32 +
1.33 +set ::iKey 1
1.34 +foreach Len [list 10000 100000 1000000] {
1.35 + do_test tkt2332.$Len.1 {
1.36 + set val "[expr rand()][expr rand()][expr rand()][expr rand()][expr rand()]"
1.37 + set ::blobstr [string range \
1.38 + [string repeat $val [expr ($Len/[string length $val])+1]] 0 [expr $Len-1]
1.39 + ]
1.40 +
1.41 + db eval { INSERT INTO blobs VALUES($::iKey, zeroblob($Len)) }
1.42 + } {}
1.43 +
1.44 + do_test tkt2332.$Len.2 {
1.45 + execsql {
1.46 + SELECT length(v) FROM blobs WHERE k = $::iKey;
1.47 + }
1.48 + } $Len
1.49 +
1.50 + do_test tkt2332.$Len.3 {
1.51 + set ::fd [db incrblob blobs v $::iKey]
1.52 + puts -nonewline $::fd $::blobstr
1.53 + close $::fd
1.54 + } {}
1.55 +
1.56 + do_test tkt2332.$Len.4 {
1.57 + execsql { SELECT length(v) FROM blobs WHERE k = $::iKey; }
1.58 + } $Len
1.59 +
1.60 + do_test tkt2332.$Len.5 {
1.61 + lindex [execsql {SELECT v FROM blobs WHERE k = $::iKey}] 0
1.62 + } $::blobstr
1.63 +
1.64 + incr ::iKey
1.65 +}
1.66 +
1.67 +# Free memory:
1.68 +unset ::blobstr
1.69 +
1.70 +finish_test