Fixes default log output to console for macOS
[sqlcipher.git] / ext / session / sessionmem.test
blob75b48623d0fdb8a0ae37007a0767ac15f49e8c22
1 # 2020 December 23
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]
17
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
24 do_execsql_test 1.0 {
25   CREATE TABLE t1(i INTEGER PRIMARY KEY, x, y);
26   CREATE TABLE t2(i INTEGER, x, y, PRIMARY KEY(x, y));
29 do_test 1.1 {
30   sqlite3session S db main
31   S attach *
32 } {}
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
44 } {
45   set mem1 [S memory_used]
46   do_test 1.2.$tn.(mu=$mem1) {
47     execsql $sql
48     set mem2 [S memory_used]
49     expr {$mem2 > $mem1}
50   } $eRes
53 do_test 1.3 {
54   S delete
55 } {}
57 finish_test