danielk1977 | 1d46146 | 2009-04-21 09:02:45 +0000 | [diff] [blame] | 1 | # 2009 April 17 |
| 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 implements regression tests for SQLite library. The |
| 13 | # focus of this file is the code in rowhash.c. |
| 14 | # |
drh | 048129d | 2010-06-02 14:43:30 +0000 | [diff] [blame] | 15 | # NB: The rowhash.c module is no longer part of the source tree. But |
| 16 | # we might as well keep this test. |
| 17 | # |
danielk1977 | 1d46146 | 2009-04-21 09:02:45 +0000 | [diff] [blame] | 18 | |
| 19 | set testdir [file dirname $argv0] |
| 20 | source $testdir/tester.tcl |
| 21 | |
| 22 | do_test rowhash-1.1 { |
| 23 | execsql { |
| 24 | CREATE TABLE t1(id INTEGER PRIMARY KEY, a, b, c); |
| 25 | CREATE INDEX i1 ON t1(a); |
| 26 | CREATE INDEX i2 ON t1(b); |
| 27 | CREATE INDEX i3 ON t1(c); |
| 28 | } |
| 29 | } {} |
| 30 | |
| 31 | proc do_keyset_test {name lKey} { |
| 32 | db transaction { |
| 33 | execsql { DELETE FROM t1 } |
| 34 | foreach key $lKey { |
drh | 84fe066 | 2009-04-21 17:13:38 +0000 | [diff] [blame] | 35 | execsql { INSERT OR IGNORE INTO t1 VALUES($key, 'a', 'b', 'c') } |
danielk1977 | 1d46146 | 2009-04-21 09:02:45 +0000 | [diff] [blame] | 36 | } |
| 37 | } |
| 38 | do_test $name { |
| 39 | lsort -integer [execsql { |
| 40 | SELECT id FROM t1 WHERE a = 'a' OR b = 'b' OR c = 'c'; |
| 41 | }] |
danielk1977 | 2e90567 | 2009-04-28 15:48:08 +0000 | [diff] [blame] | 42 | } [lsort -integer -unique $lKey] |
danielk1977 | 1d46146 | 2009-04-21 09:02:45 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | do_keyset_test rowhash-2.1 {1 2 3} |
| 46 | do_keyset_test rowhash-2.2 {0 1 2 3} |
| 47 | do_keyset_test rowhash-2.3 {62 125 188} |
shane | b1a82db | 2009-04-23 18:42:04 +0000 | [diff] [blame] | 48 | if {[working_64bit_int]} { |
| 49 | expr srand(1) |
drh | 048129d | 2010-06-02 14:43:30 +0000 | [diff] [blame] | 50 | unset -nocomplain i L |
shane | b1a82db | 2009-04-23 18:42:04 +0000 | [diff] [blame] | 51 | for {set i 4} {$i < 10} {incr i} { |
| 52 | for {set j 0} {$j < 5000} {incr j} { |
drh | 7895fdd | 2009-05-02 12:02:01 +0000 | [diff] [blame] | 53 | lappend L [expr int(rand()*1000000000)] |
shane | b1a82db | 2009-04-23 18:42:04 +0000 | [diff] [blame] | 54 | } |
| 55 | do_keyset_test rowhash-2.$i $L |
danielk1977 | 1d46146 | 2009-04-21 09:02:45 +0000 | [diff] [blame] | 56 | } |
danielk1977 | 1d46146 | 2009-04-21 09:02:45 +0000 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | finish_test |