CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
fts3tok1.test125 linesDownload Raw Back to test
1# 2013 April 222#3# The author disclaims copyright to this source code.  In place of4# 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.  The12# focus of this script is testing the "fts3tokenize" virtual table13# that is part of the FTS3 module.14#15 16set testdir [file dirname $argv0]17source $testdir/tester.tcl18ifcapable !fts3 { finish_test ; return }19set ::testprefix fts3tok120 21#-------------------------------------------------------------------------22# Simple test cases. Using the default (simple) tokenizer.23#24do_execsql_test 1.0 {25  CREATE VIRTUAL TABLE t1 USING fts3tokenize(simple);26  CREATE VIRTUAL TABLE t2 USING fts3tokenize();27  CREATE VIRTUAL TABLE t3 USING fts3tokenize(simple, '', 'xyz ');28}29 30foreach {tn tbl} {1 t1 2 t2 3 t3} {31  do_execsql_test 1.$tn.1 "SELECT * FROM $tbl WHERE input = 'one two three'" {32    {one two three} one   0  3 0 33    {one two three} two   4  7 1 34    {one two three} three 8 13 235  }36 37  do_execsql_test 1.$tn.2 "38    SELECT token FROM $tbl WHERE input = 'OnE tWo tHrEe'39  " {40    one two three41  }42}43 44do_execsql_test 1.4 {45  SELECT token FROM t3 WHERE input = '1x2x3x'46} {1 2 3}47 48do_execsql_test 1.5 {49  SELECT token FROM t1 WHERE input = '1x2x3x'50} {1x2x3x}51 52do_execsql_test 1.6 {53  SELECT token FROM t3 WHERE input = '1''2x3x'54} {1'2 3}55 56do_execsql_test 1.7 {57  SELECT token FROM t3 WHERE input = ''58} {}59 60do_execsql_test 1.8 {61  SELECT token FROM t3 WHERE input = NULL62} {}63 64do_execsql_test 1.9 {65  SELECT * FROM t3 WHERE input = 12366} {123 123 0 3 0}67 68do_execsql_test 1.10 {69  SELECT * FROM t1 WHERE input = 'a b c' AND token = 'b';70} {71  {a b c} b 2 3 172}73 74do_execsql_test 1.11 {75  SELECT * FROM t1 WHERE token = 'b' AND input = 'a b c';76} {77  {a b c} b 2 3 178}79 80do_execsql_test 1.12 {81  SELECT * FROM t1 WHERE input < 'b' AND input = 'a b c';82} {83  {a b c} a 0 1 0 84  {a b c} b 2 3 1 85  {a b c} c 4 5 286}87 88do_execsql_test 1.13.1 {89  CREATE TABLE c1(x);90  INSERT INTO c1(x) VALUES('a b c');91  INSERT INTO c1(x) VALUES('d e f');92}93do_execsql_test 1.13.2 {94  SELECT * FROM c1, t1 WHERE input = x AND c1.rowid=t1.rowid;95} {96  {a b c} {a b c} a 0 1 0 97  {d e f} {d e f} e 2 3 1 98}99 100 101#-------------------------------------------------------------------------102# Error cases.103#104do_catchsql_test 2.0 {105  CREATE VIRTUAL TABLE tX USING fts3tokenize(nosuchtokenizer);106} {1 {unknown tokenizer: nosuchtokenizer}}107 108do_catchsql_test 2.1 {109  CREATE VIRTUAL TABLE t4 USING fts3tokenize;110  SELECT * FROM t4;111} {1 {SQL logic error}}112 113do_catchsql_test 2.2 {114  CREATE VIRTUAL TABLE t USING fts4(tokenize=simple""); 115} {0 {}}116 117ifcapable fts3_unicode {118  do_catchsql_test 2.3 {119    CREATE VIRTUAL TABLE u USING fts4(tokenize=unicode61""); 120  } {1 {unknown tokenizer}}121}122 123 124finish_test125