0
0
mirror of https://github.com/sqlite/sqlite.git synced 2024-11-28 07:51:10 +01:00
sqlite/ext/session/sessionmem.test
dan a2560ce934 Add tests for sqlite3session_memory_used() interface.
FossilOrigin-Name: 5596611f96f3401262b9dadc591bf7e3411d2c4a6f5be5cfe524e203d9820fd1
2021-01-20 10:59:47 +00:00

58 lines
1.5 KiB
Plaintext

# 2020 December 23
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for the SQLite sessions module
# Specifically, for the sqlite3session_memory_used() API.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join [file dirname [info script]] session_common.tcl]
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix sessionmem
do_execsql_test 1.0 {
CREATE TABLE t1(i INTEGER PRIMARY KEY, x, y);
CREATE TABLE t2(i INTEGER, x, y, PRIMARY KEY(x, y));
}
do_test 1.1 {
sqlite3session S db main
S attach *
} {}
foreach {tn sql eRes} {
1 { INSERT INTO t1 VALUES(1, 2, 3) } 1
2 { UPDATE t1 SET x=5 } 0
3 { UPDATE t1 SET i=5 } 1
4 { DELETE FROM t1 } 0
5 { INSERT INTO t1 VALUES(1, 2, 3) } 0
6 { INSERT INTO t1 VALUES(5, 2, 3) } 0
7 { INSERT INTO t2 VALUES('a', 'b', 'c') } 1
8 { INSERT INTO t2 VALUES('d', 'e', 'f') } 1
9 { UPDATE t2 SET i='e' } 0
} {
set mem1 [S memory_used]
do_test 1.2.$tn.(mu=$mem1) {
execsql $sql
set mem2 [S memory_used]
expr {$mem2 > $mem1}
} $eRes
}
do_test 1.3 {
S delete
} {}
finish_test