fts5bigtok.test 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # 2016 Jan 19
  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
  12. # focus of this script is testing the FTS5 module.
  13. #
  14. source [file join [file dirname [info script]] fts5_common.tcl]
  15. set testprefix fts5bigtok
  16. return_if_no_fts5
  17. proc rndterm {} {
  18. set L [list 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]
  19. set l [lindex $L [expr int(rand() * [llength $L])]]
  20. string repeat $l [expr int(rand() * 5) + 60]
  21. }
  22. proc rnddoc {n} {
  23. set res [list]
  24. for {set i 0} {$i < $n} {incr i} {
  25. lappend res [rndterm]
  26. }
  27. set res
  28. }
  29. foreach_detail_mode $::testprefix {
  30. db func rnddoc rnddoc
  31. do_execsql_test 1.0 {
  32. CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);
  33. INSERT INTO t1(t1, rank) VALUES('pgsz', 32);
  34. CREATE VIRTUAL TABLE t1vocab USING fts5vocab(t1, row);
  35. WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10 )
  36. INSERT INTO t1 SELECT rnddoc(3) FROM s;
  37. WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10 )
  38. INSERT INTO t1 SELECT rnddoc(3) FROM s;
  39. }
  40. foreach v [db eval {SELECT term FROM t1vocab}] {
  41. set res [db eval {SELECT rowid FROM t1($v)}]
  42. do_execsql_test 1.[string range $v 0 0] {
  43. SELECT rowid FROM t1($v) ORDER BY rowid DESC
  44. } [lsort -integer -decr $res]
  45. }
  46. do_execsql_test 2.0 {
  47. INSERT INTO t1(t1) VALUES('optimize');
  48. }
  49. foreach v [db eval {SELECT term FROM t1vocab}] {
  50. set res [db eval {SELECT rowid FROM t1($v)}]
  51. do_execsql_test 2.[string range $v 0 0] {
  52. SELECT rowid FROM t1($v) ORDER BY rowid DESC
  53. } [lsort -integer -decr $res]
  54. }
  55. }
  56. finish_test