fix remapping behavior. Remapping is only necessary if we are rendering on the workbe...
[AROS-Contrib.git] / sqlite3 / test / safety.test
bloba12cd84b245ea84490a66356a53950f3369a9667
1 # 2005 January 11
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.  The
12 # focus of this file is testing the sqlite3SafetyOn and sqlite3SafetyOff
13 # functions.  Those routines are not strictly necessary - they are
14 # designed to detect misuse of the library.
16 # $Id: safety.test,v 1.1 2005/01/11 15:28:33 drh Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
21 do_test safety-1.1 {
22   db close
23   set DB [sqlite3 db test.db]
24   db eval {CREATE TABLE t1(a)}
25   sqlite_set_magic $DB SQLITE_MAGIC_BUSY
26   catchsql {
27     SELECT name FROM sqlite_master;
28   }
29 } {1 {library routine called out of sequence}}
30 do_test safety-1.2 {
31   sqlite_set_magic $DB SQLITE_MAGIC_OPEN
32   catchsql {
33     SELECT name FROM sqlite_master
34   }
35 } {0 t1}
37 do_test safety-2.1 {
38   proc safety_on {} "sqlite_set_magic $DB SQLITE_MAGIC_BUSY"
39   db function safety_on safety_on
40   catchsql {
41     SELECT safety_on(), name FROM sqlite_master
42   }
43 } {1 {library routine called out of sequence}}
44 do_test safety-2.2 {
45   catchsql {
46     SELECT 'hello'
47   }
48 } {1 {library routine called out of sequence}}
49 do_test safety-2.3 {
50   sqlite3_close $DB
51 } {SQLITE_MISUSE}
52 do_test safety-2.4 {
53   sqlite_set_magic $DB SQLITE_MAGIC_OPEN
54   execsql {
55     SELECT name FROM sqlite_master
56   }
57 } {t1}
59 do_test safety-3.1 {
60   set rc [catch {
61     db eval {SELECT name FROM sqlite_master} {
62       sqlite_set_magic $DB SQLITE_MAGIC_BUSY
63     }
64   } msg]
65   lappend rc $msg
66 } {1 {library routine called out of sequence}}
67 sqlite_set_magic $DB SQLITE_MAGIC_OPEN
69 finish_test