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