fts3ah.test 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # 2006 October 31
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # 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. # This file implements regression tests for SQLite library. The focus
  12. # here is testing correct handling of very long terms.
  13. #
  14. set testdir [file dirname $argv0]
  15. source $testdir/tester.tcl
  16. # If SQLITE_ENABLE_FTS3 is not defined, omit this file.
  17. ifcapable !fts3 {
  18. finish_test
  19. return
  20. }
  21. # Generate a document of bigterms based on characters from the list
  22. # chars.
  23. proc bigtermdoc {chars len} {
  24. set doc ""
  25. foreach char $chars {
  26. append doc " " [string repeat $char $len]
  27. }
  28. return $doc
  29. }
  30. set len 5000
  31. set doc1 [bigtermdoc {a b c d} $len]
  32. set doc2 [bigtermdoc {b d e f} $len]
  33. set doc3 [bigtermdoc {a c e} $len]
  34. set aterm [string repeat a $len]
  35. set bterm [string repeat b $len]
  36. set xterm [string repeat x $len]
  37. db eval {
  38. CREATE VIRTUAL TABLE t1 USING fts3(content);
  39. INSERT INTO t1 (rowid, content) VALUES(1, $doc1);
  40. INSERT INTO t1 (rowid, content) VALUES(2, $doc2);
  41. INSERT INTO t1 (rowid, content) VALUES(3, $doc3);
  42. }
  43. # No hits at all. Returns empty doclists from termSelect().
  44. do_test fts3ah-1.1 {
  45. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
  46. } {}
  47. do_test fts3ah-1.2 {
  48. execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm}
  49. } {1 3}
  50. do_test fts3ah-1.3 {
  51. execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm}
  52. } {}
  53. do_test fts3ah-1.4 {
  54. execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'"
  55. } {1 3}
  56. do_test fts3ah-1.5 {
  57. execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'"
  58. } {1}
  59. finish_test