CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
incrblobfault.test75 linesDownload Raw Back to test
1# 2010 October 262#3# The author disclaims copyright to this source code.  In place of4# a legal notice, here is a blessing:5#6#    May you do good and not evil.7#    May you find forgiveness for yourself and forgive others.8#    May you share freely, never taking more than you give.9#10#***********************************************************************11#12#13 14set testdir [file dirname $argv0]15source $testdir/tester.tcl16 17ifcapable !incrblob {18  finish_test19  return20}21 22set testprefix incrblobfault23 24do_execsql_test 1.0 {25  CREATE TABLE blob(x INTEGER PRIMARY KEY, v BLOB);26  INSERT INTO blob VALUES(1, 'hello world');27  INSERT INTO blob VALUES(2, 'world hello');28  INSERT INTO blob SELECT NULL, v FROM blob;29  INSERT INTO blob SELECT NULL, v FROM blob;30  INSERT INTO blob SELECT NULL, v FROM blob;31  INSERT INTO blob SELECT NULL, v FROM blob;32  INSERT INTO blob SELECT NULL, v FROM blob;33  INSERT INTO blob SELECT NULL, v FROM blob;34  INSERT INTO blob SELECT NULL, v FROM blob;35  INSERT INTO blob SELECT NULL, v FROM blob;36  INSERT INTO blob SELECT NULL, v FROM blob;37  INSERT INTO blob SELECT NULL, v FROM blob;38}39 40do_faultsim_test 1 -prep {41  sqlite3 db test.db42  set ::blob [db incrblob blob v 1]43} -body {44  if {[catch {sqlite3_blob_reopen $::blob 1000}]} {45    error [sqlite3_errmsg db]46  }47} -test {48  faultsim_test_result {0 {}}49  close $::blob50}51 52do_faultsim_test 2 -prep {53  sqlite3 db test.db54  set ::blob [db incrblob blob v 1]55} -body {56  if {[catch {sqlite3_blob_reopen $::blob -1}]} {57    error [sqlite3_errmsg db]58  }59} -test {60  faultsim_test_result {1 {no such rowid: -1}} {1 {disk I/O error}}61  close $::blob62}63 64do_faultsim_test 3 -prep {65  sqlite3 db test.db66} -body {67  set ::blob [db incrblob blob v 1]68  gets $::blob69} -test {70  faultsim_test_result {0 {hello world}}71  catch { close $::blob }72}73 74finish_test75