1
0

incrblobfault.test 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # 2010 October 26
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # 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. set testdir [file dirname $argv0]
  14. source $testdir/tester.tcl
  15. set testprefix incrblobfault
  16. do_execsql_test 1.0 {
  17. CREATE TABLE blob(x INTEGER PRIMARY KEY, v BLOB);
  18. INSERT INTO blob VALUES(1, 'hello world');
  19. INSERT INTO blob VALUES(2, 'world hello');
  20. INSERT INTO blob SELECT NULL, v FROM blob;
  21. INSERT INTO blob SELECT NULL, v FROM blob;
  22. INSERT INTO blob SELECT NULL, v FROM blob;
  23. INSERT INTO blob SELECT NULL, v FROM blob;
  24. INSERT INTO blob SELECT NULL, v FROM blob;
  25. INSERT INTO blob SELECT NULL, v FROM blob;
  26. INSERT INTO blob SELECT NULL, v FROM blob;
  27. INSERT INTO blob SELECT NULL, v FROM blob;
  28. INSERT INTO blob SELECT NULL, v FROM blob;
  29. INSERT INTO blob SELECT NULL, v FROM blob;
  30. }
  31. do_faultsim_test 1 -prep {
  32. sqlite3 db test.db
  33. set ::blob [db incrblob blob v 1]
  34. } -body {
  35. if {[catch {sqlite3_blob_reopen $::blob 1000}]} {
  36. error [sqlite3_errmsg db]
  37. }
  38. } -test {
  39. faultsim_test_result {0 {}}
  40. close $::blob
  41. }
  42. do_faultsim_test 2 -prep {
  43. sqlite3 db test.db
  44. set ::blob [db incrblob blob v 1]
  45. } -body {
  46. if {[catch {sqlite3_blob_reopen $::blob -1}]} {
  47. error [sqlite3_errmsg db]
  48. }
  49. } -test {
  50. faultsim_test_result {1 {no such rowid: -1}}
  51. close $::blob
  52. }
  53. do_faultsim_test 3 -prep {
  54. sqlite3 db test.db
  55. } -body {
  56. set ::blob [db incrblob blob v 1]
  57. gets $::blob
  58. } -test {
  59. faultsim_test_result {0 {hello world}}
  60. catch { close $::blob }
  61. }
  62. finish_test