fts3ag.test 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # 2006 October 19
  2. #
  3. # The author disclaims copyright to this source code.
  4. #
  5. #*************************************************************************
  6. # This file implements regression tests for SQLite library. The focus
  7. # of this script is testing handling of edge cases for various doclist
  8. # merging functions in the FTS3 module query logic.
  9. #
  10. # $Id: fts3ag.test,v 1.2 2007/11/16 00:23:08 shess Exp $
  11. #
  12. set testdir [file dirname $argv0]
  13. source $testdir/tester.tcl
  14. # If SQLITE_ENABLE_FTS3 is defined, omit this file.
  15. ifcapable !fts3 {
  16. finish_test
  17. return
  18. }
  19. db eval {
  20. CREATE VIRTUAL TABLE t1 USING fts3(content);
  21. INSERT INTO t1 (rowid, content) VALUES(1, 'this is a test');
  22. INSERT INTO t1 (rowid, content) VALUES(2, 'also a test');
  23. }
  24. # No hits at all. Returns empty doclists from termSelect().
  25. do_test fts3ag-1.1 {
  26. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
  27. } {}
  28. # Empty left in docListExceptMerge().
  29. do_test fts3ag-1.2 {
  30. execsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this something'}
  31. } {}
  32. # Empty right in docListExceptMerge().
  33. do_test fts3ag-1.3 {
  34. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this -something'}
  35. } {1}
  36. # Empty left in docListPhraseMerge().
  37. do_test fts3ag-1.4 {
  38. execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"this something"'}
  39. } {}
  40. # Empty right in docListPhraseMerge().
  41. do_test fts3ag-1.5 {
  42. execsql {SELECT rowid FROM t1 WHERE t1 MATCH '"something is"'}
  43. } {}
  44. # Empty left in docListOrMerge().
  45. do_test fts3ag-1.6 {
  46. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR this'}
  47. } {1}
  48. # Empty right in docListOrMerge().
  49. do_test fts3ag-1.7 {
  50. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR something'}
  51. } {1}
  52. # Empty left in docListAndMerge().
  53. do_test fts3ag-1.8 {
  54. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something this'}
  55. } {}
  56. # Empty right in docListAndMerge().
  57. do_test fts3ag-1.9 {
  58. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this something'}
  59. } {}
  60. # No support for all-except queries.
  61. do_test fts3ag-1.10 {
  62. catchsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this -something'}
  63. } {1 {malformed MATCH expression: [-this -something]}}
  64. # Test that docListOrMerge() correctly handles reaching the end of one
  65. # doclist before it reaches the end of the other.
  66. do_test fts3ag-1.11 {
  67. breakpoint
  68. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR also'}
  69. } {1 2}
  70. do_test fts3ag-1.12 {
  71. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'also OR this'}
  72. } {1 2}
  73. # Empty left and right in docListOrMerge(). Each term matches neither
  74. # row, and when combined there was an assertion failure.
  75. do_test fts3ag-1.13 {
  76. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR nothing'}
  77. } {}
  78. finish_test