mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-03 19:27:24 +00:00
Fixed issue #44, now accepting all valid locators
This commit is contained in:
1 parent
68fbd4fc1a
commit
f6ca069896
5 files changed
+58
-114
No files matched your search
@@ -20,13 +20,32 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
package com.rtbishop.look4sat
|
||||
|
||||
import com.rtbishop.look4sat.utility.QthConverter
|
||||
import com.rtbishop.look4sat.utility.round
|
||||
import org.junit.Test
|
||||
|
||||
class QthConverterTest {
|
||||
|
||||
private val converter = QthConverter()
|
||||
|
||||
@Test
|
||||
fun `Given valid QTH returns correct location`() {
|
||||
var result = converter.qthToLocation("io91VL39FX")
|
||||
assert(result?.latitude == 51.4792 && result.longitude == -0.2083)
|
||||
result = converter.qthToLocation("JN58TD")
|
||||
assert(result?.latitude == 48.1458 && result.longitude == 11.6250)
|
||||
result = converter.qthToLocation("gf15vc")
|
||||
assert(result?.latitude == -34.8958 && result.longitude == -56.2083)
|
||||
result = converter.qthToLocation("fm18LW")
|
||||
assert(result?.latitude == 38.9375 && result.longitude == -77.0417)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given invalid QTH returns null`() {
|
||||
var result = converter.qthToLocation("ZZ00zz")
|
||||
assert(result == null)
|
||||
result = converter.qthToLocation("JN58tz")
|
||||
assert(result == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given valid location returns correct QTH`() {
|
||||
assert(converter.locationToQTH(51.4878, -0.2146) == "IO91vl")
|
||||
@@ -40,24 +59,4 @@ class QthConverterTest {
|
||||
assert(converter.locationToQTH(91.0542, -170.1142) == null)
|
||||
assert(converter.locationToQTH(89.0542, -240.1142) == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given valid QTH returns correct location`() {
|
||||
var result = converter.qthToLocation("IO91vl")
|
||||
assert(result?.latitude?.round(4) == 51.4792 && result.longitude.round(4) == -0.2083)
|
||||
result = converter.qthToLocation("JN58TD")
|
||||
assert(result?.latitude?.round(4) == 48.1458 && result.longitude.round(4) == 11.625)
|
||||
result = converter.qthToLocation("gf15vc")
|
||||
assert(result?.latitude?.round(4) == -34.8958 && result.longitude.round(4) == -56.2083)
|
||||
result = converter.qthToLocation("fm18LW")
|
||||
assert(result?.latitude?.round(4) == 38.9375 && result.longitude.round(4) == -77.0417)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given invalid QTH returns correct location`() {
|
||||
var result = converter.qthToLocation("ZZ00zz")
|
||||
assert(result == null)
|
||||
result = converter.qthToLocation("em75KBzz")
|
||||
assert(result == null)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user