fts3ad.test 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # 2006 October 1
  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 FTS3 module, and in particular
  13. # the Porter stemmer.
  14. #
  15. # $Id: fts3ad.test,v 1.1 2007/08/20 17:38:42 shess Exp $
  16. #
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. # If SQLITE_ENABLE_FTS3 is defined, omit this file.
  20. ifcapable !fts3 {
  21. finish_test
  22. return
  23. }
  24. do_test fts3ad-1.1 {
  25. execsql {
  26. CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize porter);
  27. INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
  28. SELECT rowid FROM t1 WHERE content MATCH 'run jump';
  29. }
  30. } {1}
  31. do_test fts3ad-1.2 {
  32. execsql {
  33. SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'run jump';
  34. }
  35. } {{<b>running</b> and <b>jumping</b>}}
  36. do_test fts3ad-1.3 {
  37. execsql {
  38. INSERT INTO t1(rowid, content)
  39. VALUES(2, 'abcdefghijklmnopqrstuvwyxz');
  40. SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijqrstuvwyxz'
  41. }
  42. } {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
  43. do_test fts3ad-1.4 {
  44. execsql {
  45. SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijXXXXqrstuvwyxz'
  46. }
  47. } {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
  48. do_test fts3ad-1.5 {
  49. execsql {
  50. INSERT INTO t1(rowid, content)
  51. VALUES(3, 'The value is 123456789');
  52. SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123789'
  53. }
  54. } {3 {The value is <b>123456789</b>}}
  55. do_test fts3ad-1.6 {
  56. execsql {
  57. SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123000000789'
  58. }
  59. } {3 {The value is <b>123456789</b>}}
  60. do_test fts3ad-2.1 {
  61. execsql {
  62. DROP TABLE t1;
  63. CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize porter);
  64. INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
  65. SELECT rowid FROM t1 WHERE content MATCH 'run jump';
  66. }
  67. } {1}
  68. do_test fts3ad-2.2 {
  69. execsql {
  70. DROP TABLE t1;
  71. CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize= porter);
  72. INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
  73. SELECT rowid FROM t1 WHERE content MATCH 'run jump';
  74. }
  75. } {1}
  76. do_test fts3ad-2.3 {
  77. execsql {
  78. DROP TABLE t1;
  79. CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize= simple);
  80. INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
  81. SELECT rowid FROM t1 WHERE content MATCH 'run jump';
  82. }
  83. } {}
  84. do_test fts3ad-2.4 {
  85. execsql {
  86. DROP TABLE t1;
  87. CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize= porter);
  88. INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
  89. SELECT rowid FROM t1 WHERE content MATCH 'run jump';
  90. }
  91. } {1}
  92. do_test fts3ad-2.5 {
  93. execsql {
  94. DROP TABLE t1;
  95. CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize = porter);
  96. INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');
  97. SELECT rowid FROM t1 WHERE content MATCH 'run jump';
  98. }
  99. } {1}
  100. finish_test