summaryrefslogtreecommitdiff
path: root/test/spellfix.test
diff options
context:
space:
mode:
authorHans-Christoph Steiner <hans@eds.org>2013-08-13 15:43:01 -0400
committerHans-Christoph Steiner <hans@eds.org>2013-08-13 15:43:01 -0400
commit4228998fd796fa2f9e84fb73632e0a07cc7cd188 (patch)
tree15b2336f351468fedd0c39e9de4ad905a686f3b0 /test/spellfix.test
parentbdee7cf7d974b2f70d5934786c5666006e7360be (diff)
parent08119c361d1181b3e8f1abb429236e488a664753 (diff)
Merge tag 'upstream/2.2.1'
Upstream version 2.2.1 # gpg: Signature made Tue 13 Aug 2013 03:42:56 PM EDT using RSA key ID 374BBE81 # gpg: Good signature from "Hans-Christoph Steiner <hans@at.or.at>" # gpg: aka "[jpeg image of size 5408]" # gpg: aka "Hans-Christoph Steiner <hs420@nyu.edu>" # gpg: aka "Hans-Christoph Steiner <hans@eds.org>" # gpg: aka "Hans-Christoph Steiner <hans@guardianproject.info>" # gpg: aka "Hans-Christoph Steiner <hansi@nyu.edu>" # gpg: aka "Hans-Christoph Steiner <hans@guardianproject.info>"
Diffstat (limited to 'test/spellfix.test')
-rw-r--r--test/spellfix.test64
1 files changed, 60 insertions, 4 deletions
diff --git a/test/spellfix.test b/test/spellfix.test
index afef981..dfa487a 100644
--- a/test/spellfix.test
+++ b/test/spellfix.test
@@ -16,7 +16,7 @@ set testprefix spellfix
ifcapable !vtab { finish_test ; return }
-register_spellfix_module db
+load_static_extension db spellfix nextchar
set vocab {
rabbi rabbit rabbits rabble rabid rabies raccoon raccoons race raced racer
@@ -84,6 +84,26 @@ foreach {tn word res} {
} $res
}
+# Tests of the next_char function.
+#
+do_test 1.10 {
+ db eval {
+ CREATE TABLE vocab(w TEXT PRIMARY KEY);
+ INSERT INTO vocab SELECT word FROM t1;
+ }
+} {}
+do_execsql_test 1.11 {
+ SELECT next_char('re','vocab','w');
+} {a}
+do_execsql_test 1.12 {
+ SELECT next_char('r','vocab','w');
+} {ae}
+do_execsql_test 1.13 {
+ SELECT next_char('','vocab','w');
+} {r}
+do_test 1.14 {
+ catchsql {SELECT next_char('','xyzzy','a')}
+} {1 {no such table: xyzzy}}
do_execsql_test 2.1 {
CREATE VIRTUAL TABLE t2 USING spellfix1;
@@ -136,16 +156,52 @@ do_test 3.2 {
}
} {}
-breakpoint
foreach {tn word res} {
1 kos* {kosher 3 kiosk 4 kudo 2 kiss 3 kissed 3}
2 kellj* {killjoy 5 kill 4 killed 4 killer 4 killers 4}
3 kellj {kill 4 kills 5 killjoy 7 keel 4 killed 6}
} {
- do_execsql_test 1.2.$tn {
+ do_execsql_test 3.2.$tn {
SELECT word, matchlen FROM t3 WHERE word MATCH $word
ORDER BY score, word LIMIT 5
} $res
-}
+}
+
+do_execsql_test 4.0 {
+ INSERT INTO t3(command) VALUES('edit_cost_table=NULL');
+}
+foreach {tn word res} {
+ 1 kosher {kosher 0 kisser 51 kissers 76 kissed 126 kisses 126}
+ 2 kellj {keels 60 killjoy 68 kills 80 keel 120 kill 125}
+ 3 kashar {kosher 80 kisser 91 kissers 116 kissed 166 kisses 166}
+} {
+ do_execsql_test 4.1.$tn {
+ SELECT word, distance FROM t3 WHERE word MATCH $word
+ ORDER BY score, word LIMIT 5
+ } $res
+}
+do_execsql_test 5.0 {
+ CREATE TABLE costs2(iLang, cFrom, cTo, iCost);
+ INSERT INTO costs2 VALUES(0, 'a', 'o', 1);
+ INSERT INTO costs2 VALUES(0, 'e', 'o', 4);
+ INSERT INTO costs2 VALUES(0, 'i', 'o', 8);
+ INSERT INTO costs2 VALUES(0, 'u', 'o', 16);
+ INSERT INTO t3(command) VALUES('edit_cost_table="costs2"');
+}
+
+foreach {tn word res} {
+ 1 kasher {kosher 1}
+ 2 kesher {kosher 4}
+ 3 kisher {kosher 8}
+ 4 kosher {kosher 0}
+ 5 kusher {kosher 16}
+} {
+ do_execsql_test 5.1.$tn {
+ SELECT word, distance FROM t3 WHERE word MATCH $word
+ ORDER BY score, word LIMIT 1
+ } $res
+}
+
+
finish_test