diff options
author | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-06 22:39:41 +0000 |
---|---|---|
committer | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-06 22:39:41 +0000 |
commit | 586381f8db3497c24c11f96234f1879b34e74bc7 (patch) | |
tree | 99f7d18350289b135ef6dd5c161baba8bce668a3 /third_party/sqlite/test/safety.test | |
parent | 6e3b12ff2cbbe8c481f986c8f0dd230bb50add2a (diff) | |
download | chromium_src-586381f8db3497c24c11f96234f1879b34e74bc7.zip chromium_src-586381f8db3497c24c11f96234f1879b34e74bc7.tar.gz chromium_src-586381f8db3497c24c11f96234f1879b34e74bc7.tar.bz2 |
Upgrade our sqlite to 3.6.1, with the local changes made by Gears. I'm
checking in the full sqlite tree to make upstream merges easier. This means
we'll have generated sources split out from the originals.
One important change this makes is that "BEGIN" now defaults to "BEGIN
IMMEDIATE" rather than "BEGIN DEFERRED". This doesn't affect us because we
don't use unqualified BEGIN statements.
The full CL is too big for Rietveld. I'm splitting it into 2. This one is
reviewable. The other CL is just a fresh drop of:
//depot/googleclient/gears/opensource/third_party/sqlite_google
Review URL: http://codereview.chromium.org/15067
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7623 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/sqlite/test/safety.test')
-rwxr-xr-x | third_party/sqlite/test/safety.test | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/third_party/sqlite/test/safety.test b/third_party/sqlite/test/safety.test new file mode 100755 index 0000000..9cca57c --- /dev/null +++ b/third_party/sqlite/test/safety.test @@ -0,0 +1,93 @@ +# 2005 January 11 +# +# 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. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing the sqlite3SafetyOn and sqlite3SafetyOff +# functions. Those routines are not strictly necessary - they are +# designed to detect misuse of the library. +# +# $Id: safety.test,v 1.4 2008/03/18 13:46:53 drh Exp $ + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +ifcapable !debug { + puts "Skipping safety tests since SQLITE_DEBUG is off" + finish_test + return +} + +# Return the UTF-8 representation of the supplied UTF-16 string $str. +proc utf8 {str} { + # If $str ends in two 0x00 0x00 bytes, knock these off before + # converting to UTF-8 using TCL. + binary scan $str \c* vals + if {[lindex $vals end]==0 && [lindex $vals end-1]==0} { + set str [binary format \c* [lrange $vals 0 end-2]] + } + + set r [encoding convertfrom unicode $str] + return $r +} + + +do_test safety-1.1 { + set DB [sqlite3_connection_pointer db] + db eval {CREATE TABLE t1(a)} + sqlite_set_magic $DB SQLITE_MAGIC_BUSY + catchsql { + SELECT name FROM sqlite_master; + } +} {1 {library routine called out of sequence}} +do_test safety-1.2 { + sqlite_set_magic $DB SQLITE_MAGIC_OPEN + catchsql { + SELECT name FROM sqlite_master + } +} {0 t1} + +do_test safety-2.1 { + proc safety_on {} "sqlite_set_magic $DB SQLITE_MAGIC_BUSY" + db function safety_on safety_on + catchsql { + SELECT safety_on(), name FROM sqlite_master + } +} {1 {library routine called out of sequence}} +ifcapable {utf16} { + do_test safety-2.1.1 { + utf8 [sqlite3_errmsg16 db] + } {library routine called out of sequence} +} +do_test safety-2.2 { + catchsql { + SELECT 'hello' + } +} {1 {library routine called out of sequence}} +do_test safety-2.3 { + sqlite3_close $DB +} {SQLITE_MISUSE} +do_test safety-2.4 { + sqlite_set_magic $DB SQLITE_MAGIC_OPEN + execsql { + SELECT name FROM sqlite_master + } +} {t1} + +do_test safety-3.1 { + set rc [catch { + db eval {SELECT name FROM sqlite_master} { + sqlite_set_magic $DB SQLITE_MAGIC_BUSY + } + } msg] + lappend rc $msg +} {1 {library routine called out of sequence}} +sqlite_set_magic $DB SQLITE_MAGIC_OPEN + +finish_test |