From: dan Date: Mon, 30 Nov 2009 08:55:03 +0000 (+0000) Subject: Add test cases for examples recently added to documentation file fts3.html. X-Git-Tag: version-3.7.2~780 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63b94d64c33a769fc2f29b895e6517cc213ab94e;p=thirdparty%2Fsqlite.git Add test cases for examples recently added to documentation file fts3.html. FossilOrigin-Name: 498922cc356316a3ec59320529b685728e407746 --- diff --git a/manifest b/manifest index 909d7cf25f..383980841b 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Updates\sto\ssnippet()\sand\soffsets()\sfunctions\sof\sFTS3\sso\sthat\sthey\swork\nsanely\sfollowing\san\sOOM\sfault. -D 2009-11-28T21:33:21 +C Add\stest\scases\sfor\sexamples\srecently\sadded\sto\sdocumentation\sfile\sfts3.html. +D 2009-11-30T08:55:04 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -329,7 +326,7 @@ F test/descidx3.test 3394ad4d089335cac743c36a14129d6d931c316f F test/diskfull.test 0cede7ef9d8f415d9d3944005c76be7589bb5ebb F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376 F test/e_fkey.test fd1fcf89badd5f2773d7ac04775b5ff3488eda17 -F test/e_fts3.test 488055f7c223e289ea341d55a7e1dd5281893b93 +F test/e_fts3.test 24bb398086eca6d8d3dab64d383d5bb2dd4ff681 F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398 F test/enc3.test 5c550d59ff31dccdba5d1a02ae11c7047d77c041 @@ -380,7 +377,7 @@ F test/fts2q.test b2fbbe038b7a31a52a6079b215e71226d8c6a682 F test/fts2r.test b154c30b63061d8725e320fba1a39e2201cadd5e F test/fts2token.test d8070b241a15ff13592a9ae4a8b7c171af6f445a F test/fts3.test f4f380d3717493605270dfa3b0fa893ea0afb18d -F test/fts3_common.tcl cdc89bb78754d54b19d8a5dfabd14575742a5293 +F test/fts3_common.tcl 31935839b1b601a5955572cb4e8060513c96bde0 F test/fts3aa.test 5327d4c1d9b6c61021696746cc9a6cdc5bf159c0 F test/fts3ab.test 09aeaa162aee6513d9ff336b6932211008b9d1f9 F test/fts3ac.test 356280144a2c92aa7b11474afadfe62a437fcd69 @@ -778,14 +775,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 31eed4f8f95f0799d634eccbd9e09cb58172d250 -R 63b6d1158b26a83c6b254a0d208f841c -U drh -Z 8559238aab4fefe4430f422ac07d6956 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFLEZckoxKgR168RlERAilJAJ9fOhH9A66qH4Y5YOtTa1Ji3y2FSACcC046 -fNgY4pufsjXCsUyJbj/lIyo= -=K2mf ------END PGP SIGNATURE----- +P b939a37a8ce296785a300e79ab9d3d87ad91343f +R 07bf5d7ea8efdfde49b03310dbe8e9d5 +U dan +Z 5540823be73c9695614535782a706576 diff --git a/manifest.uuid b/manifest.uuid index 689f72bae2..f97326b155 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b939a37a8ce296785a300e79ab9d3d87ad91343f \ No newline at end of file +498922cc356316a3ec59320529b685728e407746 \ No newline at end of file diff --git a/test/e_fts3.test b/test/e_fts3.test index be67ebb356..0c23d225bb 100644 --- a/test/e_fts3.test +++ b/test/e_fts3.test @@ -104,5 +104,64 @@ ddl_test 1.7.3 {DROP TABLE data} ########################################################################## +########################################################################## +# Test the example in section 5 (custom tokenizers). +# +ddl_test 2.1.1 { CREATE VIRTUAL TABLE simple USING fts3(tokenize=simple) } +write_test 2.1.2 simple_content { + INSERT INTO simple VALUES('Right now they''re very frustrated') +} +read_test 2.1.3 {SELECT docid FROM simple WHERE simple MATCH 'Frustrated'} {1} +read_test 2.1.4 {SELECT docid FROM simple WHERE simple MATCH 'Frustration'} {} + +ddl_test 2.2.1 { CREATE VIRTUAL TABLE porter USING fts3(tokenize=porter) } +write_test 2.2.2 porter_content { + INSERT INTO porter VALUES('Right now they''re very frustrated') +} +read_test 2.2.3 {SELECT docid FROM porter WHERE porter MATCH 'Frustrated'} {1} +read_test 2.2.4 {SELECT docid FROM porter WHERE porter MATCH 'Frustration'} {1} + +########################################################################## +# Test the examples in section 4 (auxillary functions). +# +ddl_test 3.1.1 { CREATE VIRTUAL TABLE mail USING fts3(subject, body) } + +write_test 3.1.2 mail_content { + INSERT INTO mail VALUES( + 'hello world', 'This message is a hello world message.'); +} +write_test 3.1.3 mail_content { + INSERT INTO mail VALUES( + 'urgent: serious', 'This mail is seen as a more serious mail'); } + +read_test 3.1.4 { + SELECT offsets(mail) FROM mail WHERE mail MATCH 'world'; +} {{0 0 6 5 1 0 24 5}} +read_test 3.1.5 { + SELECT offsets(mail) FROM mail WHERE mail MATCH 'message' +} {{1 0 5 7 1 0 30 7}} +read_test 3.1.6 { + SELECT offsets(mail) FROM mail WHERE mail MATCH '"serious mail"' +} {{1 0 28 7 1 1 36 4}} + +ddl_test 3.2.1 { CREATE VIRTUAL TABLE text USING fts3() } + +write_test 3.2.2 text_content { + INSERT INTO text VALUES(' + During 30 Nov-1 Dec, 2-3oC drops. Cool in the upper portion, minimum temperature 14-16oC and cool elsewhere, minimum temperature 17-20oC. Cold to very cold on mountaintops, minimum temperature 6-12oC. Northeasterly winds 15-30 km/hr. After that, temperature increases. Northeasterly winds 15-30 km/hr. + '); +} + +read_test 3.2.3 { + SELECT snippet(text) FROM text WHERE text MATCH 'cold' +} {{... elsewhere, minimum temperature 17-20oC. Cold to very cold on mountaintops, minimum ...}} + +read_test 3.2.4 { + SELECT snippet(text, '[', ']', '...') FROM text WHERE text MATCH '"min* tem*"' +} {{... 2-3oC drops. Cool in the upper portion, [minimum] [temperature] 14-16oC and cool elsewhere, [minimum] ...}} + +#break +} + finish_test diff --git a/test/fts3_common.tcl b/test/fts3_common.tcl index a6de4ab26f..f954f5c32b 100644 --- a/test/fts3_common.tcl +++ b/test/fts3_common.tcl @@ -334,7 +334,7 @@ proc doPassiveTest {name sql catchres} { if {$::DO_MALLOC_TEST} {sqlite3_memdebug_fail $iFail -repeat $nRepeat} set res [catchsql $sql] - if {[lsearch $answers $res]>=0} { + if {[lsearch -exact $answers $res]>=0} { set res $str } do_test $name.$zName.$iFail [list set {} $res] $str