rowhash.test 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #
  15. # NB: The rowhash.c module is no longer part of the source tree. But
  16. # we might as well keep this test.
  17. #
  18. set testdir [file dirname $argv0]
  19. source $testdir/tester.tcl
  20. do_test rowhash-1.1 {
  21. execsql {
  22. CREATE TABLE t1(id INTEGER PRIMARY KEY, a, b, c);
  23. CREATE INDEX i1 ON t1(a);
  24. CREATE INDEX i2 ON t1(b);
  25. CREATE INDEX i3 ON t1(c);
  26. }
  27. } {}
  28. proc do_keyset_test {name lKey} {
  29. db transaction {
  30. execsql { DELETE FROM t1 }
  31. foreach key $lKey {
  32. execsql { INSERT OR IGNORE INTO t1 VALUES($key, 'a', 'b', 'c') }
  33. }
  34. }
  35. do_test $name {
  36. lsort -integer [execsql {
  37. SELECT id FROM t1 WHERE a = 'a' OR b = 'b' OR c = 'c';
  38. }]
  39. } [lsort -integer -unique $lKey]
  40. }
  41. do_keyset_test rowhash-2.1 {1 2 3}
  42. do_keyset_test rowhash-2.2 {0 1 2 3}
  43. do_keyset_test rowhash-2.3 {62 125 188}
  44. if {[working_64bit_int]} {
  45. expr srand(1)
  46. unset -nocomplain i L
  47. for {set i 4} {$i < 10} {incr i} {
  48. for {set j 0} {$j < 5000} {incr j} {
  49. lappend L [expr int(rand()*1000000000)]
  50. }
  51. do_keyset_test rowhash-2.$i $L
  52. }
  53. }
  54. finish_test