2dcc9aa2a8
in anticipation of implementing reverse order searching of a table. (CVS 794) FossilOrigin-Name: 0ad1d93879bee0d34b122591c025192a51b8490f
99 lines
2.3 KiB
Plaintext
99 lines
2.3 KiB
Plaintext
# 2002 December 03
|
|
#
|
|
# 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 SQLite library. The
|
|
# focus of this script is btree database backend
|
|
#
|
|
# This file focuses on testing the sqliteBtreeNext() and
|
|
# sqliteBtreePrevious() procedures and making sure they are able
|
|
# to step through an entire table from either direction.
|
|
#
|
|
# $Id: btree4.test,v 1.1 2002/12/04 13:40:27 drh Exp $
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
|
|
if {[info commands btree_open]!=""} {
|
|
|
|
# Open a test database.
|
|
#
|
|
file delete -force test1.bt
|
|
file delete -force test1.bt-journal
|
|
set b1 [btree_open test1.bt]
|
|
btree_begin_transaction $::b1
|
|
|
|
set data {abcdefghijklmnopqrstuvwxyz0123456789}
|
|
append data $data
|
|
append data $data
|
|
append data $data
|
|
append data $data
|
|
|
|
foreach N {10 100 1000} {
|
|
btree_clear_table $::b1 2
|
|
set ::c1 [btree_cursor $::b1 2 1]
|
|
do_test btree4-$N.1 {
|
|
for {set i 1} {$i<=$N} {incr i} {
|
|
btree_insert $::c1 [format k-%05d $i] $::data-$i
|
|
}
|
|
btree_first $::c1
|
|
btree_key $::c1
|
|
} {k-00001}
|
|
do_test btree4-$N.2 {
|
|
btree_data $::c1
|
|
} $::data-1
|
|
for {set i 2} {$i<=$N} {incr i} {
|
|
do_test btree-$N.3.$i.1 {
|
|
btree_next $::c1
|
|
} 0
|
|
do_test btree-$N.3.$i.2 {
|
|
btree_key $::c1
|
|
} [format k-%05d $i]
|
|
do_test btree-$N.3.$i.3 {
|
|
btree_data $::c1
|
|
} $::data-$i
|
|
}
|
|
do_test btree4-$N.4 {
|
|
btree_next $::c1
|
|
} 1
|
|
do_test btree4-$N.5 {
|
|
btree_last $::c1
|
|
} 0
|
|
do_test btree4-$N.6 {
|
|
btree_key $::c1
|
|
} [format k-%05d $N]
|
|
do_test btree4-$N.7 {
|
|
btree_data $::c1
|
|
} $::data-$N
|
|
for {set i [expr {$N-1}]} {$i>=1} {incr i -1} {
|
|
do_test btree4-$N.8.$i.1 {
|
|
btree_prev $::c1
|
|
} 0
|
|
do_test btree4-$N.8.$i.2 {
|
|
btree_key $::c1
|
|
} [format k-%05d $i]
|
|
do_test btree4-$N.8.$i.3 {
|
|
btree_data $::c1
|
|
} $::data-$i
|
|
}
|
|
do_test btree4-$N.9 {
|
|
btree_prev $::c1
|
|
} 1
|
|
btree_close_cursor $::c1
|
|
}
|
|
|
|
btree_rollback $::b1
|
|
btree_pager_ref_dump $::b1
|
|
btree_close $::b1
|
|
|
|
} ;# end if( not mem: and has pager_open command );
|
|
|
|
finish_test
|