2014-12-29 14:24:46 +03:00
|
|
|
# 2014 Dec 20
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
#
|
|
|
|
# Tests focusing on the fts5 tokenizers
|
|
|
|
#
|
|
|
|
|
|
|
|
if {![info exists testdir]} {
|
2014-12-29 18:59:36 +03:00
|
|
|
set testdir [file join [file dirname [info script]] .. .. .. test]
|
2014-12-29 14:24:46 +03:00
|
|
|
}
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
set testprefix fts5tokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do_execsql_test 1.0 {
|
|
|
|
CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize=porter);
|
|
|
|
DROP TABLE ft1;
|
|
|
|
}
|
|
|
|
do_execsql_test 1.1 {
|
|
|
|
CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize='porter');
|
|
|
|
DROP TABLE ft1;
|
|
|
|
}
|
|
|
|
do_execsql_test 1.2 {
|
|
|
|
CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize = porter);
|
|
|
|
DROP TABLE ft1;
|
|
|
|
}
|
|
|
|
do_execsql_test 1.3 {
|
|
|
|
CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize = 'porter');
|
|
|
|
DROP TABLE ft1;
|
|
|
|
}
|
|
|
|
do_execsql_test 1.4 {
|
|
|
|
CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize = 'porter simple');
|
|
|
|
DROP TABLE ft1;
|
|
|
|
}
|
|
|
|
|
|
|
|
do_execsql_test 2.0 {
|
|
|
|
CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize=porter);
|
|
|
|
INSERT INTO ft1 VALUES('embedded databases');
|
|
|
|
}
|
|
|
|
do_execsql_test 2.1 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'embedding' } 1
|
|
|
|
do_execsql_test 2.2 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'database' } 1
|
|
|
|
do_execsql_test 2.3 {
|
|
|
|
SELECT rowid FROM ft1 WHERE ft1 MATCH 'database embedding'
|
|
|
|
} 1
|
|
|
|
|
|
|
|
|
|
|
|
proc tcl_create {args} {
|
|
|
|
set ::targs $args
|
|
|
|
error "failed"
|
|
|
|
}
|
|
|
|
sqlite3_fts5_create_tokenizer db tcl tcl_create
|
|
|
|
|
|
|
|
foreach {tn directive expected} {
|
|
|
|
1 {tokenize='tcl a b c'} {a b c}
|
|
|
|
2 {tokenize='tcl ''d'' ''e'' ''f'''} {d e f}
|
|
|
|
3 {tokenize="tcl 'g' 'h' 'i'"} {g h i}
|
|
|
|
4 {tokenize = tcl} {}
|
|
|
|
} {
|
|
|
|
do_catchsql_test 3.$tn.1 "
|
|
|
|
CREATE VIRTUAL TABLE ft2 USING fts5(x, $directive)
|
|
|
|
" {1 {error in tokenizer constructor}}
|
|
|
|
do_test 3.$tn.2 { set ::targs } $expected
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
do_catchsql_test 4.1 {
|
|
|
|
CREATE VIRTUAL TABLE ft2 USING fts5(x, tokenize = tcl abc);
|
|
|
|
} {1 {parse error in "tokenize = tcl abc"}}
|
|
|
|
do_catchsql_test 4.2 {
|
|
|
|
CREATE VIRTUAL TABLE ft2 USING fts5(x y)
|
|
|
|
} {1 {parse error in "x y"}}
|
|
|
|
|
|
|
|
finish_test
|
|
|
|
|