kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
fix device version parsing and confirm it works with SHAs
rodzic
041a04afc1
commit
18d526166f
|
@ -27,7 +27,7 @@ data class DeviceVersion(val asString: String) : Comparable<DeviceVersion>, Logg
|
|||
Regex("(\\d{1,2}).(\\d{1,2}).(\\d{1,2})").find(s)
|
||||
?: throw Exception("Can't parse version $s")
|
||||
val (major, minor, build) = match.destructured
|
||||
return major.toInt() * 1000 + minor.toInt() * 100 + build.toInt()
|
||||
return major.toInt() * 10000 + minor.toInt() * 100 + build.toInt()
|
||||
}
|
||||
|
||||
override fun compareTo(other: DeviceVersion): Int = asInt - other.asInt
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.geeksville.mesh.model
|
||||
|
||||
import android.net.Uri
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class DeviceVersionTest {
|
||||
/** make sure we match the python and device code behavior */
|
||||
@Test
|
||||
fun canParse() {
|
||||
|
||||
assertEquals(10000, DeviceVersion("1.0.0").asInt)
|
||||
assertEquals(10101, DeviceVersion("1.1.1").asInt)
|
||||
assertEquals(12357, DeviceVersion("1.23.57").asInt)
|
||||
assertEquals(12357, DeviceVersion("1.23.57.abde123").asInt)
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue