sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / ext / fts5 / test / fts5fuzz1.test
| 1 | # 2014 June 17 |
| 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 | # This file implements regression tests for SQLite library. The |
| 12 | # focus of this script is testing the FTS5 module. |
| 13 | # |
| 14 | |
| 15 | source [file join [file dirname [info script]] fts5_common.tcl] |
| 16 | return_if_no_fts5 |
| 17 | set testprefix fts5fuzz1 |
| 18 | |
| 19 | |
| 20 | #------------------------------------------------------------------------- |
| 21 | reset_db |
| 22 | do_catchsql_test 1.1 { |
| 23 | CREATE VIRTUAL TABLE f1 USING fts5(a b); |
| 24 | } {/1 {parse error in.*}/} |
| 25 | |
| 26 | |
| 27 | #------------------------------------------------------------------------- |
| 28 | reset_db |
| 29 | do_execsql_test 2.1 { |
| 30 | CREATE VIRTUAL TABLE f1 USING fts5(a, b); |
| 31 | INSERT INTO f1 VALUES('a b', 'c d'); |
| 32 | INSERT INTO f1 VALUES('e f', 'a b'); |
| 33 | } |
| 34 | |
| 35 | do_execsql_test 2.2.1 { |
| 36 | SELECT rowid FROM f1('""'); |
| 37 | } {} |
| 38 | |
| 39 | do_execsql_test 2.2.2 { |
| 40 | SELECT rowid FROM f1('"" AND a'); |
| 41 | } {} |
| 42 | |
| 43 | |
| 44 | do_execsql_test 2.2.3 { |
| 45 | SELECT rowid FROM f1('"" a'); |
| 46 | } {1 2} |
| 47 | |
| 48 | do_execsql_test 2.2.4 { |
| 49 | SELECT rowid FROM f1('"" OR a'); |
| 50 | } {1 2} |
| 51 | |
| 52 | do_execsql_test 2.3 { |
| 53 | SELECT a, b FROM f1('NEAR("")'); |
| 54 | } {} |
| 55 | |
| 56 | do_execsql_test 2.4 { |
| 57 | SELECT a, b FROM f1('NEAR("", 5)'); |
| 58 | } {} |
| 59 | |
| 60 | do_execsql_test 2.5 { |
| 61 | SELECT a, b FROM f1('NEAR("" c, 5)'); |
| 62 | } {{a b} {c d}} |
| 63 | |
| 64 | do_execsql_test 2.6 { |
| 65 | SELECT a, b FROM f1('NEAR("" c d, 5)'); |
| 66 | } {{a b} {c d}} |
| 67 | |
| 68 | do_execsql_test 2.7 { |
| 69 | SELECT a, b FROM f1('NEAR(c d, 5)'); |
| 70 | } {{a b} {c d}} |
| 71 | |
| 72 | do_execsql_test 2.8 { |
| 73 | SELECT rowid FROM f1('NEAR("a" "b", 5)'); |
| 74 | } {1 2} |
| 75 | |
| 76 | #------------------------------------------------------------------------- |
| 77 | reset_db |
| 78 | do_execsql_test 3.2 { |
| 79 | CREATE VIRTUAL TABLE f2 USING fts5(o, t, tokenize="ascii separators abc"); |
| 80 | SELECT * FROM f2('a+4'); |
| 81 | } {} |
| 82 | |
| 83 | |
| 84 | |
| 85 | #------------------------------------------------------------------------- |
| 86 | reset_db |
| 87 | do_catchsql_test 4.1 { |
| 88 | CREATE VIRTUAL TABLE f2 USING fts5(o, t); |
| 89 | SELECT * FROM f2('(8 AND 9)`AND 10'); |
| 90 | } {1 {fts5: syntax error near "`"}} |
| 91 | |
| 92 | finish_test |