Source

clojure-geohash / test / geohash / test / core.clj

(ns geohash.test.core
  (:use [geohash.core])
  (:use [clojure.test]))
(set! *warn-on-reflection* true)
(deftest test-encode 
  (is (= "ww8p1r4t8" (encode 37.8324 112.5584)))
  (is (= "wtsnstbgzys5" (encode 32.112343 118.324122 12))))

(deftest test-decode
  (let [geodata (decode "ww8p1r4t8")]
    (is (< (Math/abs (- (:lat geodata) 37.8324)) 0.0001))
    (is (< (Math/abs (- (:lon geodata) 112.5584)) 0.0001))))