881b890af4
FossilOrigin-Name: 11cab41c4f02cdddc4fd3f57555573ac2814a81b
96 lines
2.3 KiB
Plaintext
96 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: btree4rb.test,v 1.1 2003/04/20 23:45:23 drh Exp $
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
|
|
if {[info commands btree_open]!=""} {
|
|
|
|
# Open a test database.
|
|
#
|
|
set b1 [btree_open :memory:]
|
|
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 btree4rb-$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 btree4rb-$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 btree4rb-$N.4 {
|
|
btree_next $::c1
|
|
} 1
|
|
do_test btree4rb-$N.5 {
|
|
btree_last $::c1
|
|
} 0
|
|
do_test btree4rb-$N.6 {
|
|
btree_key $::c1
|
|
} [format k-%05d $N]
|
|
do_test btree4rb-$N.7 {
|
|
btree_data $::c1
|
|
} $::data-$N
|
|
for {set i [expr {$N-1}]} {$i>=1} {incr i -1} {
|
|
do_test btree4rb-$N.8.$i.1 {
|
|
btree_prev $::c1
|
|
} 0
|
|
do_test btree4rb-$N.8.$i.2 {
|
|
btree_key $::c1
|
|
} [format k-%05d $i]
|
|
do_test btree4rb-$N.8.$i.3 {
|
|
btree_data $::c1
|
|
} $::data-$i
|
|
}
|
|
do_test btree4rb-$N.9 {
|
|
btree_prev $::c1
|
|
} 1
|
|
btree_close_cursor $::c1
|
|
}
|
|
|
|
btree_rollback $::b1
|
|
btree_close $::b1
|
|
|
|
} ;# end if( not mem: and has pager_open command );
|
|
|
|
finish_test
|