fts1d.test 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 FTS1 module, and in particular
  13. # the Porter stemmer.
  14. #
  15. # $Id: fts1d.test,v 1.1 2006/10/01 18:41:21 drh Exp $
  16. #
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. # If SQLITE_ENABLE_FTS1 is defined, omit this file.
  20. ifcapable !fts1 {
  21. finish_test
  22. return
  23. }
  24. do_test fts1d-1.1 {
  25. execsql {
  26. CREATE VIRTUAL TABLE t1 USING fts1(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 fts1d-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 fts1d-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 fts1d-1.4 {
  44. execsql {
  45. SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijXXXXqrstuvwyxz'
  46. }
  47. } {2 <b>abcdefghijklmnopqrstuvwyxz</b>}
  48. do_test fts1d-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 fts1d-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. finish_test