Debian Codegraph @

ext/fts5/test/fts5tokendata.test

raw
1 # 2014 Jan 08
2 #
3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
5 #
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.
9 #
10 #***********************************************************************
11 #
12 # Tests focused on phrase queries.
13 #
14
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 set testprefix fts5tokendata
17
18 # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
19 ifcapable !fts5 {
20 finish_test
21 return
22 }
23
24 foreach_detail_mode $testprefix {
25
26 sqlite3_fts5_register_origintext db
27 fts5_aux_test_functions db
28 proc b {x} { string map [list "\0" "."] $x }
29 db func b b
30
31 do_execsql_test 1.0 {
32 CREATE VIRTUAL TABLE ft USING fts5(a, b, tokendata=1,
33 tokenize="origintext unicode61", detail=%DETAIL%
34 );
35 CREATE VIRTUAL TABLE vocab USING fts5vocab(ft, instance);
36 }
37
38 do_execsql_test 1.1 {
39 INSERT INTO ft(rowid, a, b) VALUES
40 (1, 'Pedagog Pedal Pedant', 'Peculier Day Today'),
41 (2, 'Pedant pedantic pecked', 'Peck Penalize Pen');
42
43 INSERT INTO ft(rowid, a, b) VALUES
44 (3, 'Penalty Pence Penciled', 'One Two Three'),
45 (4, 'Pedant Pedal Pedant', 'Peculier Day Today');
46 }
47
48 do_execsql_test 1.2 {
49 SELECT DISTINCT b(term) FROM vocab
50 } {
51 day.Day one.One peck.Peck pecked peculier.Peculier pedagog.Pedagog
52 pedal.Pedal pedant.Pedant pedantic pen.Pen penalize.Penalize
53 penalty.Penalty pence.Pence penciled.Penciled three.Three
54 today.Today two.Two
55 }
56
57 do_execsql_test 1.3.1 {
58 SELECT rowid FROM ft('pe*')
59 } {
60 1 2 3 4
61 }
62
63 do_execsql_test 1.3.2 {
64 SELECT rowid FROM ft('pe*') ORDER BY rowid DESC
65 } {
66 4 3 2 1
67 }
68
69 if {"%DETAIL%"!="none"} {
70 do_execsql_test 1.3.3 {
71 SELECT rowid FROM ft WHERE a MATCH 'pe*' ORDER BY rowid DESC
72 } {
73 4 3 2 1
74 }
75 }
76
77 do_execsql_test 1.4 {
78 SELECT rowid, b( fts5_test_insttoken(ft, 0, 0) ) FROM ft('pedant')
79 } {
80 1 pedant.Pedant
81 2 pedant.Pedant
82 4 pedant.Pedant
83 }
84
85 do_execsql_test 1.5 {
86 SELECT rowid, b( fts5_test_insttoken(ft, 0, 0) ) FROM ft('pe*')
87 } {
88 1 pedagog.Pedagog
89 2 pedant.Pedant
90 3 penalty.Penalty
91 4 pedant.Pedant
92 }
93
94 do_execsql_test 1.6 {
95 SELECT rowid, fts5_test_poslist(ft) FROM ft('pe*')
96 } {
97 1 {0.0.0 0.0.1 0.0.2 0.1.0}
98 2 {0.0.0 0.0.1 0.0.2 0.1.0 0.1.1 0.1.2}
99 3 {0.0.0 0.0.1 0.0.2}
100 4 {0.0.0 0.0.1 0.0.2 0.1.0}
101 }
102 }
103
104 finish_test
105