Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/session/sessionchange.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / session / sessionchange.test` 117 lines ยท 2769 bytes Raw Blame History 1 # 2011 March 07 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 SQLite library. 12 # 13 14 if {![info exists testdir]} { 15 set testdir [file join [file dirname [info script]] .. .. test] 16 } 17 source [file join [file dirname [info script]] session_common.tcl] 18 source $testdir/tester.tcl 19 ifcapable !session {finish_test; return} 20 21 set testprefix sessionchange 22 23 do_execsql_test 1.0 { 24 CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); 25 } 26 27 do_test 1.1 { 28 set C [changeset_from_sql { 29 INSERT INTO t1 VALUES(1, 2, 3); 30 INSERT INTO t1 VALUES(10, 20, 30); 31 }] 32 33 set res [list] 34 set iter [sqlite3changeset_start $C] 35 while {[$iter next]=="SQLITE_ROW"} { 36 lappend res [$iter data] 37 } 38 $iter finalize 39 40 set res 41 } [list \ 42 {INSERT t1 0 X.. {} {i 10 i 20 i 30}} \ 43 {INSERT t1 0 X.. {} {i 1 i 2 i 3}} \ 44 ] 45 46 47 do_test 1.2 { 48 sqlite3changegroup grp 49 set iter [sqlite3changeset_start $C] 50 while {[$iter next]=="SQLITE_ROW"} { 51 grp add_change $iter 52 } 53 $iter finalize 54 55 set res [list] 56 grp output 57 sqlite3session_foreach c [grp output] { lappend res $c } 58 grp delete 59 set res 60 } [list \ 61 {INSERT t1 0 X.. {} {i 10 i 20 i 30}} \ 62 {INSERT t1 0 X.. {} {i 1 i 2 i 3}} \ 63 ] 64 65 do_test 1.3.1 { 66 set iter [sqlite3changeset_start $C] 67 sqlite3changegroup grp 68 list [catch { grp add_change $iter } msg] $msg 69 } {1 SQLITE_ERROR} 70 do_test 1.3.2 { 71 while {[$iter next]=="SQLITE_ROW"} { } 72 list [catch { grp add_change $iter } msg] $msg 73 } {1 SQLITE_ERROR} 74 grp delete 75 $iter finalize 76 77 do_test 1.4 { 78 set res [list] 79 set iter [sqlite3changeset_start -invert $C] 80 while {[$iter next]=="SQLITE_ROW"} { 81 lappend res [$iter data] 82 } 83 $iter finalize 84 set res 85 } [list \ 86 {DELETE t1 0 X.. {i 10 i 20 i 30} {}} \ 87 {DELETE t1 0 X.. {i 1 i 2 i 3} {}} \ 88 ] 89 90 do_test 1.5 { 91 sqlite3changegroup grp 92 set iter [sqlite3changeset_start -invert $C] 93 $iter next 94 list [catch { grp add_change $iter } msg] $msg 95 } {1 SQLITE_ERROR} 96 $iter finalize 97 grp delete 98 99 do_test 1.6 { 100 set C [changeset_from_sql { 101 INSERT INTO t1 VALUES(1001, hex(randomblob(10000)), hex(randomblob(10000))); 102 INSERT INTO t1 VALUES(2001, hex(randomblob(10000)), hex(randomblob(10000))); 103 INSERT INTO t1 VALUES(3001, hex(randomblob(10000)), hex(randomblob(10000))); 104 }] 105 106 sqlite3changegroup grp 107 set iter [sqlite3changeset_start $C] 108 while {[$iter next]=="SQLITE_ROW"} { 109 grp add_change $iter 110 } 111 $iter finalize 112 } SQLITE_OK 113 114 grp delete 115 116 117 finish_test