|
1 | 1 | package org.geoscript
|
2 | 2 |
|
3 |
| -import org.specs._ |
| 3 | +import org.scalatest._, matchers._ |
4 | 4 | import GeoHash._
|
5 | 5 |
|
6 |
| -class GeoHashTest extends Specification { |
| 6 | +class GeoHashTest extends FunSuite with ShouldMatchers { |
7 | 7 | val cases = Seq(
|
8 | 8 | (57.64911, 10.40744, 11, "u4pruydqqvj"),
|
9 | 9 | (42.6, -5.6, 5, "ezs42")
|
10 | 10 | )
|
11 | 11 |
|
12 |
| - "The GeoHash examples from Wikipedia" should { |
13 |
| - "produce the cited hashes" in { |
14 |
| - cases.foreach { case (lon, lat, level, hash) => |
15 |
| - geohash(lon, lat, level) must_== (hash) |
16 |
| - } |
| 12 | + test("produce the cited hashes") { |
| 13 | + cases.foreach { case (lon, lat, level, hash) => |
| 14 | + geohash(lon, lat, level) should be(hash) |
17 | 15 | }
|
| 16 | + } |
18 | 17 |
|
19 |
| - "work in reverse" in { |
20 |
| - cases.foreach { case (lon, lat, level, hash) => |
21 |
| - val (actualLon, actualLat) = decode(hash) |
22 |
| - actualLon must beCloseTo(lon, 0.005) |
23 |
| - actualLat must beCloseTo(lat, 0.005) |
24 |
| - } |
| 18 | + test("work in reverse") { |
| 19 | + cases.foreach { case (lon, lat, level, hash) => |
| 20 | + val (actualLon, actualLat) = decode(hash) |
| 21 | + assert(math.abs(actualLon - lon) < 0.005, |
| 22 | + "Actual longitude %f not within tolerance of expected %f" format(actualLon, lon)) |
| 23 | + assert(math.abs(actualLat - lat) < 0.005, |
| 24 | + "Actual latitude %f not within tolerance of expected %f" format(actualLat, lat)) |
25 | 25 | }
|
26 | 26 | }
|
27 | 27 | }
|
0 commit comments