Skip to content

Commit 598e88f

Browse files
committed
Port GeoHashTest to Scalatest
1 parent b1aa51d commit 598e88f

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

geoscript/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ libraryDependencies ++=
2121
Seq(
2222
"javax.media" % "jai_core" % "1.1.3",
2323
"org.scala-tools.testing" %% "specs" % "[1.6,1.7)" % "test",
24-
"org.scala-tools.testing" %% "specs" % "[1.6,1.7)" % "test",
24+
"org.scalatest" %% "scalatest" % "1.8" % "test",
2525
"com.lowagie" % "itext" % "2.1.5"
2626
)
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
package org.geoscript
22

3-
import org.specs._
3+
import org.scalatest._, matchers._
44
import GeoHash._
55

6-
class GeoHashTest extends Specification {
6+
class GeoHashTest extends FunSuite with ShouldMatchers {
77
val cases = Seq(
88
(57.64911, 10.40744, 11, "u4pruydqqvj"),
99
(42.6, -5.6, 5, "ezs42")
1010
)
1111

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)
1715
}
16+
}
1817

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))
2525
}
2626
}
2727
}

0 commit comments

Comments
 (0)