diff options
Diffstat (limited to 'lib/libsqlite3/ext/rtree/rtree1.test')
-rw-r--r-- | lib/libsqlite3/ext/rtree/rtree1.test | 130 |
1 files changed, 46 insertions, 84 deletions
diff --git a/lib/libsqlite3/ext/rtree/rtree1.test b/lib/libsqlite3/ext/rtree/rtree1.test index 0beb16cc949..583b0285076 100644 --- a/lib/libsqlite3/ext/rtree/rtree1.test +++ b/lib/libsqlite3/ext/rtree/rtree1.test @@ -17,7 +17,6 @@ if {![info exists testdir]} { } source [file join [file dirname [info script]] rtree_util.tcl] source $testdir/tester.tcl -set testprefix rtree1 # Test plan: # @@ -33,7 +32,6 @@ set testprefix rtree1 # rtree-8.*: Test constrained scans of r-tree data. # # rtree-12.*: Test that on-conflict clauses are supported. -# rtree-13.*: Test that bug [d2889096e7bdeac6d] has been fixed. # ifcapable !rtree { @@ -106,34 +104,21 @@ for {set nCol 1} {$nCol<[llength $cols]} {incr nCol} { catchsql { DROP TABLE t1 } } -# Like execsql except display output as integer where that can be -# done without loss of information. -# -proc execsql_intout {sql} { - set out {} - foreach term [execsql $sql] { - regsub {\.0$} $term {} term - lappend out $term - } - return $out -} - # Test that it is possible to open an existing database that contains # r-tree tables. # -do_execsql_test rtree-1.4.1a { - CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2); - INSERT INTO t1 VALUES(1, 5.0, 10.0); - SELECT substr(hex(data),1,40) FROM t1_node; -} {00000001000000000000000140A0000041200000} -do_execsql_test rtree-1.4.1b { - INSERT INTO t1 VALUES(2, 15.0, 20.0); +do_test rtree-1.4.1 { + execsql { + CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2); + INSERT INTO t1 VALUES(1, 5.0, 10.0); + INSERT INTO t1 VALUES(2, 15.0, 20.0); + } } {} do_test rtree-1.4.2 { db close sqlite3 db test.db - execsql_intout { SELECT * FROM t1 ORDER BY ii } -} {1 5 10 2 15 20} + execsql { SELECT * FROM t1 ORDER BY ii } +} {1 5.0 10.0 2 15.0 20.0} do_test rtree-1.4.3 { execsql { DROP TABLE t1 } } {} @@ -142,12 +127,12 @@ do_test rtree-1.4.3 { # column names. # do_test rtree-1.5.1 { - execsql_intout { + execsql { CREATE VIRTUAL TABLE t1 USING rtree("the key", "x dim.", "x2'dim"); INSERT INTO t1 VALUES(1, 2, 3); SELECT "the key", "x dim.", "x2'dim" FROM t1; } -} {1 2 3} +} {1 2.0 3.0} do_test rtree-1.5.1 { execsql { DROP TABLE t1 } } {} @@ -176,8 +161,8 @@ do_test rtree-2.1.1 { do_test rtree-2.1.2 { execsql { INSERT INTO t1 VALUES(NULL, 1, 3, 2, 4) } - execsql_intout { SELECT * FROM t1 } -} {1 1 3 2 4} + execsql { SELECT * FROM t1 } +} {1 1.0 3.0 2.0 4.0} do_test rtree-2.1.3 { execsql { INSERT INTO t1 VALUES(NULL, 1, 3, 2, 4) } execsql { SELECT rowid FROM t1 ORDER BY rowid } @@ -216,17 +201,17 @@ do_test rtree-3.1.1 { } } {} do_test rtree-3.1.2 { - execsql_intout { + execsql { INSERT INTO t1 VALUES(5, 1, 3, 2, 4); SELECT * FROM t1; } -} {5 1 3 2 4} +} {5 1.0 3.0 2.0 4.0} do_test rtree-3.1.3 { - execsql_intout { + execsql { INSERT INTO t1 VALUES(6, 2, 6, 4, 8); SELECT * FROM t1; } -} {5 1 3 2 4 6 2 6 4 8} +} {5 1.0 3.0 2.0 4.0 6 2.0 6.0 4.0 8.0} # Test the constraint on the coordinates (c[i]<=c[i+1] where (i%2==0)): do_test rtree-3.2.1 { @@ -243,25 +228,25 @@ do_test rtree-5.1.1 { execsql { CREATE VIRTUAL TABLE t2 USING rtree(ii, x1, x2) } } {} do_test rtree-5.1.2 { - execsql_intout { + execsql { INSERT INTO t2 VALUES(1, 10, 20); INSERT INTO t2 VALUES(2, 30, 40); INSERT INTO t2 VALUES(3, 50, 60); SELECT * FROM t2 ORDER BY ii; } -} {1 10 20 2 30 40 3 50 60} +} {1 10.0 20.0 2 30.0 40.0 3 50.0 60.0} do_test rtree-5.1.3 { - execsql_intout { + execsql { DELETE FROM t2 WHERE ii=2; SELECT * FROM t2 ORDER BY ii; } -} {1 10 20 3 50 60} +} {1 10.0 20.0 3 50.0 60.0} do_test rtree-5.1.4 { - execsql_intout { + execsql { DELETE FROM t2 WHERE ii=1; SELECT * FROM t2 ORDER BY ii; } -} {3 50 60} +} {3 50.0 60.0} do_test rtree-5.1.5 { execsql { DELETE FROM t2 WHERE ii=3; @@ -279,16 +264,16 @@ do_test rtree-6.1.1 { execsql { CREATE VIRTUAL TABLE t3 USING rtree(ii, x1, x2, y1, y2) } } {} do_test rtree-6.1.2 { - execsql_intout { + execsql { INSERT INTO t3 VALUES(1, 2, 3, 4, 5); UPDATE t3 SET x2=5; SELECT * FROM t3; } -} {1 2 5 4 5} +} {1 2.0 5.0 4.0 5.0} do_test rtree-6.1.3 { execsql { UPDATE t3 SET ii = 2 } - execsql_intout { SELECT * FROM t3 } -} {2 2 5 4 5} + execsql { SELECT * FROM t3 } +} {2 2.0 5.0 4.0 5.0} #---------------------------------------------------------------------------- # Test cases rtree-7.* test rename operations. @@ -301,29 +286,29 @@ do_test rtree-7.1.1 { } {} do_test rtree-7.1.2 { execsql { ALTER TABLE t4 RENAME TO t5 } - execsql_intout { SELECT * FROM t5 } -} {1 2 3 4 5 6 7} + execsql { SELECT * FROM t5 } +} {1 2.0 3.0 4.0 5.0 6.0 7.0} do_test rtree-7.1.3 { db close sqlite3 db test.db - execsql_intout { SELECT * FROM t5 } -} {1 2 3 4 5 6 7} + execsql { SELECT * FROM t5 } +} {1 2.0 3.0 4.0 5.0 6.0 7.0} do_test rtree-7.1.4 { execsql { ALTER TABLE t5 RENAME TO 'raisara "one"'''} - execsql_intout { SELECT * FROM "raisara ""one""'" } -} {1 2 3 4 5 6 7} + execsql { SELECT * FROM "raisara ""one""'" } +} {1 2.0 3.0 4.0 5.0 6.0 7.0} do_test rtree-7.1.5 { - execsql_intout { SELECT * FROM 'raisara "one"''' } -} {1 2 3 4 5 6 7} + execsql { SELECT * FROM 'raisara "one"''' } +} {1 2.0 3.0 4.0 5.0 6.0 7.0} do_test rtree-7.1.6 { execsql { ALTER TABLE "raisara ""one""'" RENAME TO "abc 123" } - execsql_intout { SELECT * FROM "abc 123" } -} {1 2 3 4 5 6 7} + execsql { SELECT * FROM "abc 123" } +} {1 2.0 3.0 4.0 5.0 6.0 7.0} do_test rtree-7.1.7 { db close sqlite3 db test.db - execsql_intout { SELECT * FROM "abc 123" } -} {1 2 3 4 5 6 7} + execsql { SELECT * FROM "abc 123" } +} {1 2.0 3.0 4.0 5.0 6.0 7.0} # An error midway through a rename operation. do_test rtree-7.2.1 { @@ -333,8 +318,8 @@ do_test rtree-7.2.1 { catchsql { ALTER TABLE "abc 123" RENAME TO t4 } } {1 {SQL logic error or missing database}} do_test rtree-7.2.2 { - execsql_intout { SELECT * FROM "abc 123" } -} {1 2 3 4 5 6 7} + execsql { SELECT * FROM "abc 123" } +} {1 2.0 3.0 4.0 5.0 6.0 7.0} do_test rtree-7.2.3 { execsql { DROP TABLE t4_node; @@ -345,13 +330,13 @@ do_test rtree-7.2.3 { do_test rtree-7.2.4 { db close sqlite3 db test.db - execsql_intout { SELECT * FROM "abc 123" } -} {1 2 3 4 5 6 7} + execsql { SELECT * FROM "abc 123" } +} {1 2.0 3.0 4.0 5.0 6.0 7.0} do_test rtree-7.2.5 { execsql { DROP TABLE t4_rowid } execsql { ALTER TABLE "abc 123" RENAME TO t4 } - execsql_intout { SELECT * FROM t4 } -} {1 2 3 4 5 6 7} + execsql { SELECT * FROM t4 } +} {1 2.0 3.0 4.0 5.0 6.0 7.0} #---------------------------------------------------------------------------- @@ -437,18 +422,16 @@ do_test rtree-11.2 { # Test on-conflict clause handling. # db_delete_and_reopen -do_execsql_test 12.0.1 { +do_execsql_test 12.0 { CREATE VIRTUAL TABLE t1 USING rtree_i32(idx, x1, x2, y1, y2); INSERT INTO t1 VALUES(1, 1, 2, 3, 4); - SELECT substr(hex(data),1,56) FROM t1_node; -} {00000001000000000000000100000001000000020000000300000004} -do_execsql_test 12.0.2 { INSERT INTO t1 VALUES(2, 2, 3, 4, 5); INSERT INTO t1 VALUES(3, 3, 4, 5, 6); CREATE TABLE source(idx, x1, x2, y1, y2); INSERT INTO source VALUES(5, 8, 8, 8, 8); INSERT INTO source VALUES(2, 7, 7, 7, 7); + } db_save_and_close foreach {tn sql_template testdata} { @@ -514,25 +497,4 @@ foreach {tn sql_template testdata} { db close } } - -#------------------------------------------------------------------------- -# Test that bug [d2889096e7bdeac6d] has been fixed. -# -reset_db -do_execsql_test 13.1 { - CREATE VIRTUAL TABLE t9 USING rtree(id, xmin, xmax); - INSERT INTO t9 VALUES(1,0,0); - INSERT INTO t9 VALUES(2,0,0); - SELECT * FROM t9 WHERE id IN (1, 2); -} {1 0.0 0.0 2 0.0 0.0} - -do_execsql_test 13.2 { - WITH r(x) AS ( - SELECT 1 UNION ALL - SELECT 2 UNION ALL - SELECT 3 - ) - SELECT * FROM r CROSS JOIN t9 WHERE id=x; -} {1 1 0.0 0.0 2 2 0.0 0.0} - finish_test |