1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/fts2l.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,69 @@
1.4 +# 2007 March 28
1.5 +#
1.6 +# The author disclaims copyright to this source code.
1.7 +#
1.8 +#*************************************************************************
1.9 +# This file implements regression tests for SQLite library. The focus
1.10 +# of this script is testing isspace/isalnum/tolower problems with the
1.11 +# FTS2 module. Unfortunately, this code isn't a really principled set
1.12 +# of tests, because it is impossible to know where new uses of these
1.13 +# functions might appear.
1.14 +#
1.15 +# $Id: fts2l.test,v 1.2 2007/12/13 21:54:11 drh Exp $
1.16 +#
1.17 +
1.18 +set testdir [file dirname $argv0]
1.19 +source $testdir/tester.tcl
1.20 +
1.21 +# If SQLITE_ENABLE_FTS2 is defined, omit this file.
1.22 +ifcapable !fts2 {
1.23 + finish_test
1.24 + return
1.25 +}
1.26 +
1.27 +# Tests that startsWith() (calls isspace, tolower, isalnum) can handle
1.28 +# hi-bit chars. parseSpec() also calls isalnum here.
1.29 +do_test fts2l-1.1 {
1.30 + execsql "CREATE VIRTUAL TABLE t1 USING fts2(content, \x80)"
1.31 +} {}
1.32 +
1.33 +# Additionally tests isspace() call in getToken(), and isalnum() call
1.34 +# in tokenListToIdList().
1.35 +do_test fts2l-1.2 {
1.36 + catch {
1.37 + execsql "CREATE VIRTUAL TABLE t2 USING fts2(content, tokenize \x80)"
1.38 + }
1.39 + sqlite3_errmsg $DB
1.40 +} "unknown tokenizer: \x80"
1.41 +
1.42 +# Additionally test final isalnum() in startsWith().
1.43 +do_test fts2l-1.3 {
1.44 + execsql "CREATE VIRTUAL TABLE t3 USING fts2(content, tokenize\x80)"
1.45 +} {}
1.46 +
1.47 +# The snippet-generation code has calls to isspace() which are sort of
1.48 +# hard to get to. It finds convenient breakpoints by starting ~40
1.49 +# chars before and after the matched term, and scanning ~10 chars
1.50 +# around that position for isspace() characters. The long word with
1.51 +# embedded hi-bit chars causes one of these isspace() calls to be
1.52 +# exercised. The version with a couple extra spaces should cause the
1.53 +# other isspace() call to be exercised. [Both cases have been tested
1.54 +# in the debugger, but I'm hoping to continue to catch it if simple
1.55 +# constant changes change things slightly.
1.56 +#
1.57 +# The trailing and leading hi-bit chars help with code which tests for
1.58 +# isspace() to coalesce multiple spaces.
1.59 +
1.60 +set word "\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80"
1.61 +set phrase1 "$word $word $word target $word $word $word"
1.62 +set phrase2 "$word $word $word target $word $word $word"
1.63 +
1.64 +db eval {CREATE VIRTUAL TABLE t4 USING fts2(content)}
1.65 +db eval "INSERT INTO t4 (content) VALUES ('$phrase1')"
1.66 +db eval "INSERT INTO t4 (content) VALUES ('$phrase2')"
1.67 +
1.68 +do_test fts2l-1.4 {
1.69 + execsql {SELECT rowid, length(snippet(t4)) FROM t4 WHERE t4 MATCH 'target'}
1.70 +} {1 111 2 117}
1.71 +
1.72 +finish_test