| 1 |
# 2008 Jul 14 |
| 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 |
# The focus of this file is testing the r-tree extension when it is |
| 13 |
# configured to store values as 32 bit integers. |
| 14 |
# |
| 15 |
|
| 16 |
if {![info exists testdir]} { |
| 17 |
set testdir [file join [file dirname [info script]] .. .. test] |
| 18 |
} |
| 19 |
source [file join [file dirname [info script]] rtree_util.tcl] |
| 20 |
source $testdir/tester.tcl |
| 21 |
|
| 22 |
ifcapable !rtree { |
| 23 |
finish_test |
| 24 |
return |
| 25 |
} |
| 26 |
|
| 27 |
do_test rtree5-1.0 { |
| 28 |
execsql { CREATE VIRTUAL TABLE t1 USING rtree_i32(id, x1, x2, y1, y2) } |
| 29 |
} {} |
| 30 |
do_test rtree5-1.1 { |
| 31 |
execsql { INSERT INTO t1 VALUES(1, 5, 10, 4, 11.2) } |
| 32 |
} {} |
| 33 |
do_test rtree5-1.2 { |
| 34 |
execsql { SELECT * FROM t1 } |
| 35 |
} {1 5 10 4 11} |
| 36 |
do_test rtree5-1.3 { |
| 37 |
execsql { SELECT typeof(x1) FROM t1 } |
| 38 |
} {integer} |
| 39 |
|
| 40 |
do_test rtree5-1.4 { |
| 41 |
execsql { SELECT x1==5 FROM t1 } |
| 42 |
} {1} |
| 43 |
do_test rtree5-1.5 { |
| 44 |
execsql { SELECT x1==5.2 FROM t1 } |
| 45 |
} {0} |
| 46 |
do_test rtree5-1.6 { |
| 47 |
execsql { SELECT x1==5.0 FROM t1 } |
| 48 |
} {1} |
| 49 |
|
| 50 |
do_test rtree5-1.7 { |
| 51 |
execsql { SELECT count(*) FROM t1 WHERE x1==5 } |
| 52 |
} {1} |
| 53 |
ifcapable !rtree_int_only { |
| 54 |
do_test rtree5-1.8 { |
| 55 |
execsql { SELECT count(*) FROM t1 WHERE x1==5.2 } |
| 56 |
} {0} |
| 57 |
} |
| 58 |
do_test rtree5-1.9 { |
| 59 |
execsql { SELECT count(*) FROM t1 WHERE x1==5.0 } |
| 60 |
} {1} |
| 61 |
|
| 62 |
do_test rtree5-1.10 { |
| 63 |
execsql { SELECT (1<<31)-5, (1<<31)-1, -1*(1<<31), -1*(1<<31)+5 } |
| 64 |
} {2147483643 2147483647 -2147483648 -2147483643} |
| 65 |
do_test rtree5-1.11 { |
| 66 |
execsql { |
| 67 |
INSERT INTO t1 VALUES(2, (1<<31)-5, (1<<31)-1, -1*(1<<31), -1*(1<<31)+5) |
| 68 |
} |
| 69 |
} {} |
| 70 |
do_test rtree5-1.12 { |
| 71 |
execsql { SELECT * FROM t1 WHERE id=2 } |
| 72 |
} {2 2147483643 2147483647 -2147483648 -2147483643} |
| 73 |
do_test rtree5-1.13 { |
| 74 |
execsql { |
| 75 |
SELECT * FROM t1 WHERE |
| 76 |
x1=2147483643 AND x2=2147483647 AND |
| 77 |
y1=-2147483648 AND y2=-2147483643 |
| 78 |
} |
| 79 |
} {2 2147483643 2147483647 -2147483648 -2147483643} |
| 80 |
do_rtree_integrity_test rtree5-1.14 t1 |
| 81 |
|
| 82 |
expand_all_sql db |
| 83 |
finish_test |