11d46146bSdanielk1977# 2009 April 17 21d46146bSdanielk1977# 31d46146bSdanielk1977# The author disclaims copyright to this source code. In place of 41d46146bSdanielk1977# a legal notice, here is a blessing: 51d46146bSdanielk1977# 61d46146bSdanielk1977# May you do good and not evil. 71d46146bSdanielk1977# May you find forgiveness for yourself and forgive others. 81d46146bSdanielk1977# May you share freely, never taking more than you give. 91d46146bSdanielk1977# 101d46146bSdanielk1977#*********************************************************************** 111d46146bSdanielk1977# 121d46146bSdanielk1977# This file implements regression tests for SQLite library. The 131d46146bSdanielk1977# focus of this file is the code in rowhash.c. 141d46146bSdanielk1977# 15*048129dcSdrh# NB: The rowhash.c module is no longer part of the source tree. But 16*048129dcSdrh# we might as well keep this test. 17*048129dcSdrh# 181d46146bSdanielk1977 191d46146bSdanielk1977set testdir [file dirname $argv0] 201d46146bSdanielk1977source $testdir/tester.tcl 211d46146bSdanielk1977 221d46146bSdanielk1977do_test rowhash-1.1 { 231d46146bSdanielk1977 execsql { 241d46146bSdanielk1977 CREATE TABLE t1(id INTEGER PRIMARY KEY, a, b, c); 251d46146bSdanielk1977 CREATE INDEX i1 ON t1(a); 261d46146bSdanielk1977 CREATE INDEX i2 ON t1(b); 271d46146bSdanielk1977 CREATE INDEX i3 ON t1(c); 281d46146bSdanielk1977 } 291d46146bSdanielk1977} {} 301d46146bSdanielk1977 311d46146bSdanielk1977proc do_keyset_test {name lKey} { 321d46146bSdanielk1977 db transaction { 331d46146bSdanielk1977 execsql { DELETE FROM t1 } 341d46146bSdanielk1977 foreach key $lKey { 3584fe0664Sdrh execsql { INSERT OR IGNORE INTO t1 VALUES($key, 'a', 'b', 'c') } 361d46146bSdanielk1977 } 371d46146bSdanielk1977 } 381d46146bSdanielk1977 do_test $name { 391d46146bSdanielk1977 lsort -integer [execsql { 401d46146bSdanielk1977 SELECT id FROM t1 WHERE a = 'a' OR b = 'b' OR c = 'c'; 411d46146bSdanielk1977 }] 422e905678Sdanielk1977 } [lsort -integer -unique $lKey] 431d46146bSdanielk1977} 441d46146bSdanielk1977 451d46146bSdanielk1977do_keyset_test rowhash-2.1 {1 2 3} 461d46146bSdanielk1977do_keyset_test rowhash-2.2 {0 1 2 3} 471d46146bSdanielk1977do_keyset_test rowhash-2.3 {62 125 188} 48b1a82dbeSshaneif {[working_64bit_int]} { 4984fe0664Sdrh expr srand(1) 50*048129dcSdrh unset -nocomplain i L 511d46146bSdanielk1977 for {set i 4} {$i < 10} {incr i} { 521d46146bSdanielk1977 for {set j 0} {$j < 5000} {incr j} { 537895fdd4Sdrh lappend L [expr int(rand()*1000000000)] 541d46146bSdanielk1977 } 551d46146bSdanielk1977 do_keyset_test rowhash-2.$i $L 561d46146bSdanielk1977 } 57b1a82dbeSshane} 581d46146bSdanielk1977 591d46146bSdanielk1977finish_test 60