dan | b023b04 | 2010-01-06 17:19:21 +0000 | [diff] [blame^] | 1 | |
| 2 | set testdir [file dirname $argv0] |
| 3 | source $testdir/tester.tcl |
| 4 | |
| 5 | # If SQLITE_ENABLE_FTS3 is defined, omit this file. |
| 6 | ifcapable !fts3 { finish_test ; return } |
| 7 | |
| 8 | do_test fts3snippet-1.1 { |
| 9 | execsql { |
| 10 | CREATE VIRTUAL TABLE ft USING fts3; |
| 11 | INSERT INTO ft VALUES('xxx xxx xxx xxx'); |
| 12 | } |
| 13 | } {} |
| 14 | |
| 15 | proc normalize {L} { |
| 16 | set ret [list] |
| 17 | foreach l $L {lappend ret $l} |
| 18 | return $ret |
| 19 | } |
| 20 | |
| 21 | do_test fts3snippet-1.2 { |
| 22 | execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH 'xxx' } |
| 23 | } {{0 0 0 3 0 0 4 3 0 0 8 3 0 0 12 3}} |
| 24 | |
| 25 | do_test fts3snippet-1.3 { |
| 26 | execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH '"xxx xxx"' } |
| 27 | } [list [normalize { |
| 28 | 0 0 0 3 |
| 29 | 0 0 4 3 |
| 30 | 0 1 4 3 |
| 31 | 0 0 8 3 |
| 32 | 0 1 8 3 |
| 33 | 0 1 12 3 |
| 34 | }]] |
| 35 | |
| 36 | |
| 37 | do_test fts3snippet-1.4 { |
| 38 | execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH '"xxx xxx" xxx' } |
| 39 | } [list [normalize { |
| 40 | 0 0 0 3 |
| 41 | 0 2 0 3 |
| 42 | 0 0 4 3 |
| 43 | 0 1 4 3 |
| 44 | 0 2 4 3 |
| 45 | 0 0 8 3 |
| 46 | 0 1 8 3 |
| 47 | 0 2 8 3 |
| 48 | 0 1 12 3 |
| 49 | 0 2 12 3 |
| 50 | }]] |
| 51 | |
| 52 | do_test fts3snippet-1.5 { |
| 53 | execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH 'xxx "xxx xxx"' } |
| 54 | } [list [normalize { |
| 55 | 0 0 0 3 |
| 56 | 0 1 0 3 |
| 57 | 0 0 4 3 |
| 58 | 0 1 4 3 |
| 59 | 0 2 4 3 |
| 60 | 0 0 8 3 |
| 61 | 0 1 8 3 |
| 62 | 0 2 8 3 |
| 63 | 0 0 12 3 |
| 64 | 0 2 12 3 |
| 65 | }]] |
| 66 | |
| 67 | finish_test |
| 68 | |