/ Check-in [b914ece0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add further fts5 tests. 100% code coverage is finally restored.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b914ece0d146cfc8adba4dc4e8633e14f174d6ea
User & Date: dan 2016-01-19 16:06:23
Context
2016-01-19
17:54
Fix two harmless compiler warnings about comparisons of dangling pointers. check-in: 86944f19 user: drh tags: trunk
16:06
Add further fts5 tests. 100% code coverage is finally restored. check-in: b914ece0 user: dan tags: trunk
2016-01-18
17:48
Add tests for fts5. Fix a crash that can occur in fts5 if the database content is corrupted. check-in: acaf4264 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts5/test/fts5_common.tcl.

    10     10   #***********************************************************************
    11     11   #
    12     12   
    13     13   if {![info exists testdir]} {
    14     14     set testdir [file join [file dirname [info script]] .. .. .. test]
    15     15   }
    16     16   source $testdir/tester.tcl
           17  +
           18  +ifcapable !fts5 {
           19  +  finish_test
           20  +  return
           21  +}
    17     22   
    18     23   catch { 
    19     24     sqlite3_fts5_may_be_corrupt 0 
    20     25     reset_db
    21     26   }
    22     27   
    23     28   # If SQLITE_ENABLE_FTS5 is not defined, skip this test.

Added ext/fts5/test/fts5bigtok.test.

            1  +# 2016 Jan 19
            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  +
           15  +source [file join [file dirname [info script]] fts5_common.tcl]
           16  +set testprefix fts5bigtok
           17  +
           18  +proc rndterm {} {
           19  +  set L [list a b c d e f g h i j k l m n o p q r s t u v w x y z]
           20  +  set l [lindex $L [expr int(rand() * [llength $L])]]
           21  +  string repeat $l [expr int(rand() * 5) + 60]
           22  +}
           23  +
           24  +proc rnddoc {n} {
           25  +  set res [list]
           26  +  for {set i 0} {$i < $n} {incr i} {
           27  +    lappend res [rndterm]
           28  +  }
           29  +  set res
           30  +}
           31  +
           32  +foreach_detail_mode $::testprefix {
           33  +  db func rnddoc rnddoc
           34  +  do_execsql_test 1.0 {
           35  +    CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);
           36  +    INSERT INTO t1(t1, rank) VALUES('pgsz', 32);
           37  +    CREATE VIRTUAL TABLE t1vocab USING fts5vocab(t1, row);
           38  +
           39  +    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10 )
           40  +    INSERT INTO t1 SELECT rnddoc(3) FROM s;
           41  +
           42  +    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10 )
           43  +    INSERT INTO t1 SELECT rnddoc(3) FROM s;
           44  +  }
           45  +
           46  +  foreach v [db eval {SELECT term FROM t1vocab}] {
           47  +    set res [db eval {SELECT rowid FROM t1($v)}]
           48  +    do_execsql_test 1.[string range $v 0 0] {
           49  +      SELECT rowid FROM t1($v) ORDER BY rowid DESC
           50  +    } [lsort -integer -decr $res]
           51  +  }
           52  +
           53  +  do_execsql_test 2.0 {
           54  +    INSERT INTO t1(t1) VALUES('optimize');
           55  +  }
           56  +
           57  +  foreach v [db eval {SELECT term FROM t1vocab}] {
           58  +    set res [db eval {SELECT rowid FROM t1($v)}]
           59  +    do_execsql_test 2.[string range $v 0 0] {
           60  +      SELECT rowid FROM t1($v) ORDER BY rowid DESC
           61  +    } [lsort -integer -decr $res]
           62  +  }
           63  +}
           64  +
           65  +finish_test
           66  +
           67  +

Changes to ext/fts5/test/fts5integrity.test.

   141    141     INSERT INTO gg(gg) VALUES('integrity-check');
   142    142   }
   143    143   
   144    144   do_execsql_test 5.2 {
   145    145     INSERT INTO gg(gg) VALUES('optimize');
   146    146   }
   147    147   
   148         -breakpoint
   149    148   do_execsql_test 5.3 {
   150    149     INSERT INTO gg(gg) VALUES('integrity-check');
   151    150   }
          151  +
          152  +do_test 5.4.1 {
          153  +  set ok 0
          154  +  for {set i 0} {$i < 10000} {incr i} {
          155  +    set T [format %.5d $i]
          156  +    set res  [db eval { SELECT rowid FROM gg($T) ORDER BY rowid ASC  }]
          157  +    set res2 [db eval { SELECT rowid FROM gg($T) ORDER BY rowid DESC }]
          158  +    if {$res == [lsort -integer $res2]} { incr ok }
          159  +  }
          160  +  set ok
          161  +} {10000}
          162  +
          163  +do_test 5.4.2 {
          164  +  set ok 0
          165  +  for {set i 0} {$i < 100} {incr i} {
          166  +    set T "[format %.3d $i]*"
          167  +    set res  [db eval { SELECT rowid FROM gg($T) ORDER BY rowid ASC  }]
          168  +    set res2 [db eval { SELECT rowid FROM gg($T) ORDER BY rowid DESC }]
          169  +    if {$res == [lsort -integer $res2]} { incr ok }
          170  +  }
          171  +  set ok
          172  +} {100}
          173  +
          174  +#-------------------------------------------------------------------------
          175  +# Similar to 5.*.
          176  +#
          177  +foreach {tn pgsz} {
          178  +  1  32
          179  +  2  36
          180  +  3  40
          181  +  4  44
          182  +  5  48
          183  +} {
          184  +  do_execsql_test 6.$tn.1 {
          185  +    DROP TABLE IF EXISTS hh;
          186  +    CREATE VIRTUAL TABLE hh USING fts5(y);
          187  +    INSERT INTO hh(hh, rank) VALUES('pgsz', $pgsz);
          188  +
          189  +    WITH s(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<999)
          190  +     INSERT INTO hh SELECT printf("%.3d%.3d%.3d %.3d%.3d%.3d",i,i,i,i+1,i+1,i+1)
          191  +     FROM s;
          192  +
          193  +    WITH s(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<999)
          194  +     INSERT INTO hh SELECT printf("%.3d%.3d%.3d %.3d%.3d%.3d",i,i,i,i+1,i+1,i+1)
          195  +     FROM s;
          196  +
          197  +    INSERT INTO hh(hh) VALUES('optimize');
          198  +  }
          199  +
          200  +  do_test 6.$tn.2 {
          201  +    set ok 0
          202  +    for {set i 0} {$i < 1000} {incr i} {
          203  +      set T [format %.3d%.3d%.3d $i $i $i]
          204  +      set res  [db eval { SELECT rowid FROM hh($T) ORDER BY rowid ASC  }]
          205  +      set res2 [db eval { SELECT rowid FROM hh($T) ORDER BY rowid DESC }]
          206  +      if {$res == [lsort -integer $res2]} { incr ok }
          207  +    }
          208  +    set ok
          209  +  } {1000}
          210  +}
   152    211   
   153    212   finish_test
   154    213   

Changes to ext/fts5/test/fts5rowid.test.

   198    198         SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100
   199    199       ) INSERT INTO x5 SELECT 'a b c d e f' FROM s;
   200    200     COMMIT;
   201    201     SELECT count(fts5_decode_none(rowid, block)) FROM x5_data;
   202    202   } {32}
   203    203   
   204    204   do_execsql_test 6.1 {
   205         -  DELETE FROM x5 WHERE rowid=1;
   206         -  UPDATE x5 SET x='a b c d e f' WHERE rowid=2;
          205  +  DELETE FROM x5 WHERE rowid <= 2;
          206  +  SELECT count(fts5_decode_none(rowid, block)) FROM x5_data;
          207  +} {34}
          208  +
          209  +do_execsql_test 6.2 {
          210  +  UPDATE x5 SET x='a b c d e f' WHERE rowid=3;
   207    211     SELECT count(fts5_decode_none(rowid, block)) FROM x5_data;
   208    212   } {36}
   209    213   
   210    214   #db eval {SELECT rowid, fts5_decode_none(rowid, block) aS r FROM x5_data} {puts $r}
   211    215   
   212    216   
   213    217   
   214    218   finish_test
   215    219