CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
spellfix2.test119 linesDownload Raw Back to test
1# 2012 July 122#3# The author disclaims copyright to this source code.  In place of4# 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 13set testdir [file dirname $argv0]14source $testdir/tester.tcl15set testprefix spellfix216 17ifcapable !vtab { finish_test ; return }18load_static_extension db spellfix nextchar19 20do_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 30do_execsql_test 1.1 {31  SELECT word, distance, matchlen FROM demo 32  WHERE word MATCH 'amstedam*' AND top=333  ORDER BY +word;34} {35   amsterdam      100 936   amsterdamania  100 937   amsterdammetje 100 938}39 40do_execsql_test 1.2 {41  SELECT word, distance, matchlen FROM demo WHERE 42  word MATCH 'amstedam*' AND top=3 AND distance <= 10043  ORDER BY +word;44} {45   amsterdam      100 946   amsterdamania  100 947   amsterdammetje 100 948}49 50do_execsql_test 1.3 {51  SELECT word, distance, matchlen FROM demo WHERE 52  word MATCH 'amstedam*' AND distance <= 10053  ORDER BY +word;54} {55   amsterdam         100 956   amsterdamania     100 957   amsterdamlaan     100 958   amsterdammetje    100 959   amsterdamsestraat 100 960   amsterdamweg      100 961}62 63do_test 1.4 {64  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} {65    execsql { INSERT INTO demo(word) VALUES ('amsterdam' || $l) }66  }67} {}68 69do_execsql_test 1.5 {70  SELECT count(*) FROM demo WHERE word MATCH 'amstedam*' AND distance <= 100;71  SELECT count(*) FROM demo 72  WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20;73} {74  32 2075}76 77do_execsql_test 1.6 {78  SELECT word, distance, matchlen FROM demo 79  WHERE word MATCH 'amstedam*' AND distance <= 10080  ORDER BY distance, word;81} {82  amsterdam         100 9        amsterdama        100 983  amsterdamania     100 9        amsterdamb        100 984  amsterdamc        100 9        amsterdamd        100 985  amsterdame        100 9        amsterdamf        100 986  amsterdamg        100 9        amsterdamh        100 987  amsterdami        100 9        amsterdamj        100 988  amsterdamk        100 9        amsterdaml        100 989  amsterdamlaan     100 9        amsterdamm        100 990  amsterdammetje    100 9        amsterdamn        100 991  amsterdamo        100 9        amsterdamp        100 992  amsterdamq        100 9        amsterdamr        100 993  amsterdams        100 9        amsterdamsestraat 100 994  amsterdamt        100 9        amsterdamu        100 995  amsterdamv        100 9        amsterdamw        100 996  amsterdamweg      100 9        amsterdamx        100 997  amsterdamy        100 9        amsterdamz        100 998}99 100do_execsql_test 1.7 {101  SELECT word, distance, matchlen FROM demo 102  WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20103  ORDER BY distance, word;104} {105  amsterdam         100 9        amsterdama        100 9106  amsterdamania     100 9        amsterdamb        100 9107  amsterdamc        100 9        amsterdame        100 9108  amsterdamf        100 9        amsterdamg        100 9109  amsterdamh        100 9        amsterdami        100 9110  amsterdamm        100 9        amsterdammetje    100 9111  amsterdamn        100 9        amsterdamo        100 9112  amsterdamp        100 9        amsterdamu        100 9113  amsterdamv        100 9        amsterdamw        100 9114  amsterdamweg      100 9        amsterdamy        100 9115}116 117 118finish_test119