fts5fuzz1.test 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # 2014 June 17
  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. return_if_no_fts5
  16. set testprefix fts5fuzz1
  17. #-------------------------------------------------------------------------
  18. reset_db
  19. do_catchsql_test 1.1 {
  20. CREATE VIRTUAL TABLE f1 USING fts5(a b);
  21. } {/1 {parse error in.*}/}
  22. #-------------------------------------------------------------------------
  23. reset_db
  24. do_execsql_test 2.1 {
  25. CREATE VIRTUAL TABLE f1 USING fts5(a, b);
  26. INSERT INTO f1 VALUES('a b', 'c d');
  27. INSERT INTO f1 VALUES('e f', 'a b');
  28. }
  29. do_execsql_test 2.2.1 {
  30. SELECT rowid FROM f1('""');
  31. } {}
  32. do_execsql_test 2.2.2 {
  33. SELECT rowid FROM f1('"" AND a');
  34. } {}
  35. do_execsql_test 2.2.3 {
  36. SELECT rowid FROM f1('"" a');
  37. } {1 2}
  38. do_execsql_test 2.2.4 {
  39. SELECT rowid FROM f1('"" OR a');
  40. } {1 2}
  41. do_execsql_test 2.3 {
  42. SELECT a, b FROM f1('NEAR("")');
  43. } {}
  44. do_execsql_test 2.4 {
  45. SELECT a, b FROM f1('NEAR("", 5)');
  46. } {}
  47. do_execsql_test 2.5 {
  48. SELECT a, b FROM f1('NEAR("" c, 5)');
  49. } {{a b} {c d}}
  50. do_execsql_test 2.6 {
  51. SELECT a, b FROM f1('NEAR("" c d, 5)');
  52. } {{a b} {c d}}
  53. do_execsql_test 2.7 {
  54. SELECT a, b FROM f1('NEAR(c d, 5)');
  55. } {{a b} {c d}}
  56. do_execsql_test 2.8 {
  57. SELECT rowid FROM f1('NEAR("a" "b", 5)');
  58. } {1 2}
  59. #-------------------------------------------------------------------------
  60. reset_db
  61. do_execsql_test 3.2 {
  62. CREATE VIRTUAL TABLE f2 USING fts5(o, t, tokenize="ascii separators abc");
  63. SELECT * FROM f2('a+4');
  64. } {}
  65. #-------------------------------------------------------------------------
  66. reset_db
  67. do_catchsql_test 4.1 {
  68. CREATE VIRTUAL TABLE f2 USING fts5(o, t);
  69. SELECT * FROM f2('(8 AND 9)`AND 10');
  70. } {1 {fts5: syntax error near "`"}}
  71. finish_test