2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A# 2002 December 03
2N/A#
2N/A# The author disclaims copyright to this source code. In place of
2N/A# a legal notice, here is a blessing:
2N/A#
2N/A# May you do good and not evil.
2N/A# May you find forgiveness for yourself and forgive others.
2N/A# May you share freely, never taking more than you give.
2N/A#
2N/A#***********************************************************************
2N/A# This file implements regression tests for SQLite library. The
2N/A# focus of this script is btree database backend
2N/A#
2N/A# This file focuses on testing the sqliteBtreeNext() and
2N/A# sqliteBtreePrevious() procedures and making sure they are able
2N/A# to step through an entire table from either direction.
2N/A#
2N/A# $Id: btree4.test,v 1.1 2002/12/04 13:40:27 drh Exp $
2N/A
2N/A
2N/Aset testdir [file dirname $argv0]
2N/Asource $testdir/tester.tcl
2N/A
2N/Aif {[info commands btree_open]!=""} {
2N/A
2N/A# Open a test database.
2N/A#
2N/Afile delete -force test1.bt
2N/Afile delete -force test1.bt-journal
2N/Aset b1 [btree_open test1.bt]
2N/Abtree_begin_transaction $::b1
2N/A
2N/Aset data {abcdefghijklmnopqrstuvwxyz0123456789}
2N/Aappend data $data
2N/Aappend data $data
2N/Aappend data $data
2N/Aappend data $data
2N/A
2N/Aforeach N {10 100 1000} {
2N/A btree_clear_table $::b1 2
2N/A set ::c1 [btree_cursor $::b1 2 1]
2N/A do_test btree4-$N.1 {
2N/A for {set i 1} {$i<=$N} {incr i} {
2N/A btree_insert $::c1 [format k-%05d $i] $::data-$i
2N/A }
2N/A btree_first $::c1
2N/A btree_key $::c1
2N/A } {k-00001}
2N/A do_test btree4-$N.2 {
2N/A btree_data $::c1
2N/A } $::data-1
2N/A for {set i 2} {$i<=$N} {incr i} {
2N/A do_test btree-$N.3.$i.1 {
2N/A btree_next $::c1
2N/A } 0
2N/A do_test btree-$N.3.$i.2 {
2N/A btree_key $::c1
2N/A } [format k-%05d $i]
2N/A do_test btree-$N.3.$i.3 {
2N/A btree_data $::c1
2N/A } $::data-$i
2N/A }
2N/A do_test btree4-$N.4 {
2N/A btree_next $::c1
2N/A } 1
2N/A do_test btree4-$N.5 {
2N/A btree_last $::c1
2N/A } 0
2N/A do_test btree4-$N.6 {
2N/A btree_key $::c1
2N/A } [format k-%05d $N]
2N/A do_test btree4-$N.7 {
2N/A btree_data $::c1
2N/A } $::data-$N
2N/A for {set i [expr {$N-1}]} {$i>=1} {incr i -1} {
2N/A do_test btree4-$N.8.$i.1 {
2N/A btree_prev $::c1
2N/A } 0
2N/A do_test btree4-$N.8.$i.2 {
2N/A btree_key $::c1
2N/A } [format k-%05d $i]
2N/A do_test btree4-$N.8.$i.3 {
2N/A btree_data $::c1
2N/A } $::data-$i
2N/A }
2N/A do_test btree4-$N.9 {
2N/A btree_prev $::c1
2N/A } 1
2N/A btree_close_cursor $::c1
2N/A}
2N/A
2N/Abtree_rollback $::b1
2N/Abtree_pager_ref_dump $::b1
2N/Abtree_close $::b1
2N/A
2N/A} ;# end if( not mem: and has pager_open command );
2N/A
2N/Afinish_test