summaryrefslogtreecommitdiffstats
path: root/ext/fts5/test/fts5prefix2.test
blob: bf16e81a732fdfd1e6ecf241d0a6e3550e6203f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 2020 Dec 3
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains tests focused on prefix indexes.
#

source [file join [file dirname [info script]] fts5_common.tcl]
set testprefix fts5prefix2

# If SQLITE_ENABLE_FTS5 is defined, omit this file.
ifcapable !fts5 {
  finish_test
  return
}

foreach p {3 2 1} {
  reset_db
    do_execsql_test 1.$p.0 "
    CREATE VIRTUAL TABLE t1 USING fts5(xyz, prefix=$p);
  "
  do_execsql_test 1.$p.1 {
    INSERT INTO t1 VALUES
      ('May you do good and not evil.'),
      ('May you find forgiveness for yourself and forgive others.'),
      ('May you share freely, never taking more than you give f.');
  }

  do_execsql_test 1.$p.2 {
    SELECT highlight(t1, 0, '[', ']') FROM t1('f*');
  } {
    {May you [find] [forgiveness] [for] yourself and [forgive] others.}
    {May you share [freely], never taking more than you give [f].}
  }
}

do_execsql_test 2.0 {
  CREATE VIRTUAL TABLE t2 USING fts5(one, prefix=3);
  INSERT INTO t2 VALUES('top');
  INSERT INTO t2 VALUES('to');
  INSERT INTO t2 VALUES('tommy');
}

do_execsql_test 2.1 {
  SELECT * FROM t2('to*');
} {top to tommy}



finish_test