xref: /sqlite-3.40.0/test/mallocH.test (revision 4cfb22f7)
1# 2008 August 01
2#
3# The author disclaims copyright to this source code.  In place of
4# a legal notice, here is a blessing:
5#
6#    May you do good and not evil.
7#    May you find forgiveness for yourself and forgive others.
8#    May you share freely, never taking more than you give.
9#
10#***********************************************************************
11#
12# This test script checks malloc failures in various obscure operations.
13#
14# $Id: mallocH.test,v 1.1 2008/08/01 18:47:02 drh Exp $
15
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
18source $testdir/malloc_common.tcl
19
20# Malloc failures in journaling of in-memory databases.
21#
22do_malloc_test mallocH-1 -tclprep {
23  db close
24  sqlite3 db :memory:
25  db eval {
26    CREATE TABLE t1(x UNIQUE, y);
27    INSERT INTO t1 VALUES(1,2);
28  }
29} -sqlbody {
30  INSERT INTO t1 SELECT x+1, y+100 FROM t1;
31}
32
33# Malloc failures while parsing a CASE expression.
34#
35do_malloc_test mallocH-2 -sqlbody {
36   SELECT CASE WHEN 1 THEN 1 END;
37}
38
39# Malloc failures while parsing a EXISTS(SELECT ...)
40#
41do_malloc_test mallocH-3 -sqlbody {
42   SELECT 3+EXISTS(SELECT * FROM sqlite_master);
43}
44
45# Malloc failures within the replace() function.
46#
47do_malloc_test mallocH-3 -sqlbody {
48   SELECT replace('ababa','a','xyzzy');
49}
50
51finish_test
52