1# 2# 2002 December 03 3# 4# The author disclaims copyright to this source code. In place of 5# a legal notice, here is a blessing: 6# 7# May you do good and not evil. 8# May you find forgiveness for yourself and forgive others. 9# May you share freely, never taking more than you give. 10# 11#*********************************************************************** 12# This file implements regression tests for SQLite library. The 13# focus of this script is btree database backend 14# 15# This file focuses on testing the sqliteBtreeNext() and 16# sqliteBtreePrevious() procedures and making sure they are able 17# to step through an entire table from either direction. 18# 19# $Id: btree4.test,v 1.1 2002/12/04 13:40:27 drh Exp $ 20 21 22set testdir [file dirname $argv0] 23source $testdir/tester.tcl 24 25if {[info commands btree_open]!=""} { 26 27# Open a test database. 28# 29file delete -force test1.bt 30file delete -force test1.bt-journal 31set b1 [btree_open test1.bt] 32btree_begin_transaction $::b1 33 34set data {abcdefghijklmnopqrstuvwxyz0123456789} 35append data $data 36append data $data 37append data $data 38append data $data 39 40foreach N {10 100 1000} { 41 btree_clear_table $::b1 2 42 set ::c1 [btree_cursor $::b1 2 1] 43 do_test btree4-$N.1 { 44 for {set i 1} {$i<=$N} {incr i} { 45 btree_insert $::c1 [format k-%05d $i] $::data-$i 46 } 47 btree_first $::c1 48 btree_key $::c1 49 } {k-00001} 50 do_test btree4-$N.2 { 51 btree_data $::c1 52 } $::data-1 53 for {set i 2} {$i<=$N} {incr i} { 54 do_test btree-$N.3.$i.1 { 55 btree_next $::c1 56 } 0 57 do_test btree-$N.3.$i.2 { 58 btree_key $::c1 59 } [format k-%05d $i] 60 do_test btree-$N.3.$i.3 { 61 btree_data $::c1 62 } $::data-$i 63 } 64 do_test btree4-$N.4 { 65 btree_next $::c1 66 } 1 67 do_test btree4-$N.5 { 68 btree_last $::c1 69 } 0 70 do_test btree4-$N.6 { 71 btree_key $::c1 72 } [format k-%05d $N] 73 do_test btree4-$N.7 { 74 btree_data $::c1 75 } $::data-$N 76 for {set i [expr {$N-1}]} {$i>=1} {incr i -1} { 77 do_test btree4-$N.8.$i.1 { 78 btree_prev $::c1 79 } 0 80 do_test btree4-$N.8.$i.2 { 81 btree_key $::c1 82 } [format k-%05d $i] 83 do_test btree4-$N.8.$i.3 { 84 btree_data $::c1 85 } $::data-$i 86 } 87 do_test btree4-$N.9 { 88 btree_prev $::c1 89 } 1 90 btree_close_cursor $::c1 91} 92 93btree_rollback $::b1 94btree_pager_ref_dump $::b1 95btree_close $::b1 96 97} ;# end if( not mem: and has pager_open command ); 98 99finish_test 100