3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for the SQLite sessions module
12 # Specifically, for the sqlite3session_memory_used() API.
15 if {![info exists testdir]} {
16 set testdir [file join [file dirname [info script]] .. .. test]
18 source [file join [file dirname [info script]] session_common.tcl]
19 source $testdir/tester.tcl
20 ifcapable !session {finish_test; return}
22 set testprefix sessionmem
25 CREATE TABLE t1(i INTEGER PRIMARY KEY, x, y);
26 CREATE TABLE t2(i INTEGER, x, y, PRIMARY KEY(x, y));
30 sqlite3session S db main
34 foreach {tn sql eRes} {
35 1 { INSERT INTO t1 VALUES(1, 2, 3) } 1
36 2 { UPDATE t1 SET x=5 } 0
37 3 { UPDATE t1 SET i=5 } 1
38 4 { DELETE FROM t1 } 0
39 5 { INSERT INTO t1 VALUES(1, 2, 3) } 0
40 6 { INSERT INTO t1 VALUES(5, 2, 3) } 0
41 7 { INSERT INTO t2 VALUES('a', 'b', 'c') } 1
42 8 { INSERT INTO t2 VALUES('d', 'e', 'f') } 1
43 9 { UPDATE t2 SET i='e' } 0
45 set mem1 [S memory_used]
46 do_test 1.2.$tn.(mu=$mem1) {
48 set mem2 [S memory_used]