1*be7721d1Sdan# 2016 February 4 2*be7721d1Sdan# 3*be7721d1Sdan# The author disclaims copyright to this source code. In place of 4*be7721d1Sdan# a legal notice, here is a blessing: 5*be7721d1Sdan# 6*be7721d1Sdan# May you do good and not evil. 7*be7721d1Sdan# May you find forgiveness for yourself and forgive others. 8*be7721d1Sdan# May you share freely, never taking more than you give. 9*be7721d1Sdan# 10*be7721d1Sdan#*********************************************************************** 11*be7721d1Sdan# The focus of the tests is the word-fuzzer virtual table. The tests 12*be7721d1Sdan# in this file are slower than those in fuzzer1.test. So this file does 13*be7721d1Sdan# not run as part of veryquick.test etc. 14*be7721d1Sdan# 15*be7721d1Sdan 16*be7721d1Sdanset testdir [file dirname $argv0] 17*be7721d1Sdansource $testdir/tester.tcl 18*be7721d1Sdan 19*be7721d1Sdanifcapable !vtab { 20*be7721d1Sdan finish_test 21*be7721d1Sdan return 22*be7721d1Sdan} 23*be7721d1Sdan 24*be7721d1Sdanset ::testprefix fuzzer2 25*be7721d1Sdanload_static_extension db fuzzer 26*be7721d1Sdan 27*be7721d1Sdan#------------------------------------------------------------------------- 28*be7721d1Sdan# This test uses a fuzzer table with many rules. There is one rule to 29*be7721d1Sdan# map each possible two character string, where characters are lower-case 30*be7721d1Sdan# letters used in the English language, to all other possible two character 31*be7721d1Sdan# strings. In total, (26^4)-(26^2) mappings (the subtracted term represents 32*be7721d1Sdan# the no-op mappings discarded automatically by the fuzzer). 33*be7721d1Sdan# 34*be7721d1Sdan# 35*be7721d1Sdando_execsql_test 1.1.1 { 36*be7721d1Sdan DROP TABLE IF EXISTS x1; 37*be7721d1Sdan DROP TABLE IF EXISTS x1_rules; 38*be7721d1Sdan CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost); 39*be7721d1Sdan} 40*be7721d1Sdanputs "This test is slow - perhaps around 7 seconds on an average pc" 41*be7721d1Sdando_test 1.1.2 { 42*be7721d1Sdan set LETTERS {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} 43*be7721d1Sdan set cost 1 44*be7721d1Sdan db transaction { 45*be7721d1Sdan foreach c1 $LETTERS { 46*be7721d1Sdan foreach c2 $LETTERS { 47*be7721d1Sdan foreach c3 $LETTERS { 48*be7721d1Sdan foreach c4 $LETTERS { 49*be7721d1Sdan db eval {INSERT INTO x1_rules VALUES(0, $c1||$c2, $c3||$c4, $cost)} 50*be7721d1Sdan set cost [expr ($cost%1000) + 1] 51*be7721d1Sdan } 52*be7721d1Sdan } 53*be7721d1Sdan } 54*be7721d1Sdan } 55*be7721d1Sdan db eval {UPDATE x1_rules SET cost = 20 WHERE cost<20 AND cFrom!='xx'} 56*be7721d1Sdan } 57*be7721d1Sdan} {} 58*be7721d1Sdan 59*be7721d1Sdando_execsql_test 1.2 { 60*be7721d1Sdan SELECT count(*) FROM x1_rules WHERE cTo!=cFrom; 61*be7721d1Sdan} [expr 26*26*26*26 - 26*26] 62*be7721d1Sdan 63*be7721d1Sdando_execsql_test 1.2.1 { 64*be7721d1Sdan CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules); 65*be7721d1Sdan SELECT word FROM x1 WHERE word MATCH 'xx' LIMIT 10; 66*be7721d1Sdan} {xx hw hx hy hz ia ib ic id ie} 67*be7721d1Sdando_execsql_test 1.2.2 { 68*be7721d1Sdan SELECT cTo FROM x1_rules WHERE cFrom='xx' 69*be7721d1Sdan ORDER BY cost asc, rowid asc LIMIT 9; 70*be7721d1Sdan} {hw hx hy hz ia ib ic id ie} 71*be7721d1Sdan 72*be7721d1Sdanfinish_test 73