diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 23:37:03 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 23:37:03 +0000 |
commit | e33cba46498a40774bc6d33a9258afbd5fa059e6 (patch) | |
tree | 4ce6b22f4f7b2b245b2d89bb9209a53e3274b263 /third_party/sqlite/src/test/fts2i.test | |
parent | aaf6472fd01db928919d4dc13687bde2a4b5c7b9 (diff) | |
download | chromium_src-e33cba46498a40774bc6d33a9258afbd5fa059e6.zip chromium_src-e33cba46498a40774bc6d33a9258afbd5fa059e6.tar.gz chromium_src-e33cba46498a40774bc6d33a9258afbd5fa059e6.tar.bz2 |
Move bundled copy of sqlite one level deeper to better separate it
from our patches, READMEs, etc.
Also, add a shim header so we can use it for building
with system sqlite.
TEST=compile
BUG=22208
Review URL: http://codereview.chromium.org/3108030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56619 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/sqlite/src/test/fts2i.test')
-rw-r--r-- | third_party/sqlite/src/test/fts2i.test | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/third_party/sqlite/src/test/fts2i.test b/third_party/sqlite/src/test/fts2i.test new file mode 100644 index 0000000..e732e6a --- /dev/null +++ b/third_party/sqlite/src/test/fts2i.test @@ -0,0 +1,87 @@ +# 2007 January 17 +# +# The author disclaims copyright to this source code. +# +#************************************************************************* +# This file implements regression tests for SQLite fts2 library. The +# focus here is testing handling of UPDATE when using UTF-16-encoded +# databases. +# +# $Id: fts2i.test,v 1.2 2007/01/24 03:46:35 drh Exp $ +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# If SQLITE_ENABLE_FTS2 is defined, omit this file. +ifcapable !fts2 { + finish_test + return +} + +# Return the UTF-16 representation of the supplied UTF-8 string $str. +# If $nt is true, append two 0x00 bytes as a nul terminator. +# NOTE(shess) Copied from capi3.test. +proc utf16 {str {nt 1}} { + set r [encoding convertto unicode $str] + if {$nt} { + append r "\x00\x00" + } + return $r +} + +db eval { + PRAGMA encoding = "UTF-16le"; + CREATE VIRTUAL TABLE t1 USING fts2(content); +} + +do_test fts2i-1.0 { + execsql {PRAGMA encoding} +} {UTF-16le} + +do_test fts2i-1.1 { + execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')} + execsql {SELECT content FROM t1 WHERE rowid = 1} +} {one} + +do_test fts2i-1.2 { + set sql "INSERT INTO t1 (rowid, content) VALUES(2, 'two')" + set STMT [sqlite3_prepare $DB $sql -1 TAIL] + sqlite3_step $STMT + sqlite3_finalize $STMT + execsql {SELECT content FROM t1 WHERE rowid = 2} +} {two} + +do_test fts2i-1.3 { + set sql "INSERT INTO t1 (rowid, content) VALUES(3, 'three')" + set STMT [sqlite3_prepare $DB $sql -1 TAIL] + sqlite3_step $STMT + sqlite3_finalize $STMT + set sql "UPDATE t1 SET content = 'trois' WHERE rowid = 3" + set STMT [sqlite3_prepare $DB $sql -1 TAIL] + sqlite3_step $STMT + sqlite3_finalize $STMT + execsql {SELECT content FROM t1 WHERE rowid = 3} +} {trois} + +do_test fts2i-1.4 { + set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(4, 'four')}] + set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL] + sqlite3_step $STMT + sqlite3_finalize $STMT + execsql {SELECT content FROM t1 WHERE rowid = 4} +} {four} + +do_test fts2i-1.5 { + set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(5, 'five')}] + set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL] + sqlite3_step $STMT + sqlite3_finalize $STMT + set sql "UPDATE t1 SET content = 'cinq' WHERE rowid = 5" + set STMT [sqlite3_prepare $DB $sql -1 TAIL] + sqlite3_step $STMT + sqlite3_finalize $STMT + execsql {SELECT content FROM t1 WHERE rowid = 5} +} {cinq} + +finish_test |