SQLite4
Artifact Content
Not logged in

Artifact 5d0d9a899b9b7749431bbc5e688530542de76a15:


# 2012 January 21
#
# 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 file is testing the internal storage.h interface.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_test storage1-1.1 {
  set x [storage_open :memory:]
  storage_close $x
} {}
do_test storage1-1.2 {
  set x [storage_open :memory:]
  set c1 [storage_open_cursor $x]
  set c2 [storage_open_cursor $x]
  set c3 [storage_open_cursor $x]
  storage_close_cursor $c2
  storage_close_cursor $c3
  storage_close_cursor $c1
  storage_close $x
} {}
do_test storage1-1.3 {
  set x [storage_open :memory:]
  storage_begin $x 2
  storage_replace $x 0123456789abcdef fedcba9876543210
  storage_rollback $x 1
  storage_begin $x 2
  storage_replace $x 0123456789abcd fedcba9876543210
  storage_commit $x 0
  storage_close $x
} {}
do_test storage1-1.4 {
  set x [storage_open :memory:]
  storage_begin $x 2
  storage_replace $x 0123456789abcdef fedcba9876543210
  set c1 [storage_open_cursor $x]
  set res {}
  lappend res [storage_seek $c1 00 1]
  lappend res [storage_key $c1]
  lappend res [storage_data $c1]
  storage_close_cursor $c1
  storage_close $x
  set res
} {SQLITE4_INEXACT 0123456789ABCDEF FEDCBA9876543210}
do_test storage1-1.5 {
  set x [storage_open :memory:]
  storage_begin $x 2
  storage_replace $x 012345 abcd
  storage_replace $x 014557 ef01
  set c1 [storage_open_cursor $x]
  set res {}
  lappend res [storage_seek $c1 02 -1]
  lappend res [storage_key $c1]
  lappend res [storage_data $c1]
  lappend res [storage_prev $c1]
  lappend res [storage_key $c1]
  lappend res [storage_data $c1]
  lappend res [storage_prev $c1]
  storage_close_cursor $c1
  storage_close $x
  set res
} {SQLITE4_INEXACT 014557 EF01 SQLITE4_OK 012345 ABCD SQLITE4_NOTFOUND}
do_test storage1-1.6 {
  set x [storage_open :memory:]
  storage_begin $x 2
  storage_replace $x 012345 abcd
  storage_replace $x 014567 ef01
  storage_replace $x 013456 deaf
  storage_replace $x 012345 eeaa
  set c1 [storage_open_cursor $x]
  set c2 [storage_open_cursor $x]
  set res {}
  lappend res [storage_seek $c1 00 +1]
  lappend res [storage_key $c1]
  lappend res [storage_data $c1]
  lappend res [storage_next $c1]
  lappend res [storage_key $c1]
  lappend res [storage_data $c1]
  storage_delete $c1
  lappend res [storage_next $c1]
  lappend res [storage_key $c1]
  lappend res [storage_data $c1]
  lappend res [storage_prev $c1]
  lappend res [storage_key $c1]
  lappend res [storage_data $c1]
  storage_close_cursor $c1
  storage_close_cursor $c2
  storage_close $x
  set res
} {SQLITE4_INEXACT 012345 EEAA SQLITE4_OK 013456 DEAF SQLITE4_OK 014567 EF01 SQLITE4_OK 012345 EEAA}

finish_test