1c1e63be3Sdan# 2012 July 12 2c1e63be3Sdan# 3c1e63be3Sdan# The author disclaims copyright to this source code. In place of 4c1e63be3Sdan# a legal notice, here is a blessing: 5c1e63be3Sdan# 6c1e63be3Sdan# May you do good and not evil. 7c1e63be3Sdan# May you find forgiveness for yourself and forgive others. 8c1e63be3Sdan# May you share freely, never taking more than you give. 9c1e63be3Sdan# 10c1e63be3Sdan#*********************************************************************** 11c1e63be3Sdan# 12c1e63be3Sdan 13c1e63be3Sdanset testdir [file dirname $argv0] 14c1e63be3Sdansource $testdir/tester.tcl 15c1e63be3Sdanset testprefix spellfix2 16c1e63be3Sdan 17c1e63be3Sdanifcapable !vtab { finish_test ; return } 18c1e63be3Sdanload_static_extension db spellfix nextchar 19c1e63be3Sdan 20c1e63be3Sdando_execsql_test 1.0 { 21c1e63be3Sdan CREATE VIRTUAL TABLE demo USING spellfix1; 22c1e63be3Sdan INSERT INTO demo(word) VALUES ('amsterdam'); 23c1e63be3Sdan INSERT INTO demo(word) VALUES ('amsterdammetje'); 24c1e63be3Sdan INSERT INTO demo(word) VALUES ('amsterdamania'); 25c1e63be3Sdan INSERT INTO demo(word) VALUES ('amsterdamweg'); 26c1e63be3Sdan INSERT INTO demo(word) VALUES ('amsterdamsestraat'); 27c1e63be3Sdan INSERT INTO demo(word) VALUES ('amsterdamlaan'); 28c1e63be3Sdan} 29c1e63be3Sdan 30c1e63be3Sdando_execsql_test 1.1 { 31c1e63be3Sdan SELECT word, distance, matchlen FROM demo 32e5c61f81Sdrh WHERE word MATCH 'amstedam*' AND top=3 33e5c61f81Sdrh ORDER BY +word; 34c1e63be3Sdan} { 35c1e63be3Sdan amsterdam 100 9 36c1e63be3Sdan amsterdamania 100 9 37e5c61f81Sdrh amsterdammetje 100 9 38c1e63be3Sdan} 39c1e63be3Sdan 40c1e63be3Sdando_execsql_test 1.2 { 41c1e63be3Sdan SELECT word, distance, matchlen FROM demo WHERE 42e5c61f81Sdrh word MATCH 'amstedam*' AND top=3 AND distance <= 100 43e5c61f81Sdrh ORDER BY +word; 44c1e63be3Sdan} { 45c1e63be3Sdan amsterdam 100 9 46c1e63be3Sdan amsterdamania 100 9 47e5c61f81Sdrh amsterdammetje 100 9 48c1e63be3Sdan} 49c1e63be3Sdan 50c1e63be3Sdando_execsql_test 1.3 { 51c1e63be3Sdan SELECT word, distance, matchlen FROM demo WHERE 52e5c61f81Sdrh word MATCH 'amstedam*' AND distance <= 100 53e5c61f81Sdrh ORDER BY +word; 54c1e63be3Sdan} { 55c1e63be3Sdan amsterdam 100 9 56c1e63be3Sdan amsterdamania 100 9 57c1e63be3Sdan amsterdamlaan 100 9 58e5c61f81Sdrh amsterdammetje 100 9 59e5c61f81Sdrh amsterdamsestraat 100 9 60e5c61f81Sdrh amsterdamweg 100 9 61c1e63be3Sdan} 62c1e63be3Sdan 63c1e63be3Sdando_test 1.4 { 64c1e63be3Sdan 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} { 65c1e63be3Sdan execsql { INSERT INTO demo(word) VALUES ('amsterdam' || $l) } 66c1e63be3Sdan } 67c1e63be3Sdan} {} 68c1e63be3Sdan 69c1e63be3Sdando_execsql_test 1.5 { 70c1e63be3Sdan SELECT count(*) FROM demo WHERE word MATCH 'amstedam*' AND distance <= 100; 71c1e63be3Sdan SELECT count(*) FROM demo 72c1e63be3Sdan WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20; 73c1e63be3Sdan} { 74c1e63be3Sdan 32 20 75c1e63be3Sdan} 76c1e63be3Sdan 77c1e63be3Sdando_execsql_test 1.6 { 78c1e63be3Sdan SELECT word, distance, matchlen FROM demo 79*1dcc97cdSdrh WHERE word MATCH 'amstedam*' AND distance <= 100 80*1dcc97cdSdrh ORDER BY distance, word; 81c1e63be3Sdan} { 82*1dcc97cdSdrh amsterdam 100 9 amsterdama 100 9 83*1dcc97cdSdrh amsterdamania 100 9 amsterdamb 100 9 84*1dcc97cdSdrh amsterdamc 100 9 amsterdamd 100 9 85*1dcc97cdSdrh amsterdame 100 9 amsterdamf 100 9 86*1dcc97cdSdrh amsterdamg 100 9 amsterdamh 100 9 87*1dcc97cdSdrh amsterdami 100 9 amsterdamj 100 9 88*1dcc97cdSdrh amsterdamk 100 9 amsterdaml 100 9 89*1dcc97cdSdrh amsterdamlaan 100 9 amsterdamm 100 9 90*1dcc97cdSdrh amsterdammetje 100 9 amsterdamn 100 9 91*1dcc97cdSdrh amsterdamo 100 9 amsterdamp 100 9 92*1dcc97cdSdrh amsterdamq 100 9 amsterdamr 100 9 93*1dcc97cdSdrh amsterdams 100 9 amsterdamsestraat 100 9 94*1dcc97cdSdrh amsterdamt 100 9 amsterdamu 100 9 95*1dcc97cdSdrh amsterdamv 100 9 amsterdamw 100 9 96*1dcc97cdSdrh amsterdamweg 100 9 amsterdamx 100 9 97*1dcc97cdSdrh amsterdamy 100 9 amsterdamz 100 9 98c1e63be3Sdan} 99c1e63be3Sdan 100c1e63be3Sdando_execsql_test 1.7 { 101c1e63be3Sdan SELECT word, distance, matchlen FROM demo 102*1dcc97cdSdrh WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20 103*1dcc97cdSdrh ORDER BY distance, word; 104c1e63be3Sdan} { 105*1dcc97cdSdrh amsterdam 100 9 amsterdama 100 9 106*1dcc97cdSdrh amsterdamania 100 9 amsterdamb 100 9 107*1dcc97cdSdrh amsterdamc 100 9 amsterdame 100 9 108*1dcc97cdSdrh amsterdamf 100 9 amsterdamg 100 9 109*1dcc97cdSdrh amsterdamh 100 9 amsterdami 100 9 110*1dcc97cdSdrh amsterdamm 100 9 amsterdammetje 100 9 111*1dcc97cdSdrh amsterdamn 100 9 amsterdamo 100 9 112*1dcc97cdSdrh amsterdamp 100 9 amsterdamu 100 9 113*1dcc97cdSdrh amsterdamv 100 9 amsterdamw 100 9 114*1dcc97cdSdrh amsterdamweg 100 9 amsterdamy 100 9 115c1e63be3Sdan} 116c1e63be3Sdan 117c1e63be3Sdan 118c1e63be3Sdanfinish_test 119