]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add more tests for the in-memory database. (CVS 925)
authordrh <drh@noemail.net>
Sun, 20 Apr 2003 23:45:23 +0000 (23:45 +0000)
committerdrh <drh@noemail.net>
Sun, 20 Apr 2003 23:45:23 +0000 (23:45 +0000)
FossilOrigin-Name: 11cab41c4f02cdddc4fd3f57555573ac2814a81b

manifest
manifest.uuid
test/btree3rb.test [new file with mode: 0644]
test/btree4rb.test [new file with mode: 0644]
test/memdb.test

index 5e04a0ed37c237b4a80cbb1b41e5d6f15ae455ae..bfc750b13ca9567b7e5c18bf91d60a4e6c855805 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Added\stests\sfor\sthe\sin-memory\sdatabase\sbackend.\s\sAlso\supdated\ssome\scomments\nin\sother\smodules.\s(CVS\s924)
-D 2003-04-20T17:29:24
+C Add\smore\stests\sfor\sthe\sin-memory\sdatabase.\s(CVS\s925)
+D 2003-04-20T23:45:23
 F Makefile.in 004acec253ecdde985c8ecd5b7c9accdb210378f
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -70,7 +70,9 @@ F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
 F test/btree.test 1e3463c7838e7e71bbf37c9c6e45beee9c8975ba
 F test/btree2.test e3b81ec33dc2f89b3e6087436dfe605b870c9080
 F test/btree3.test e597fb59be2ac0ea69c62aaa2064e998e528b665
+F test/btree3rb.test 127efcf5cdfcc352054e7db12622b01cdd8b36ac
 F test/btree4.test fa955a3d7a8bc91d6084b7f494f9e5d1bdfb15b6
+F test/btree4rb.test ae6f0438512edcb45cf483471cd6070a765963a9
 F test/capi2.test fb94bed9e236074c5e255cfd25e3e32344e24855
 F test/conflict.test 80cf3780c8686b92db4ce0f60bca46a000537327
 F test/copy.test 73df5ed3112e858e006a8b7ddb4c9bab6a25d0fb
@@ -91,7 +93,7 @@ F test/limit.test 9ffb965a0f5bf7152187ef3d8d1249b96e5620bf
 F test/lock.test 388a3a10962d2d571c0c1821cc35bf069ee73473
 F test/main.test 8108ac48302027bbe4296c30b913adbe6d5d984b
 F test/malloc.test 7ba32a9ebd3aeed52ae4aaa6d42ca37e444536fd
-F test/memdb.test 2ad45c3c3215822c588c0c823137821abd96bded
+F test/memdb.test 4494051bcf72df58d9c631a5bc1260cba2b021cc
 F test/memleak.test a18e6810cae96d2f6f5136920267adbefc8e1e90
 F test/minmax.test b54ac3bc45460a4976b08ef363e05c032418726e
 F test/misc1.test 865c907df58195364eaf2e69426e9674bc8d1a8c
@@ -163,7 +165,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 921656db9e3df865aea6b1abe1bc40b1acbeeb47
-R 33f3fc945956a6408c6cd1e1bd368307
+P fb89adf4d1325c5ea471759ebfd8df7faa4f9a80
+R 5155025990322dc1039d8bac43cc6a4c
 U drh
-Z 30e6aaf687d966a7606c8c8a04b291ba
+Z 91bd6b460f5c66d00bbb9e74c7457add
index df54ff70e3904d8e9956315cce3109b0b37bc721..375ad1964e7135d7a62bd02414c36f8761a31d05 100644 (file)
@@ -1 +1 @@
-fb89adf4d1325c5ea471759ebfd8df7faa4f9a80
\ No newline at end of file
+11cab41c4f02cdddc4fd3f57555573ac2814a81b
\ No newline at end of file
diff --git a/test/btree3rb.test b/test/btree3rb.test
new file mode 100644 (file)
index 0000000..c1c02a8
--- /dev/null
@@ -0,0 +1,84 @@
+# 2001 November 22
+#
+# 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
+#
+# In particular, this file tests a small part of the Delete logic
+# for the BTree backend.  When a row is deleted from a table, the
+# cursor is suppose to be left pointing at either the previous or
+# next entry in that table.  If the cursor is left pointing at the
+# next entry, then the next Next operation is ignored.  So the 
+# sequence of operations (Delete, Next) should always leave the
+# cursor pointing at the first entry past the one that was deleted.
+# This test is designed to verify that behavior.
+#
+# $Id: btree3rb.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
+
+# Insert a few one records
+#
+set data {abcdefghijklmnopqrstuvwxyz0123456789}
+append data $data
+append data $data
+append data $data
+append data $data
+for {set k 2} {$k<=20} {incr k} {
+  for {set j 1} {$j<=$k} {incr j} {
+    set jkey [format %02d $j]
+    btree_clear_table $::b1 2
+    set ::c1 [btree_cursor $::b1 2 1]
+    for {set i 1} {$i<=$k} {incr i} {
+      set key [format %02d $i]
+      do_test btree3rb-$k.$j.1.$i {
+        btree_insert $::c1 $::key $::data
+      } {}
+      # btree_tree_dump $::b1 2
+    }
+    do_test btree3rb-$k.$j.2 {
+      btree_move_to $::c1 $::jkey
+      btree_key $::c1
+    } $::jkey
+    do_test btree3rb-$k.$j.3 {
+      btree_delete $::c1
+    } {}
+    if {$j<$k} {
+      do_test btree3rb-$k.$j.4 {
+        btree_next $::c1
+        btree_key $::c1
+      } [format %02d [expr $j+1]]
+    }
+    if {$j>1} {
+      do_test btree3rb-$k.$j.5 {
+        btree_prev $::c1
+        btree_key $::c1
+      } [format %02d [expr $j-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
diff --git a/test/btree4rb.test b/test/btree4rb.test
new file mode 100644 (file)
index 0000000..c38e946
--- /dev/null
@@ -0,0 +1,95 @@
+# 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
index cf1058a84b3cc17dfd6486e1690f8f2333da5944..01e356d0ae39f6b5d3fc28fdfb358681edd5ac3f 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is in-memory database backend.
 #
-# $Id: memdb.test,v 1.1 2003/04/20 17:29:25 drh Exp $
+# $Id: memdb.test,v 1.2 2003/04/20 23:45:23 drh Exp $
 
 
 set testdir [file dirname $argv0]
@@ -355,9 +355,27 @@ do_test memdb-6.15 {
   }
 } {}
 
-
-
-
-
+do_test memdb-7.1 {
+  execsql {
+    CREATE TABLE t6(x);
+    INSERT INTO t6 VALUES(1);
+    INSERT INTO t6 SELECT x+1 FROM t6;
+    INSERT INTO t6 SELECT x+2 FROM t6;
+    INSERT INTO t6 SELECT x+4 FROM t6;
+    INSERT INTO t6 SELECT x+8 FROM t6;
+    INSERT INTO t6 SELECT x+16 FROM t6;
+    INSERT INTO t6 SELECT x+32 FROM t6;
+    INSERT INTO t6 SELECT x+64 FROM t6;
+    INSERT INTO t6 SELECT x+128 FROM t6;
+    SELECT count(*) FROM (SELECT DISTINCT x FROM t6);
+  }
+} {256}
+for {set i 1} {$i<=256} {incr i} {
+  do_test memdb-7.2.$i {
+     execsql "DELETE FROM t6 WHERE x=\
+              (SELECT x FROM t6 ORDER BY random() LIMIT 1)"
+     execsql {SELECT count(*) FROM t6}
+  } [expr {256-$i}]
+}
 
 finish_test