1
0

rtree5.test 2.0 KB

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