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/rtreeH.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 / rtreeH.test` 122 lines ยท 4087 bytes Raw Blame History 1 # 2018-05-16 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 the 12 # auxiliary column mechanism. 13 14 if {![info exists testdir]} { 15 set testdir [file join [file dirname [info script]] .. .. test] 16 } 17 source [file join [file dirname [info script]] rtree_util.tcl] 18 source $testdir/tester.tcl 19 ifcapable !rtree { finish_test ; return } 20 21 do_execsql_test rtreeH-100 { 22 CREATE VIRTUAL TABLE t1 USING rtree(id,x0,x1,y0,y1,+label,+other); 23 INSERT INTO t1(x0,x1,y0,y1,label) VALUES 24 (0,10,0,10,'lower-left corner'), 25 (0,10,90,100,'upper-left corner'), 26 (90,100,0,10,'lower-right corner'), 27 (90,100,90,100,'upper-right corner'), 28 (40,60,40,60,'center'), 29 (0,5,0,100,'left edge'), 30 (95,100,0,100,'right edge'), 31 (0,100,0,5,'bottom edge'), 32 (0,100,95,100,'top edge'), 33 (0,100,0,100,'the whole thing'), 34 (0,50,0,100,'left half'), 35 (51,100,0,100,'right half'), 36 (0,100,0,50,'bottom half'), 37 (0,100,51,100,'top half'); 38 } {} 39 do_execsql_test rtreeH-101 { 40 SELECT * FROM t1_rowid ORDER BY rowid 41 } {1 1 {lower-left corner} {} 2 1 {upper-left corner} {} 3 1 {lower-right corner} {} 4 1 {upper-right corner} {} 5 1 center {} 6 1 {left edge} {} 7 1 {right edge} {} 8 1 {bottom edge} {} 9 1 {top edge} {} 10 1 {the whole thing} {} 11 1 {left half} {} 12 1 {right half} {} 13 1 {bottom half} {} 14 1 {top half} {}} 42 43 do_execsql_test rtreeH-102 { 44 SELECT * FROM t1 WHERE rowid=5; 45 } {5 40.0 60.0 40.0 60.0 center {}} 46 do_execsql_test rtreeH-102b { 47 SELECT * FROM t1 WHERE rowid=5.0; 48 } {5 40.0 60.0 40.0 60.0 center {}} 49 do_execsql_test rtreeH-102c { 50 SELECT * FROM t1 WHERE rowid='5'; 51 } {5 40.0 60.0 40.0 60.0 center {}} 52 do_execsql_test rtreeH-102d { 53 SELECT * FROM t1 WHERE rowid='0005'; 54 } {5 40.0 60.0 40.0 60.0 center {}} 55 do_execsql_test rtreeH-102e { 56 SELECT * FROM t1 WHERE rowid='+5.0e+0'; 57 } {5 40.0 60.0 40.0 60.0 center {}} 58 do_execsql_test rtreeH-103 { 59 SELECT * FROM t1 WHERE label='center'; 60 } {5 40.0 60.0 40.0 60.0 center {}} 61 62 do_execsql_test rtreeH-104 { 63 SELECT * FROM t1 WHERE rowid='+5.0e+0x'; 64 } {} 65 do_execsql_test rtreeH-105 { 66 SELECT * FROM t1 WHERE rowid=x'35'; 67 } {} 68 do_execsql_test rtreeH-106 { 69 SELECT * FROM t1 WHERE rowid=null; 70 } {} 71 72 73 do_rtree_integrity_test rtreeH-110 t1 74 75 do_execsql_test rtreeH-120 { 76 SELECT label FROM t1 WHERE x1<=50 ORDER BY id 77 } {{lower-left corner} {upper-left corner} {left edge} {left half}} 78 do_execsql_test rtreeH-121 { 79 SELECT label FROM t1 WHERE x1<=50 AND label NOT LIKE '%corner%' ORDER BY id 80 } {{left edge} {left half}} 81 82 do_execsql_test rtreeH-200 { 83 WITH RECURSIVE 84 c1(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c1 WHERE x<99), 85 c2(y) AS (VALUES(0) UNION ALL SELECT y+1 FROM c2 WHERE y<99) 86 INSERT INTO t1(id, x0,x1,y0,y1,label) 87 SELECT 1000+x+y*100, x, x+1, y, y+1, printf('box-%d,%d',x,y) FROM c1, c2; 88 } {} 89 90 do_execsql_test rtreeH-210 { 91 SELECT label FROM t1 WHERE x0>=48 AND x1<=50 AND y0>=48 AND y1<=50 92 ORDER BY id; 93 } {box-48,48 box-49,48 box-48,49 box-49,49} 94 95 do_execsql_test rtreeH-300 { 96 UPDATE t1 SET label='x'||label 97 WHERE x0>=49 AND x1<=50 AND y0>=49 AND y1<=50; 98 SELECT label FROM t1 WHERE x0>=48 AND x1<=50 AND y0>=48 AND y1<=50 99 ORDER BY id; 100 } {box-48,48 box-49,48 box-48,49 xbox-49,49} 101 102 #------------------------------------------------------------------------- 103 reset_db 104 do_execsql_test rtreeH-300 { 105 CREATE TABLE t0(c0); 106 INSERT INTO t0(c0) VALUES (NULL); 107 INSERT INTO t0(c0) VALUES (1); 108 CREATE VIRTUAL TABLE t1 USING rtree(c0, c1, c2, +c3 BLOB ); 109 INSERT INTO t1(c2, c3, c0) VALUES (1, 2, 1); 110 } 111 112 do_execsql_test rtreeH-310 { 113 SELECT 1 FROM t1 WHERE t1.c3; 114 } {1} 115 116 do_execsql_test rtreeH-320 { 117 SELECT * FROM t0 WHERE NOT EXISTS ( 118 SELECT 1 FROM t1 WHERE t1.c3 OR t0.c0 ISNULL 119 ); 120 } {} 121 122 finish_test