1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/mallocG.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,68 @@
1.4 +# 2007 Aug 29
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 +# This test script checks malloc failures in various obscure operations.
1.16 +#
1.17 +# $Id: mallocG.test,v 1.5 2008/08/01 18:47:02 drh Exp $
1.18 +
1.19 +set testdir [file dirname $argv0]
1.20 +source $testdir/tester.tcl
1.21 +source $testdir/malloc_common.tcl
1.22 +
1.23 +# Only run these tests if memory debugging is turned on.
1.24 +#
1.25 +if {!$MEMDEBUG} {
1.26 + puts "Skipping mallocG tests: not compiled with -DSQLITE_MEMDEBUG..."
1.27 + finish_test
1.28 + return
1.29 +}
1.30 +
1.31 +# Malloc failures while opening a database connection.
1.32 +#
1.33 +do_malloc_test mallocG-1 -tclbody {
1.34 + db close
1.35 + sqlite3 db test.db
1.36 +}
1.37 +
1.38 +do_malloc_test mallocG-2 -sqlprep {
1.39 + CREATE TABLE t1(x, y);
1.40 + CREATE TABLE t2(x INTEGER PRIMARY KEY);
1.41 +} -sqlbody {
1.42 + SELECT y FROM t1 WHERE x IN t2;
1.43 +}
1.44 +
1.45 +do_malloc_test mallocG-3 -sqlprep {
1.46 + CREATE TABLE t1(x UNIQUE);
1.47 + INSERT INTO t1 VALUES ('hello');
1.48 + INSERT INTO t1 VALUES ('out there');
1.49 +} -sqlbody {
1.50 + SELECT * FROM t1
1.51 + WHERE x BETWEEN 'a' AND 'z'
1.52 + AND x BETWEEN 'c' AND 'w'
1.53 + AND x BETWEEN 'e' AND 'u'
1.54 + AND x BETWEEN 'g' AND 'r'
1.55 + AND x BETWEEN 'i' AND 'q'
1.56 + AND x BETWEEN 'i' AND 'm'
1.57 +}
1.58 +
1.59 +proc utf16 {utf8} {
1.60 + set utf16 [encoding convertto unicode $utf8]
1.61 + append utf16 "\x00\x00"
1.62 + return $utf16
1.63 +}
1.64 +
1.65 +do_malloc_test mallocG-4 -tclbody {
1.66 + set rc [sqlite3_complete16 [utf16 "SELECT * FROM t1;"]]
1.67 + if {$rc==1} {set rc 0} {error "out of memory"}
1.68 + set rc
1.69 +}
1.70 +
1.71 +finish_test