blob: 607b01e0f83bea856ad0d3243c536156d7bf7930 [file] [log] [blame]
drh043c8f62020-05-15 01:13:46 +00001# 2020-05-14
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# The tests in this file test the FTS3 auxillary functions offsets(),
13# snippet() and matchinfo() work. At time of writing, running this file
14# provides full coverage of fts3_snippet.c.
15#
16
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19set testprefix fts3snippet
20
21# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
22ifcapable !fts3 { finish_test ; return }
23source $testdir/fts3_common.tcl
24
25set sqlite_fts3_enable_parentheses 1
26#-------------------------------------------------------------------------
27# Request a snippet from a query with more than 64 phrases.
28#
29reset_db
30do_execsql_test 1.0 {
31 CREATE VIRTUAL TABLE f USING fts3(b);
32 INSERT INTO f VALUES ( x'746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218');
33}
34
35do_execsql_test 1.1 {
36 SELECT length(snippet(f))>0 FROM f WHERE b MATCH x'1065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a010f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c2a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e082a011065616e656d655a616c702a2f65732e0f42014001380230018218021001081e0a3d746e6e6d64612e0f42';
37} {1}
38
39reset_db
40do_execsql_test 2.0 {
41 CREATE VIRTUAL TABLE t0 USING fts3(col0 INTEGER PRIMARY KEY,col1 VARCHAR(8),col2 BINARY,col3 BINARY);
42 INSERT INTO t0 VALUES (1, '1234','aaaa','bbbb');
43 SELECT snippet(t0) FROM t0 WHERE t0 MATCH x'0a4d4d4d4d320a4f52d70a310a310a4e4541520a0a31f6ce0a4f520a0a310a310a310a4f520a75fc2a242424' ;
44} {<b>1</b>}
45
danbecd68b2020-05-16 17:26:58 +000046reset_db
47do_execsql_test 2.1 {
48 CREATE VIRTUAL TABLE t0 USING fts3(
49 col0 INTEGER PRIMARY KEY,col1 VARCHAR(8),col2 BINARY,col3 BINARY
50 );
51 INSERT INTO t0 VALUES ('one', '1234','aaaa','bbbb');
52}
53do_execsql_test 2.2 {
54 SELECT snippet(t0) FROM t0 WHERE t0 MATCH
55 '(def AND (one NEAR abc)) OR one'
56} {<b>one</b>}
57
drh043c8f62020-05-15 01:13:46 +000058set sqlite_fts3_enable_parentheses 0
59finish_test