diff options
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/rdonly.test')
-rw-r--r-- | libraries/sqlite/unix/sqlite-3.5.1/test/rdonly.test | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/rdonly.test b/libraries/sqlite/unix/sqlite-3.5.1/test/rdonly.test new file mode 100644 index 0000000..2f6ebc7 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/test/rdonly.test | |||
@@ -0,0 +1,65 @@ | |||
1 | # 2007 April 24 | ||
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 | # This file implements regression tests for SQLite library. | ||
12 | # | ||
13 | # This file implements tests to make sure SQLite treats a database | ||
14 | # as readonly if its write version is set to high. | ||
15 | # | ||
16 | # $Id: rdonly.test,v 1.1 2007/04/24 17:27:52 drh Exp $ | ||
17 | |||
18 | set testdir [file dirname $argv0] | ||
19 | source $testdir/tester.tcl | ||
20 | |||
21 | |||
22 | # Create a database. | ||
23 | # | ||
24 | do_test rdonly-1.1 { | ||
25 | execsql { | ||
26 | CREATE TABLE t1(x); | ||
27 | INSERT INTO t1 VALUES(1); | ||
28 | SELECT * FROM t1; | ||
29 | } | ||
30 | } {1} | ||
31 | |||
32 | # Changes the write version from 1 to 2. Verify that the database | ||
33 | # can be read but not written. | ||
34 | # | ||
35 | do_test rdonly-1.2 { | ||
36 | db close | ||
37 | hexio_get_int [hexio_read test.db 18 1] | ||
38 | } 1 | ||
39 | do_test rdonly-1.3 { | ||
40 | hexio_write test.db 18 02 | ||
41 | sqlite3 db test.db | ||
42 | execsql { | ||
43 | SELECT * FROM t1; | ||
44 | } | ||
45 | } {1} | ||
46 | do_test rdonly-1.4 { | ||
47 | catchsql { | ||
48 | INSERT INTO t1 VALUES(2) | ||
49 | } | ||
50 | } {1 {attempt to write a readonly database}} | ||
51 | |||
52 | # Change the write version back to 1. Verify that the database | ||
53 | # is read-write again. | ||
54 | # | ||
55 | do_test rdonly-1.5 { | ||
56 | db close | ||
57 | hexio_write test.db 18 01 | ||
58 | sqlite3 db test.db | ||
59 | catchsql { | ||
60 | INSERT INTO t1 VALUES(2); | ||
61 | SELECT * FROM t1; | ||
62 | } | ||
63 | } {0 {1 2}} | ||
64 | |||
65 | finish_test | ||