Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: third_party/sqlite/src/ext/fts5/test/fts5ak.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # 2014 November 24 1 # 2014 November 24
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #************************************************************************* 10 #*************************************************************************
11 # This file implements regression tests for SQLite library. The 11 # This file implements regression tests for SQLite library. The
12 # focus of this script is testing the FTS5 module. 12 # focus of this script is testing the FTS5 module.
13 # 13 #
14 # Specifically, the auxiliary function "highlight". 14 # Specifically, the auxiliary function "highlight".
15 # 15 #
16 16
17 source [file join [file dirname [info script]] fts5_common.tcl] 17 source [file join [file dirname [info script]] fts5_common.tcl]
18 set testprefix fts5ak 18 set testprefix fts5ak
19 19
20 # If SQLITE_ENABLE_FTS5 is defined, omit this file. 20 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
21 ifcapable !fts5 { 21 ifcapable !fts5 {
22 finish_test 22 finish_test
23 return 23 return
24 } 24 }
25 25
26 foreach_detail_mode $testprefix {
27
26 do_execsql_test 1.1 { 28 do_execsql_test 1.1 {
27 CREATE VIRTUAL TABLE ft1 USING fts5(x); 29 CREATE VIRTUAL TABLE ft1 USING fts5(x, detail=%DETAIL%);
28 INSERT INTO ft1 VALUES('i d d a g i b g d d'); 30 INSERT INTO ft1 VALUES('i d d a g i b g d d');
29 INSERT INTO ft1 VALUES('h d b j c c g a c a'); 31 INSERT INTO ft1 VALUES('h d b j c c g a c a');
30 INSERT INTO ft1 VALUES('e j a e f h b f h h'); 32 INSERT INTO ft1 VALUES('e j a e f h b f h h');
31 INSERT INTO ft1 VALUES('j f h d g h i b d f'); 33 INSERT INTO ft1 VALUES('j f h d g h i b d f');
32 INSERT INTO ft1 VALUES('d c j d c j b c g e'); 34 INSERT INTO ft1 VALUES('d c j d c j b c g e');
33 INSERT INTO ft1 VALUES('i a d e g j g d a a'); 35 INSERT INTO ft1 VALUES('i a d e g j g d a a');
34 INSERT INTO ft1 VALUES('j f c e d a h j d b'); 36 INSERT INTO ft1 VALUES('j f c e d a h j d b');
35 INSERT INTO ft1 VALUES('i c c f a d g h j e'); 37 INSERT INTO ft1 VALUES('i c c f a d g h j e');
36 INSERT INTO ft1 VALUES('i d i g c d c h b f'); 38 INSERT INTO ft1 VALUES('i d i g c d c h b f');
37 INSERT INTO ft1 VALUES('g d a e h a b c f j'); 39 INSERT INTO ft1 VALUES('g d a e h a b c f j');
40
41 CREATE VIRTUAL TABLE ft2 USING fts5(x, detail=%DETAIL%);
42 INSERT INTO ft2 VALUES('a b c d e f g h i j');
38 } 43 }
39 44
40 do_execsql_test 1.2 { 45 do_execsql_test 1.2 {
41 SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'e'; 46 SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'e';
42 } { 47 } {
43 {[e] j a [e] f h b f h h} 48 {[e] j a [e] f h b f h h}
44 {d c j d c j b c g [e]} 49 {d c j d c j b c g [e]}
45 {i a d [e] g j g d a a} 50 {i a d [e] g j g d a a}
46 {j f c [e] d a h j d b} 51 {j f c [e] d a h j d b}
47 {i c c f a d g h j [e]} 52 {i c c f a d g h j [e]}
48 {g d a [e] h a b c f j} 53 {g d a [e] h a b c f j}
49 } 54 }
50 55
51 do_execsql_test 1.3 { 56 do_execsql_test 1.3 {
52 SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'h + d';
53 } {
54 {[h d] b j c c g a c a}
55 {j f [h d] g h i b d f}
56 }
57
58 do_execsql_test 1.4 {
59 SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'd + d';
60 } {
61 {i [d d] a g i b g [d d]}
62 }
63
64 do_execsql_test 1.5 {
65 SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'e e e' 57 SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'e e e'
66 } { 58 } {
67 {[e] j a [e] f h b f h h} 59 {[e] j a [e] f h b f h h}
68 {d c j d c j b c g [e]} 60 {d c j d c j b c g [e]}
69 {i a d [e] g j g d a a} 61 {i a d [e] g j g d a a}
70 {j f c [e] d a h j d b} 62 {j f c [e] d a h j d b}
71 {i c c f a d g h j [e]} 63 {i c c f a d g h j [e]}
72 {g d a [e] h a b c f j} 64 {g d a [e] h a b c f j}
73 } 65 }
74 66
75 do_execsql_test 1.6 { 67 do_execsql_test 1.4 {
68 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'f d'
69 } {
70 {a b c [d] e [f] g h i j}
71 }
72
73 do_execsql_test 1.5 {
74 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'd f'
75 } {
76 {a b c [d] e [f] g h i j}
77 }
78
79 #-------------------------------------------------------------------------
80 # Tests below this point require detail=full.
81 #-------------------------------------------------------------------------
82 if {[detail_is_full]==0} continue
83
84
85 do_execsql_test 2.1 {
86 SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'h + d';
87 } {
88 {[h d] b j c c g a c a}
89 {j f [h d] g h i b d f}
90 }
91
92 do_execsql_test 2.2 {
93 SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'd + d';
94 } {
95 {i [d d] a g i b g [d d]}
96 }
97
98 do_execsql_test 2.3 {
76 SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'd + d d + d'; 99 SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'd + d d + d';
77 } { 100 } {
78 {i [d d] a g i b g [d d]} 101 {i [d d] a g i b g [d d]}
79 } 102 }
80 103
81 do_execsql_test 2.1 { 104 do_execsql_test 2.4 {
82 CREATE VIRTUAL TABLE ft2 USING fts5(x);
83 INSERT INTO ft2 VALUES('a b c d e f g h i j');
84 }
85
86 do_execsql_test 2.2 {
87 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d c+d+e' 105 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d c+d+e'
88 } {{a [b c d e] f g h i j}} 106 } {{a [b c d e] f g h i j}}
89 107
90 do_execsql_test 2.3 { 108 do_execsql_test 2.5 {
91 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d e+f+g' 109 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d e+f+g'
92 } { 110 } {
93 {a [b c d] [e f g] h i j} 111 {a [b c d] [e f g] h i j}
94 } 112 }
95 113
96 do_execsql_test 2.4 { 114 do_execsql_test 2.6 {
97 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d c' 115 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d c'
98 } { 116 } {
99 {a [b c d] e f g h i j} 117 {a [b c d] e f g h i j}
100 } 118 }
101 119
102 do_execsql_test 2.5 { 120 do_execsql_test 2.7 {
103 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c c+d+e' 121 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c c+d+e'
104 } { 122 } {
105 {a [b c d e] f g h i j} 123 {a [b c d e] f g h i j}
106 } 124 }
107 125
108 do_execsql_test 2.6.1 {
109 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'f d'
110 } {
111 {a b c [d] e [f] g h i j}
112 }
113
114 do_execsql_test 2.6.2 {
115 SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'd f'
116 } {
117 {a b c [d] e [f] g h i j}
118 }
119
120 #------------------------------------------------------------------------- 126 #-------------------------------------------------------------------------
121 # The example from the docs. 127 # The example from the docs.
122 # 128 #
123 do_execsql_test 3.1 { 129 do_execsql_test 3.1 {
124 -- Assuming this: 130 -- Assuming this:
125 CREATE VIRTUAL TABLE ft USING fts5(a); 131 CREATE VIRTUAL TABLE ft USING fts5(a, detail=%DETAIL%);
126 INSERT INTO ft VALUES('a b c x c d e'); 132 INSERT INTO ft VALUES('a b c x c d e');
127 INSERT INTO ft VALUES('a b c c d e'); 133 INSERT INTO ft VALUES('a b c c d e');
128 INSERT INTO ft VALUES('a b c d e'); 134 INSERT INTO ft VALUES('a b c d e');
129 135
130 -- The following SELECT statement returns these three rows: 136 -- The following SELECT statement returns these three rows:
131 -- '[a b c] x [c d e]' 137 -- '[a b c] x [c d e]'
132 -- '[a b c] [c d e]' 138 -- '[a b c] [c d e]'
133 -- '[a b c d e]' 139 -- '[a b c d e]'
134 SELECT highlight(ft, 0, '[', ']') FROM ft WHERE ft MATCH 'a+b+c AND c+d+e'; 140 SELECT highlight(ft, 0, '[', ']') FROM ft WHERE ft MATCH 'a+b+c AND c+d+e';
135 } { 141 } {
136 {[a b c] x [c d e]} 142 {[a b c] x [c d e]}
137 {[a b c] [c d e]} 143 {[a b c] [c d e]}
138 {[a b c d e]} 144 {[a b c d e]}
139 } 145 }
140 146
147 }
141 148
142 finish_test 149 finish_test
143 150
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/fts5/test/fts5ai.test ('k') | third_party/sqlite/src/ext/fts5/test/fts5al.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698