summaryrefslogtreecommitdiff
path: root/test/incrblobfault.test
blob: 0c1d93d4603e1c4ea6fad8794ba4e40e3a4ef552 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# 2010 October 26
#
# 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.
#
#***********************************************************************
#
#

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

set testprefix incrblobfault

do_execsql_test 1.0 {
  CREATE TABLE blob(x INTEGER PRIMARY KEY, v BLOB);
  INSERT INTO blob VALUES(1, 'hello world');
  INSERT INTO blob VALUES(2, 'world hello');
  INSERT INTO blob SELECT NULL, v FROM blob;
  INSERT INTO blob SELECT NULL, v FROM blob;
  INSERT INTO blob SELECT NULL, v FROM blob;
  INSERT INTO blob SELECT NULL, v FROM blob;
  INSERT INTO blob SELECT NULL, v FROM blob;
  INSERT INTO blob SELECT NULL, v FROM blob;
  INSERT INTO blob SELECT NULL, v FROM blob;
  INSERT INTO blob SELECT NULL, v FROM blob;
  INSERT INTO blob SELECT NULL, v FROM blob;
  INSERT INTO blob SELECT NULL, v FROM blob;
}

do_faultsim_test 1 -prep {
  sqlite3 db test.db
  set ::blob [db incrblob blob v 1]
} -body {
  if {[catch {sqlite3_blob_reopen $::blob 1000}]} {
    error [sqlite3_errmsg db]
  }
} -test {
  faultsim_test_result {0 {}}
  close $::blob
}

do_faultsim_test 2 -prep {
  sqlite3 db test.db
  set ::blob [db incrblob blob v 1]
} -body {
  if {[catch {sqlite3_blob_reopen $::blob -1}]} {
    error [sqlite3_errmsg db]
  }
} -test {
  faultsim_test_result {1 {no such rowid: -1}}
  close $::blob
}

do_faultsim_test 3 -prep {
  sqlite3 db test.db
} -body {
  set ::blob [db incrblob blob v 1]
  gets $::blob
} -test {
  faultsim_test_result {0 {hello world}}
  catch { close $::blob }
}

finish_test