| OLD | NEW |
| 1 puts {# 2008 December 11 | 1 puts {# 2008 December 11 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
| 4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
| 5 # | 5 # |
| 6 # May you do good and not evil. | 6 # May you do good and not evil. |
| 7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
| 8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
| 9 # | 9 # |
| 10 #*********************************************************************** | 10 #*********************************************************************** |
| 11 # This file implements regression tests for SQLite library. | 11 # This file implements regression tests for SQLite library. |
| 12 # | 12 # |
| 13 # This file is automatically generated from a separate TCL script. | 13 # This file is automatically generated from a separate TCL script. |
| 14 # This file seeks to exercise integer boundary values. | 14 # This file seeks to exercise integer boundary values. |
| 15 # | 15 # |
| 16 # $Id: boundary3.tcl,v 1.3 2009/01/02 15:45:48 shane Exp $ | |
| 17 | 16 |
| 18 set testdir [file dirname $argv0] | 17 set testdir [file dirname $argv0] |
| 19 source $testdir/tester.tcl | 18 source $testdir/tester.tcl |
| 20 | 19 |
| 21 # Many of the boundary tests depend on a working 64-bit implementation. | 20 # Many of the boundary tests depend on a working 64-bit implementation. |
| 22 if {![working_64bit_int]} { finish_test; return } | 21 if {![working_64bit_int]} { finish_test; return } |
| 23 } | 22 } |
| 24 | 23 |
| 25 expr srand(0) | 24 expr srand(0) |
| 26 | 25 |
| 27 # Generate interesting boundary numbers | 26 # Generate interesting boundary numbers |
| 28 # | 27 # |
| 29 foreach x { | 28 foreach x { |
| 30 0 | 29 0 |
| 31 1 | 30 1 |
| 32 0x7f | 31 0x7f |
| 33 0x7fff | 32 0x7fff |
| 34 0x7fffff | 33 0x7fffff |
| 35 0x7fffffff | 34 0x7fffffff |
| 36 0x7fffffffff | 35 0x7fffffffff |
| 37 0x7fffffffffff | 36 0x7fffffffffff |
| 38 0x7fffffffffffff | 37 0x7fffffffffffff |
| 39 0x7fffffffffffffff | 38 0x7fffffffffffffff |
| 40 } { | 39 } { |
| 41 set x [expr {wide($x)}] | 40 set x [expr {wide($x)}] |
| 42 set boundarynum($x) 1 | 41 set boundarynum($x) 1 |
| 43 set boundarynum([expr {$x+1}]) 1 | 42 set boundarynum([expr {wide($x+1)}]) 1 |
| 44 set boundarynum([expr {-($x+1)}]) 1 | 43 set boundarynum([expr {wide(-($x+1))}]) 1 |
| 45 set boundarynum([expr {-($x+2)}]) 1 | 44 set boundarynum([expr {wide(-($x+2))}]) 1 |
| 46 set boundarynum([expr {$x+$x+1}]) 1 | 45 set boundarynum([expr {wide($x+$x+1)}]) 1 |
| 47 set boundarynum([expr {$x+$x+2}]) 1 | 46 set boundarynum([expr {wide($x+$x+2)}]) 1 |
| 48 } | 47 } |
| 49 set x [expr {wide(127)}] | 48 set x [expr {wide(127)}] |
| 50 for {set i 1} {$i<=9} {incr i} { | 49 for {set i 1} {$i<=9} {incr i} { |
| 51 set boundarynum($x) 1 | 50 set boundarynum($x) 1 |
| 52 set boundarynum([expr {$x+1}]) 1 | 51 set boundarynum([expr {wide($x+1)}]) 1 |
| 53 set x [expr {wide($x*128 + 127)}] | 52 set x [expr {wide($x*128 + 127)}] |
| 54 } | 53 } |
| 55 | 54 |
| 56 # Scramble the $inlist into a random order. | 55 # Scramble the $inlist into a random order. |
| 57 # | 56 # |
| 58 proc scramble {inlist} { | 57 proc scramble {inlist} { |
| 59 set y {} | 58 set y {} |
| 60 foreach x $inlist { | 59 foreach x $inlist { |
| 61 lappend y [list [expr {rand()}] $x] | 60 lappend y [list [expr {rand()}] $x] |
| 62 } | 61 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 108 |
| 110 set tname boundary3 | 109 set tname boundary3 |
| 111 puts "do_test $tname-1.1 \173" | 110 puts "do_test $tname-1.1 \173" |
| 112 puts " db eval \173" | 111 puts " db eval \173" |
| 113 puts " CREATE TABLE t1(a,x);" | 112 puts " CREATE TABLE t1(a,x);" |
| 114 set a 0 | 113 set a 0 |
| 115 foreach r $nums1 { | 114 foreach r $nums1 { |
| 116 incr a | 115 incr a |
| 117 set t1ra($r) $a | 116 set t1ra($r) $a |
| 118 set t1ar($a) $r | 117 set t1ar($a) $r |
| 119 set x [format %08x%08x [expr {wide($r)>>32}] $r] | 118 set x [format %016x [expr {wide($r)}]] |
| 120 set t1rx($r) $x | 119 set t1rx($r) $x |
| 121 set t1xr($x) $r | 120 set t1xr($x) $r |
| 122 puts " INSERT INTO t1(oid,a,x) VALUES($r,$a,'$x');" | 121 puts " INSERT INTO t1(oid,a,x) VALUES($r,$a,'$x');" |
| 123 } | 122 } |
| 124 puts " CREATE INDEX t1i1 ON t1(a);" | 123 puts " CREATE INDEX t1i1 ON t1(a);" |
| 125 puts " CREATE INDEX t1i2 ON t1(x);" | 124 puts " CREATE INDEX t1i2 ON t1(x);" |
| 126 puts " \175" | 125 puts " \175" |
| 127 puts "\175 {}" | 126 puts "\175 {}" |
| 128 | 127 |
| 129 puts "do_test $tname-1.2 \173" | 128 puts "do_test $tname-1.2 \173" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 151 set nums3 $nums2 | 150 set nums3 $nums2 |
| 152 lappend nums3 9.22337303685477580800e+18 | 151 lappend nums3 9.22337303685477580800e+18 |
| 153 lappend nums3 -9.22337303685477580800e+18 | 152 lappend nums3 -9.22337303685477580800e+18 |
| 154 | 153 |
| 155 set i 0 | 154 set i 0 |
| 156 foreach r $nums3 { | 155 foreach r $nums3 { |
| 157 incr i | 156 incr i |
| 158 | 157 |
| 159 set r5 $r.5 | 158 set r5 $r.5 |
| 160 set r0 $r.0 | 159 set r0 $r.0 |
| 161 if {abs($r)<9.22337203685477580800e+18} { | 160 if {abs($r)<0x7FFFFFFFFFFFFFFF || $r==-9223372036854775808} { |
| 162 set x $t1rx($r) | 161 set x $t1rx($r) |
| 163 set a $t1ra($r) | 162 set a $t1ra($r) |
| 164 puts "do_test $tname-2.$i.1 \173" | 163 puts "do_test $tname-2.$i.1 \173" |
| 165 puts " db eval \173" | 164 puts " db eval \173" |
| 166 puts " SELECT t1.* FROM t1, t2 WHERE t1.rowid=$r AND t2.a=t1.a" | 165 puts " SELECT t1.* FROM t1, t2 WHERE t1.rowid=$r AND t2.a=t1.a" |
| 167 puts " \175" | 166 puts " \175" |
| 168 puts "\175 {$a $x}" | 167 puts "\175 {$a $x}" |
| 169 puts "do_test $tname-2.$i.2 \173" | 168 puts "do_test $tname-2.$i.2 \173" |
| 170 puts " db eval \173" | 169 puts " db eval \173" |
| 171 puts " SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='$x'" | 170 puts " SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='$x'" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 puts " WHERE t2.a=$ax" | 280 puts " WHERE t2.a=$ax" |
| 282 puts " ORDER BY t1.rowid DESC" | 281 puts " ORDER BY t1.rowid DESC" |
| 283 puts " \175" | 282 puts " \175" |
| 284 puts "\175 {$aset}" | 283 puts "\175 {$aset}" |
| 285 } | 284 } |
| 286 | 285 |
| 287 } | 286 } |
| 288 | 287 |
| 289 | 288 |
| 290 puts {finish_test} | 289 puts {finish_test} |
| OLD | NEW |