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 / test / spellfix2.test
| 1 | # 2012 July 12 |
| 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 | |
| 13 | set testdir [file dirname $argv0] |
| 14 | source $testdir/tester.tcl |
| 15 | set testprefix spellfix2 |
| 16 | |
| 17 | ifcapable !vtab { finish_test ; return } |
| 18 | load_static_extension db spellfix nextchar |
| 19 | |
| 20 | do_execsql_test 1.0 { |
| 21 | CREATE VIRTUAL TABLE demo USING spellfix1; |
| 22 | INSERT INTO demo(word) VALUES ('amsterdam'); |
| 23 | INSERT INTO demo(word) VALUES ('amsterdammetje'); |
| 24 | INSERT INTO demo(word) VALUES ('amsterdamania'); |
| 25 | INSERT INTO demo(word) VALUES ('amsterdamweg'); |
| 26 | INSERT INTO demo(word) VALUES ('amsterdamsestraat'); |
| 27 | INSERT INTO demo(word) VALUES ('amsterdamlaan'); |
| 28 | } |
| 29 | |
| 30 | do_execsql_test 1.1 { |
| 31 | SELECT word, distance, matchlen FROM demo |
| 32 | WHERE word MATCH 'amstedam*' AND top=3 |
| 33 | ORDER BY +word; |
| 34 | } { |
| 35 | amsterdam 100 9 |
| 36 | amsterdamania 100 9 |
| 37 | amsterdammetje 100 9 |
| 38 | } |
| 39 | do_execsql_test 1.1b { |
| 40 | SELECT count(*) FROM demo |
| 41 | WHERE word MATCH 'amstedam*' AND top=787410671 |
| 42 | ORDER BY +word; |
| 43 | } 6 |
| 44 | |
| 45 | do_execsql_test 1.2 { |
| 46 | SELECT word, distance, matchlen FROM demo WHERE |
| 47 | word MATCH 'amstedam*' AND top=3 AND distance <= 100 |
| 48 | ORDER BY +word; |
| 49 | } { |
| 50 | amsterdam 100 9 |
| 51 | amsterdamania 100 9 |
| 52 | amsterdammetje 100 9 |
| 53 | } |
| 54 | |
| 55 | do_execsql_test 1.3 { |
| 56 | SELECT word, distance, matchlen FROM demo WHERE |
| 57 | word MATCH 'amstedam*' AND distance <= 100 |
| 58 | ORDER BY +word; |
| 59 | } { |
| 60 | amsterdam 100 9 |
| 61 | amsterdamania 100 9 |
| 62 | amsterdamlaan 100 9 |
| 63 | amsterdammetje 100 9 |
| 64 | amsterdamsestraat 100 9 |
| 65 | amsterdamweg 100 9 |
| 66 | } |
| 67 | |
| 68 | do_test 1.4 { |
| 69 | foreach l {a b c d e f g h i j k l m n o p q r s t u v w x y z} { |
| 70 | execsql { INSERT INTO demo(word) VALUES ('amsterdam' || $l) } |
| 71 | } |
| 72 | } {} |
| 73 | |
| 74 | do_execsql_test 1.5 { |
| 75 | SELECT count(*) FROM demo WHERE word MATCH 'amstedam*' AND distance <= 100; |
| 76 | SELECT count(*) FROM demo |
| 77 | WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20; |
| 78 | } { |
| 79 | 32 20 |
| 80 | } |
| 81 | |
| 82 | do_execsql_test 1.6 { |
| 83 | SELECT word, distance, matchlen FROM demo |
| 84 | WHERE word MATCH 'amstedam*' AND distance <= 100 |
| 85 | ORDER BY distance, word; |
| 86 | } { |
| 87 | amsterdam 100 9 amsterdama 100 9 |
| 88 | amsterdamania 100 9 amsterdamb 100 9 |
| 89 | amsterdamc 100 9 amsterdamd 100 9 |
| 90 | amsterdame 100 9 amsterdamf 100 9 |
| 91 | amsterdamg 100 9 amsterdamh 100 9 |
| 92 | amsterdami 100 9 amsterdamj 100 9 |
| 93 | amsterdamk 100 9 amsterdaml 100 9 |
| 94 | amsterdamlaan 100 9 amsterdamm 100 9 |
| 95 | amsterdammetje 100 9 amsterdamn 100 9 |
| 96 | amsterdamo 100 9 amsterdamp 100 9 |
| 97 | amsterdamq 100 9 amsterdamr 100 9 |
| 98 | amsterdams 100 9 amsterdamsestraat 100 9 |
| 99 | amsterdamt 100 9 amsterdamu 100 9 |
| 100 | amsterdamv 100 9 amsterdamw 100 9 |
| 101 | amsterdamweg 100 9 amsterdamx 100 9 |
| 102 | amsterdamy 100 9 amsterdamz 100 9 |
| 103 | } |
| 104 | |
| 105 | do_execsql_test 1.7 { |
| 106 | SELECT word, distance, matchlen FROM demo |
| 107 | WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20 |
| 108 | ORDER BY distance, word; |
| 109 | } { |
| 110 | amsterdam 100 9 amsterdama 100 9 |
| 111 | amsterdamania 100 9 amsterdamb 100 9 |
| 112 | amsterdamc 100 9 amsterdame 100 9 |
| 113 | amsterdamf 100 9 amsterdamg 100 9 |
| 114 | amsterdamh 100 9 amsterdami 100 9 |
| 115 | amsterdamm 100 9 amsterdammetje 100 9 |
| 116 | amsterdamn 100 9 amsterdamo 100 9 |
| 117 | amsterdamp 100 9 amsterdamu 100 9 |
| 118 | amsterdamv 100 9 amsterdamw 100 9 |
| 119 | amsterdamweg 100 9 amsterdamy 100 9 |
| 120 | } |
| 121 | |
| 122 | |
| 123 | finish_test |