fts5aux2.test 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # 2024 June 24
  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. #
  12. # Tests focusing on the auxiliary function APIs.
  13. #
  14. source [file join [file dirname [info script]] fts5_common.tcl]
  15. set testprefix fts5aux
  16. # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
  17. ifcapable !fts5 {
  18. finish_test
  19. return
  20. }
  21. do_execsql_test 1.0 {
  22. CREATE VIRTUAL TABLE x1 USING fts5(a, b);
  23. INSERT INTO x1 VALUES('a b', 'c d');
  24. INSERT INTO x1 VALUES('d e', 'a b');
  25. INSERT INTO x1 VALUES('a b', 'e f');
  26. INSERT INTO x1 VALUES('d e', 'c d');
  27. }
  28. fts5_aux_test_functions db
  29. do_execsql_test 1.1 {
  30. SELECT fts5_test_all(x1) FROM x1 WHERE rowid=2
  31. } [list [list {*}{
  32. columnsize {2 2}
  33. columntext {{d e} {a b}}
  34. columntotalsize {8 8}
  35. poslist {}
  36. tokenize {{d e} {a b}}
  37. rowcount 4
  38. }]]
  39. do_execsql_test 1.2 {
  40. SELECT fts5_test_columntext(x1) FROM x1
  41. } {
  42. {{a b} {c d}}
  43. {{d e} {a b}}
  44. {{a b} {e f}}
  45. {{d e} {c d}}
  46. }
  47. do_execsql_test 1.3 {
  48. SELECT fts5_test_rowid(x1) FROM x1
  49. } {
  50. 1 2 3 4
  51. }
  52. do_execsql_test 1.4 {
  53. SELECT fts5_test_phrasecount(x1) FROM x1
  54. } {
  55. 0 0 0 0
  56. }
  57. do_catchsql_test 1.5 {
  58. SELECT fts5_queryphrase(x1, 0) FROM x1
  59. } {1 SQLITE_RANGE}
  60. do_execsql_test 1.6 {
  61. SELECT fts5_test_rowcount(x1) FROM x1
  62. } {4 4 4 4}
  63. finish_test