fts5determin.test 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # 2016 March 21
  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. # Specifically, that the fts5 module is deterministic. At one point, when
  15. # segment ids were allocated using sqlite3_randomness(), this was not the
  16. # case.
  17. #
  18. source [file join [file dirname [info script]] fts5_common.tcl]
  19. set testprefix fts5aa
  20. return_if_no_fts5
  21. proc do_determin_test {tn} {
  22. uplevel [list
  23. do_execsql_test $tn {
  24. SELECT (SELECT md5sum(id, block) FROM t1_data)==
  25. (SELECT md5sum(id, block) FROM t2_data),
  26. (SELECT md5sum(id, block) FROM t1_data)==
  27. (SELECT md5sum(id, block) FROM t3_data)
  28. } {1 1}
  29. ]
  30. }
  31. foreach_detail_mode $::testprefix {
  32. do_execsql_test 1.0 {
  33. CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix="1 2", detail=%DETAIL%);
  34. CREATE VIRTUAL TABLE t2 USING fts5(a, b, prefix="1 2", detail=%DETAIL%);
  35. CREATE VIRTUAL TABLE t3 USING fts5(a, b, prefix="1 2", detail=%DETAIL%);
  36. }
  37. do_test 1.1 {
  38. foreach t {t1 t2 t3} {
  39. execsql [string map [list TBL $t] {
  40. INSERT INTO TBL VALUES('a b c', 'd e f');
  41. INSERT INTO TBL VALUES('c1 c2 c3', 'c1 c2 c3');
  42. INSERT INTO TBL VALUES('xyzxyzxyz', 'xyzxyzxyz');
  43. }]
  44. }
  45. } {}
  46. do_determin_test 1.2
  47. do_test 1.3 {
  48. foreach t {t1 t2 t3} {
  49. execsql [string map [list TBL $t] {
  50. INSERT INTO TBL(TBL) VALUES('optimize');
  51. }]
  52. }
  53. } {}
  54. do_determin_test 1.4
  55. }
  56. finish_test