Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/rtree/rtree9.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / rtree / rtree9.test` 129 lines ยท 4348 bytes Raw Blame History 1 # 2010 August 28 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 # This file contains tests for the r-tree module. Specifically, it tests 12 # that custom r-tree queries (geometry callbacks) work. 13 # 14 15 if {![info exists testdir]} { 16 set testdir [file join [file dirname [info script]] .. .. test] 17 } 18 source [file join [file dirname [info script]] rtree_util.tcl] 19 source $testdir/tester.tcl 20 ifcapable !rtree { finish_test ; return } 21 ifcapable rtree_int_only { finish_test; return } 22 23 register_cube_geom db 24 25 do_execsql_test rtree9-1.1 { 26 CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2, y1, y2, z1, z2); 27 INSERT INTO rt VALUES(1, 1, 2, 1, 2, 1, 2); 28 } {} 29 do_execsql_test rtree9-1.2 { 30 SELECT * FROM rt WHERE id MATCH cube(0, 0, 0, 2, 2, 2); 31 } {1 1.0 2.0 1.0 2.0 1.0 2.0} 32 do_execsql_test rtree9-1.3 { 33 SELECT * FROM rt WHERE id MATCH cube(3, 3, 3, 2, 2, 2); 34 } {} 35 do_execsql_test rtree9-1.4 { 36 DELETE FROM rt; 37 } {} 38 39 unset -nocomplain x 40 for {set i 0} {$i < 1000} {incr i} { 41 set x [expr $i%10] 42 set y [expr ($i/10)%10] 43 set z [expr ($i/100)%10] 44 execsql { INSERT INTO rt VALUES($i, $x, $x+1, $y, $y+1, $z, $z+1) } 45 } 46 do_rtree_integrity_test rtree9-2.0 rt 47 do_execsql_test rtree9-2.1 { 48 SELECT id FROM rt WHERE id MATCH cube(2.5, 2.5, 2.5, 1, 1, 1) ORDER BY id; 49 } {222 223 232 233 322 323 332 333} 50 do_execsql_test rtree9-2.2 { 51 SELECT id FROM rt WHERE id MATCH cube(5.5, 5.5, 5.5, 1, 1, 1) ORDER BY id; 52 } {555 556 565 566 655 656 665 666} 53 54 55 do_execsql_test rtree9-3.0 { 56 CREATE VIRTUAL TABLE rt32 USING rtree_i32(id, x1, x2, y1, y2, z1, z2); 57 } {} 58 for {set i 0} {$i < 1000} {incr i} { 59 set x [expr $i%10] 60 set y [expr ($i/10)%10] 61 set z [expr ($i/100)%10] 62 execsql { INSERT INTO rt32 VALUES($i, $x, $x+1, $y, $y+1, $z, $z+1) } 63 } 64 do_rtree_integrity_test rtree9-3.1 rt32 65 do_execsql_test rtree9-3.2 { 66 SELECT id FROM rt32 WHERE id MATCH cube(3, 3, 3, 1, 1, 1) ORDER BY id; 67 } {222 223 224 232 233 234 242 243 244 322 323 324 332 333 334 342 343 344 422 423 424 432 433 434 442 443 444} 68 do_execsql_test rtree9-3.3 { 69 SELECT id FROM rt32 WHERE id MATCH cube(5.5, 5.5, 5.5, 1, 1, 1) ORDER BY id; 70 } {555 556 565 566 655 656 665 666} 71 72 73 do_catchsql_test rtree9-4.1 { 74 SELECT id FROM rt32 WHERE id MATCH cube(5.5, 5.5, 1, 1, 1) ORDER BY id; 75 } {1 {SQL logic error}} 76 for {set x 2} {$x<200} {incr x 2} { 77 do_catchsql_test rtree9-4.2.[expr $x/2] { 78 SELECT id FROM rt WHERE id MATCH randomblob($x) 79 } {1 {SQL logic error}} 80 } 81 do_catchsql_test rtree9-4.3 { 82 SELECT id FROM rt WHERE id MATCH CAST( 83 (cube(5.5, 5.5, 5.5, 1, 1, 1) || X'`1234567812345678`') AS blob 84 ) 85 } {1 {SQL logic error}} 86 87 88 #------------------------------------------------------------------------- 89 # Test the example 2d "circle" geometry callback. 90 # 91 register_circle_geom db 92 93 do_execsql_test rtree9-5.1 { 94 CREATE VIRTUAL TABLE rt2 USING rtree(id, xmin, xmax, ymin, ymax); 95 96 INSERT INTO rt2 VALUES(1, 1, 2, 1, 2); 97 INSERT INTO rt2 VALUES(2, 1, 2, -2, -1); 98 INSERT INTO rt2 VALUES(3, -2, -1, -2, -1); 99 INSERT INTO rt2 VALUES(4, -2, -1, 1, 2); 100 101 INSERT INTO rt2 VALUES(5, 2, 3, 2, 3); 102 INSERT INTO rt2 VALUES(6, 2, 3, -3, -2); 103 INSERT INTO rt2 VALUES(7, -3, -2, -3, -2); 104 INSERT INTO rt2 VALUES(8, -3, -2, 2, 3); 105 106 INSERT INTO rt2 VALUES(9, 1.8, 3, 1.8, 3); 107 INSERT INTO rt2 VALUES(10, 1.8, 3, -3, -1.8); 108 INSERT INTO rt2 VALUES(11, -3, -1.8, -3, -1.8); 109 INSERT INTO rt2 VALUES(12, -3, -1.8, 1.8, 3); 110 111 INSERT INTO rt2 VALUES(13, -15, 15, 1.8, 2.2); 112 INSERT INTO rt2 VALUES(14, -15, 15, -2.2, -1.8); 113 INSERT INTO rt2 VALUES(15, 1.8, 2.2, -15, 15); 114 INSERT INTO rt2 VALUES(16, -2.2, -1.8, -15, 15); 115 116 INSERT INTO rt2 VALUES(17, -100, 100, -100, 100); 117 } {} 118 119 do_execsql_test rtree9-5.2 { 120 SELECT id FROM rt2 WHERE id MATCH circle(0.0, 0.0, 2.0); 121 } {1 2 3 4 13 14 15 16 17} 122 123 do_execsql_test rtree9-5.3 { 124 UPDATE rt2 SET xmin=xmin+5, ymin=ymin+5, xmax=xmax+5, ymax=ymax+5; 125 SELECT id FROM rt2 WHERE id MATCH circle(5.0, 5.0, 2.0); 126 } {1 2 3 4 13 14 15 16 17} 127 do_rtree_integrity_test rtree9-5.4 rt2 128 129 finish_test