PageRenderTime 53ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/src/sqlite/test/fts2h.test

#
Unknown | 76 lines | 63 code | 13 blank | 0 comment | 0 complexity | 5c2fd0838245b8cc5cc197748907f1e8 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. # 2006 October 31 (scaaarey)
  2. #
  3. # The author disclaims copyright to this source code.
  4. #
  5. #*************************************************************************
  6. # This file implements regression tests for SQLite library. The focus
  7. # here is testing correct handling of excessively long terms.
  8. #
  9. # $Id: fts2h.test,v 1.1 2006/11/29 21:03:01 shess Exp $
  10. #
  11. set testdir [file dirname $argv0]
  12. source $testdir/tester.tcl
  13. # If SQLITE_ENABLE_FTS2 is defined, omit this file.
  14. ifcapable !fts2 {
  15. finish_test
  16. return
  17. }
  18. # Generate a term of len copies of char.
  19. proc bigterm {char len} {
  20. for {set term ""} {$len>0} {incr len -1} {
  21. append term $char
  22. }
  23. return $term
  24. }
  25. # Generate a document of bigterms based on characters from the list
  26. # chars.
  27. proc bigtermdoc {chars len} {
  28. set doc ""
  29. foreach char $chars {
  30. append doc " " [bigterm $char $len]
  31. }
  32. return $doc
  33. }
  34. set len 5000
  35. set doc1 [bigtermdoc {a b c d} $len]
  36. set doc2 [bigtermdoc {b d e f} $len]
  37. set doc3 [bigtermdoc {a c e} $len]
  38. set aterm [bigterm a $len]
  39. set bterm [bigterm b $len]
  40. set xterm [bigterm x $len]
  41. db eval {
  42. CREATE VIRTUAL TABLE t1 USING fts2(content);
  43. INSERT INTO t1 (rowid, content) VALUES(1, $doc1);
  44. INSERT INTO t1 (rowid, content) VALUES(2, $doc2);
  45. INSERT INTO t1 (rowid, content) VALUES(3, $doc3);
  46. }
  47. # No hits at all. Returns empty doclists from termSelect().
  48. do_test fts2h-1.1 {
  49. execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}
  50. } {}
  51. do_test fts2h-1.2 {
  52. execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm}
  53. } {1 3}
  54. do_test fts2h-1.2 {
  55. execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm}
  56. } {}
  57. do_test fts2h-1.3 {
  58. execsql "SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'"
  59. } {1 3}
  60. do_test fts2h-1.4 {
  61. execsql "SELECT rowid FROM t1 WHERE t1 MATCH '\"$aterm $bterm\"'"
  62. } {1}
  63. finish_test