Remove a lot of the text describing extended format options from the
[sqlite.git] / test / fts3tok1.test
blob139fae89d905acd20a9a5660d6aa6d31c57a89ad
1 # 2013 April 22
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.
24 do_execsql_test 1.0 {
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
35   }
37   do_execsql_test 1.$tn.2 "
38     SELECT token FROM $tbl WHERE input = 'OnE tWo tHrEe'
39   " {
40     one two three
41   }
44 do_execsql_test 1.4 {
45   SELECT token FROM t3 WHERE input = '1x2x3x'
46 } {1 2 3}
48 do_execsql_test 1.5 {
49   SELECT token FROM t1 WHERE input = '1x2x3x'
50 } {1x2x3x}
52 do_execsql_test 1.6 {
53   SELECT token FROM t3 WHERE input = '1''2x3x'
54 } {1'2 3}
56 do_execsql_test 1.7 {
57   SELECT token FROM t3 WHERE input = ''
58 } {}
60 do_execsql_test 1.8 {
61   SELECT token FROM t3 WHERE input = NULL
62 } {}
64 do_execsql_test 1.9 {
65   SELECT * FROM t3 WHERE input = 123
66 } {123 123 0 3 0}
68 do_execsql_test 1.10 {
69   SELECT * FROM t1 WHERE input = 'a b c' AND token = 'b';
70 } {
71   {a b c} b 2 3 1
74 do_execsql_test 1.11 {
75   SELECT * FROM t1 WHERE token = 'b' AND input = 'a b c';
76 } {
77   {a b c} b 2 3 1
80 do_execsql_test 1.12 {
81   SELECT * FROM t1 WHERE input < 'b' AND input = 'a b c';
82 } {
83   {a b c} a 0 1 0 
84   {a b c} b 2 3 1 
85   {a b c} c 4 5 2
88 do_execsql_test 1.13.1 {
89   CREATE TABLE c1(x);
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;
95 } {
96   {a b c} {a b c} a 0 1 0 
97   {d e f} {d e f} e 2 3 1 
101 #-------------------------------------------------------------------------
102 # Error cases.
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;
110   SELECT * FROM t4;
111 } {1 {SQL logic error}}
113 do_catchsql_test 2.2 {
114   CREATE VIRTUAL TABLE t USING fts4(tokenize=simple""); 
115 } {0 {}}
117 ifcapable fts3_unicode {
118   do_catchsql_test 2.3 {
119     CREATE VIRTUAL TABLE u USING fts4(tokenize=unicode61""); 
120   } {1 {unknown tokenizer}}
124 finish_test