1# 2009 December 20 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# 12# This file contains tests of fts3 queries that have been useful during 13# the development process as well as some that have been useful in tracking 14# down bugs. They are not focused on any particular functionality. 15# 16 17set testdir [file dirname $argv0] 18source $testdir/tester.tcl 19 20# If this build does not include FTS3, skip the tests in this file. 21# 22ifcapable !fts3 { finish_test ; return } 23source $testdir/fts3_common.tcl 24set DO_MALLOC_TEST 0 25 26do_test fts3query-1.1 { 27 execsql { 28 CREATE VIRTUAL TABLE t1 USING fts3(x); 29 BEGIN; 30 INSERT INTO t1 VALUES('The source code for SQLite is in the public'); 31 } 32} {} 33 34do_select_test fts3query-1.2 { 35 SELECT * FROM t1; 36} {{The source code for SQLite is in the public}} 37do_select_test fts3query-1.3 { 38 SELECT * FROM t1 WHERE t1 MATCH 'sqlite' 39} {{The source code for SQLite is in the public}} 40 41do_test fts3query-1.4 { execsql {COMMIT} } {} 42 43do_select_test fts3query-1.5 { 44 SELECT * FROM t1; 45} {{The source code for SQLite is in the public}} 46do_select_test fts3query-1.6 { 47 SELECT * FROM t1 WHERE t1 MATCH 'sqlite' 48} {{The source code for SQLite is in the public}} 49 50 51set sqlite_fts3_enable_parentheses 1 52do_test fts3query-2.1 { 53 execsql { 54 CREATE VIRTUAL TABLE zoink USING fts3; 55 INSERT INTO zoink VALUES('The apple falls far from the tree'); 56 } 57} {} 58do_test fts3query-2.2 { 59 execsql { 60 SELECT docid FROM zoink WHERE zoink MATCH '(apple oranges) AND apple' 61 } 62} {} 63do_test fts3query-2.3 { 64 execsql { 65 SELECT docid FROM zoink WHERE zoink MATCH 'apple AND (oranges apple)' 66 } 67} {} 68set sqlite_fts3_enable_parentheses 0 69 70do_test fts3query-3.1 { 71 execsql { 72 CREATE VIRTUAL TABLE foobar using FTS3(description, tokenize porter); 73 INSERT INTO foobar (description) values (' 74 Filed under: Emerging Technologies, EV/Plug-in, Hybrid, Chevrolet, GM, 75 ZENN 2011 Chevy Volt - Click above for high-res image gallery There are 76 16 days left in the month of December. Besides being time for most 77 Americans to kick their Christmas shopping sessions into high gear and 78 start planning their resolutions for 2010, it also means that there''s 79 precious little time for EEStor to "deliver functional technology" to 80 Zenn Motors as promised. Still, the promises held out by the secretive 81 company are too great for us to forget about entirely. We''d love for 82 EEStor''s claims to be independently verified and proven accurate, as 83 would just about anyone else looking to break free of petroleum in fav 84 '); 85 } 86} {} 87 88do_test fts3query-3.2 { 89 execsql { SELECT docid FROM foobar WHERE description MATCH '"high sp d"' } 90} {} 91 92proc mit {blob} { 93 set scan(littleEndian) i* 94 set scan(bigEndian) I* 95 binary scan $blob $scan($::tcl_platform(byteOrder)) r 96 return $r 97} 98db func mit mit 99 100do_test fts3query-3.3 { 101 execsql { SELECT mit(matchinfo(foobar)) FROM foobar WHERE foobar MATCH 'the' } 102} {{1 1 3 3 1}} 103 104finish_test 105 106