9508daa929
FossilOrigin-Name: 782ca3b716ee1ecb0dfb5ab6f21dfd73d41758e4
55 lines
1.6 KiB
Plaintext
55 lines
1.6 KiB
Plaintext
# 2010 August 28
|
|
#
|
|
# The author disclaims copyright to this source code. In place of
|
|
# a legal notice, here is a blessing:
|
|
#
|
|
# May you do good and not evil.
|
|
# May you find forgiveness for yourself and forgive others.
|
|
# May you share freely, never taking more than you give.
|
|
#
|
|
#***********************************************************************
|
|
#
|
|
|
|
if {![info exists testdir]} {
|
|
set testdir [file join [file dirname [info script]] .. .. test]
|
|
}
|
|
source $testdir/tester.tcl
|
|
ifcapable !rtree { finish_test ; return }
|
|
|
|
register_cube_geom db
|
|
|
|
do_execsql_test rtree9-1.1 {
|
|
CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2, y1, y2, z1, z2);
|
|
INSERT INTO rt VALUES(1, 1, 2, 1, 2, 1, 2);
|
|
} {}
|
|
do_execsql_test rtree9-1.2 {
|
|
SELECT * FROM rt WHERE id MATCH cube(0, 0, 0, 2, 2, 2);
|
|
} {1 1.0 2.0 1.0 2.0 1.0 2.0}
|
|
do_execsql_test rtree9-1.3 {
|
|
SELECT * FROM rt WHERE id MATCH cube(3, 3, 3, 2, 2, 2);
|
|
} {}
|
|
do_execsql_test rtree9-1.4 {
|
|
DELETE FROM rt;
|
|
} {}
|
|
|
|
for {set i 0} {$i < 1000} {incr i} {
|
|
set x [expr $i%10]
|
|
set y [expr ($i/10)%10]
|
|
set z [expr ($i/100)%10]
|
|
execsql { INSERT INTO rt VALUES($i, $x, $x+1, $y, $y+1, $z, $z+1) }
|
|
}
|
|
|
|
do_execsql_test rtree9-2.1 {
|
|
SELECT id FROM rt WHERE id MATCH cube(2.5, 2.5, 2.5, 1, 1, 1) ORDER BY id;
|
|
} {222 223 232 233 322 323 332 333}
|
|
do_execsql_test rtree9-2.2 {
|
|
SELECT id FROM rt WHERE id MATCH cube(5.5, 5.5, 5.5, 1, 1, 1) ORDER BY id;
|
|
} {555 556 565 566 655 656 665 666}
|
|
|
|
do_catchsql_test rtree9-3.1 {
|
|
SELECT id FROM rt WHERE id MATCH cube(5.5, 5.5, 1, 1, 1) ORDER BY id;
|
|
} {1 {SQL logic error or missing database}}
|
|
|
|
|
|
finish_test
|