btree3.test revision 2
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A# 2001 November 22
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# In particular, this file tests a small part of the Delete logic
2N/A# for the BTree backend. When a row is deleted from a table, the
2N/A# cursor is suppose to be left pointing at either the previous or
2N/A# next entry in that table. If the cursor is left pointing at the
2N/A# next entry, then the next Next operation is ignored. So the
2N/A# sequence of operations (Delete, Next) should always leave the
2N/A# cursor pointing at the first entry past the one that was deleted.
2N/A# This test is designed to verify that behavior.
2N/A#
2N/A# $Id: btree3.test,v 1.2 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/A# Insert a few one records
2N/A#
2N/Aset data {abcdefghijklmnopqrstuvwxyz0123456789}
2N/Aappend data $data
2N/Aappend data $data
2N/Aappend data $data
2N/Aappend data $data
2N/Afor {set k 2} {$k<=10} {incr k} {
2N/A for {set j 1} {$j<=$k} {incr j} {
2N/A set jkey [format %02d $j]
2N/A btree_clear_table $::b1 2
2N/A set ::c1 [btree_cursor $::b1 2 1]
2N/A for {set i 1} {$i<=$k} {incr i} {
2N/A set key [format %02d $i]
2N/A do_test btree3-$k.$j.1.$i {
2N/A btree_insert $::c1 $::key $::data
2N/A } {}
2N/A # btree_tree_dump $::b1 2
2N/A }
2N/A do_test btree3-$k.$j.2 {
2N/A btree_move_to $::c1 $::jkey
2N/A btree_key $::c1
2N/A } $::jkey
2N/A do_test btree3-$k.$j.3 {
2N/A btree_delete $::c1
2N/A } {}
2N/A if {$j<$k} {
2N/A do_test btree3-$k.$j.4 {
2N/A btree_next $::c1
2N/A btree_key $::c1
2N/A } [format %02d [expr $j+1]]
2N/A }
2N/A if {$j>1} {
2N/A do_test btree3-$k.$j.5 {
2N/A btree_prev $::c1
2N/A btree_key $::c1
2N/A } [format %02d [expr $j-1]]
2N/A }
2N/A btree_close_cursor $::c1
2N/A }
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