1# 2011 March 25 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# This file implements regression tests for the session module. 12# 13 14if {![info exists testdir]} { 15 set testdir [file join [file dirname [info script]] .. .. test] 16} 17source [file join [file dirname [info script]] session_common.tcl] 18source $testdir/tester.tcl 19ifcapable !session {finish_test; return} 20 21set testprefix session4 22 23do_test 1.0 { 24 execsql { 25 CREATE TABLE x(a, b, c, d, e, PRIMARY KEY(c, e)); 26 INSERT INTO x VALUES(65.21, X'28B0', 16.35, NULL, 'doers'); 27 INSERT INTO x VALUES(NULL, 78.49, 2, X'60', -66); 28 INSERT INTO x VALUES('cathedral', NULL, 35, NULL, X'B220937E80A2D8'); 29 INSERT INTO x VALUES(NULL, 'masking', -91.37, NULL, X'596D'); 30 INSERT INTO x VALUES(19, 'domains', 'espouse', -94, 'throw'); 31 } 32 33 sqlite3session S db main 34 set changeset [changeset_from_sql { 35 DELETE FROM x WHERE e = -66; 36 UPDATE x SET a = 'parameterizable', b = 31.8 WHERE c = 35; 37 INSERT INTO x VALUES(-75.61, -17, 16.85, NULL, X'D73DB02678'); 38 }] 39 set {} {} 40} {} 41 42 43# This currently causes crashes. sqlite3changeset_invert() does not handle 44# corrupt changesets well. 45if 0 { 46 do_test 1.1 { 47 for {set i 0} {$i < [string length $changeset]} {incr i} { 48 set before [string range $changeset 0 [expr $i-1]] 49 set after [string range $changeset [expr $i+1] end] 50 for {set j 10} {$j < 260} {incr j} { 51 set x [binary format "a*ca*" $before $j $after] 52 catch { sqlite3changeset_invert $x } 53 } 54 } 55 } {} 56} 57 58do_test 1.2 { 59 set x [binary format "ca*" 0 [string range $changeset 1 end]] 60 list [catch { sqlite3changeset_invert $x } msg] $msg 61} {1 SQLITE_CORRUPT} 62 63do_test 1.3 { 64 set x [binary format "ca*" 0 [string range $changeset 1 end]] 65 list [catch { sqlite3changeset_apply db $x xConflict } msg] $msg 66} {1 SQLITE_CORRUPT} 67 68finish_test 69