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 script is testing the "fts3tokenize" virtual table
13 # that is part of the FTS3 module.
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18 ifcapable !fts3 { finish_test ; return }
19 set ::testprefix fts3tok1
21 #-------------------------------------------------------------------------
22 # Simple test cases. Using the default (simple) tokenizer.
25 CREATE VIRTUAL TABLE t1 USING fts3tokenize(simple);
26 CREATE VIRTUAL TABLE t2 USING fts3tokenize();
27 CREATE VIRTUAL TABLE t3 USING fts3tokenize(simple, '', 'xyz ');
30 foreach {tn tbl} {1 t1 2 t2 3 t3} {
31 do_execsql_test 1.$tn.1 "SELECT * FROM $tbl WHERE input = 'one two three'" {
32 {one two three} one 0 3 0
33 {one two three} two 4 7 1
34 {one two three} three 8 13 2
37 do_execsql_test 1.$tn.2 "
38 SELECT token FROM $tbl WHERE input = 'OnE tWo tHrEe'
45 SELECT token FROM t3 WHERE input = '1x2x3x'
49 SELECT token FROM t1 WHERE input = '1x2x3x'
53 SELECT token FROM t3 WHERE input = '1''2x3x'
57 SELECT token FROM t3 WHERE input = ''
61 SELECT token FROM t3 WHERE input = NULL
65 SELECT * FROM t3 WHERE input = 123
68 do_execsql_test 1.10 {
69 SELECT * FROM t1 WHERE input = 'a b c' AND token = 'b';
74 do_execsql_test 1.11 {
75 SELECT * FROM t1 WHERE token = 'b' AND input = 'a b c';
80 do_execsql_test 1.12 {
81 SELECT * FROM t1 WHERE input < 'b' AND input = 'a b c';
88 do_execsql_test 1.13.1 {
90 INSERT INTO c1(x) VALUES('a b c');
91 INSERT INTO c1(x) VALUES('d e f');
93 do_execsql_test 1.13.2 {
94 SELECT * FROM c1, t1 WHERE input = x AND c1.rowid=t1.rowid;
96 {a b c} {a b c} a 0 1 0
97 {d e f} {d e f} e 2 3 1
101 #-------------------------------------------------------------------------
104 do_catchsql_test 2.0 {
105 CREATE VIRTUAL TABLE tX USING fts3tokenize(nosuchtokenizer);
106 } {1 {unknown tokenizer: nosuchtokenizer}}
108 do_catchsql_test 2.1 {
109 CREATE VIRTUAL TABLE t4 USING fts3tokenize;
111 } {1 {SQL logic error}}
113 do_catchsql_test 2.2 {
114 CREATE VIRTUAL TABLE t USING fts4(tokenize=simple"");
117 ifcapable fts3_unicode {
118 do_catchsql_test 2.3 {
119 CREATE VIRTUAL TABLE u USING fts4(tokenize=unicode61"");
120 } {1 {unknown tokenizer}}