Skip to content

Commit b9a876c

Browse files
author
Anthony Galea
committed
Add tests for now, to-geojson, includes, intersects, polygon, polygon-sub. Relates to apa512#117.
1 parent 254c437 commit b9a876c

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

test/rethinkdb/core_test.clj

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
(is (= pokemons (sort-by :national_no (r/run (-> (r/table test-table)
127127
(r/between r/minval r/maxval {:right-bound :closed})) conn))))
128128
(is (= (r/run (-> (r/table test-table)
129-
(r/between 80 81 {:right-bound :closed})) conn) [(last pokemons)]))
129+
(r/between 80 81 {:right-bound :closed})) conn) [(last pokemons)]))
130130
(is (= (r/run (-> (r/db test-db)
131131
(r/table test-table)
132132
(r/filter (r/fn [row]
@@ -231,6 +231,10 @@
231231

232232
(deftest dates-and-times
233233
(with-open [conn (r/connect)]
234+
(is (< (-> (t/interval (r/run (r/now) conn) (t/now))
235+
(t/in-seconds))
236+
1))
237+
234238
(are [term result] (= (r/run term conn) result)
235239
(r/time 2014 12 31) (t/date-time 2014 12 31)
236240
(r/time 2014 12 31 "+01:00") (t/from-time-zone
@@ -345,11 +349,20 @@
345349

346350
(deftest geospatial-commands
347351
(with-open [conn (r/connect)]
348-
(is (= {:type "Point" :coordinates [50 50]}
349-
(r/run (r/geojson {:type "Point" :coordinates [50 50]}) conn)))
350-
(is (= "Polygon" (:type (r/run (r/fill (r/line [[50 51] [51 51] [51 52] [50 51]])) conn))))
351-
(is (= 104644.93094219 (r/run (r/distance (r/point 20 20)
352-
(r/circle (r/point 21 20) 2)) conn)))))
352+
(are [term result] (= (r/run term conn) result)
353+
(r/geojson {:type "Point" :coordinates [50 50]}) {:type "Point" :coordinates [50 50]}
354+
(r/fill (r/line [[50 51] [51 51] [51 52] [50 51]])) {:type "Polygon" :coordinates [[[50 51] [51 51] [51 52] [50 51]]]}
355+
(r/distance (r/point 20 20) (r/circle (r/point 21 20) 2)) 104644.93094219
356+
(r/to-geojson (r/point 20 20)) {:type "Point" :coordinates [20 20]}
357+
(r/includes (r/circle (r/point 20 20) 2) (r/point 20 20)) true
358+
(r/includes (r/circle (r/point 20 20) 1) (r/point 40 40)) false
359+
(r/intersects (r/circle (r/point 20 20) 30) (r/point 21 20)) false
360+
(r/intersects (r/circle (r/point 20 20) 10) (r/point 20 20)) true
361+
(r/intersects (r/circle (r/point 20 20) 3) (r/circle (r/point 20 20) 1)) true
362+
(r/intersects (r/circle (r/point 20 20) 3) (r/circle (r/point 21 20) 1)) false
363+
(r/polygon [[50 51] [51 51] [51 52] [50 51]]) {:type "Polygon" :coordinates [[[50 51] [51 51] [51 52] [50 51]]]}
364+
(r/polygon-sub (r/polygon [[0 9] [0 6] [3 6] [3 9]])
365+
(r/polygon [[1 7] [1 8] [2 8] [2 7]])) {:type "Polygon" :coordinates [[[0 9] [0 6] [3 6] [3 9] [0 9]] [[1 7] [1 8] [2 8] [2 7] [1 7]]]})))
353366

354367
(deftest administration
355368
(with-open [conn (r/connect :db test-db)]
@@ -477,7 +490,6 @@
477490
(is (= ""
478491
(:auth-key (ex-data e)))))))
479492

480-
481493
(deftest utf8-compliance
482494
(with-open [conn (r/connect :db test-db)]
483495
(let [doc {:national_no (UUID/randomUUID)

0 commit comments

Comments
 (0)