dash ble: add tests for StringLengthPrefixEncodingTest
We tested this part with a real pod and confirmed that it's working
This commit is contained in:
parent
5f71e1b27f
commit
eda52857e5
3 changed files with 28 additions and 1 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
class MessagePacketTest
|
|
@ -7,8 +7,8 @@ import org.junit.Test
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class PayloadSplitJoinTest {
|
class PayloadSplitJoinTest {
|
||||||
|
private val random = Random(42)
|
||||||
|
|
||||||
val random = Random(42)
|
|
||||||
@Test fun testSplitAndJoinBack() {
|
@Test fun testSplitAndJoinBack() {
|
||||||
for (s in 0..250) {
|
for (s in 0..250) {
|
||||||
val payload = ByteArray(s)
|
val payload = ByteArray(s)
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
|
||||||
|
|
||||||
|
import com.google.crypto.tink.subtle.Hex
|
||||||
|
import info.nightscout.androidaps.utils.extensions.toHex
|
||||||
|
import org.junit.Assert.*
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class StringLengthPrefixEncodingTest {
|
||||||
|
private val p0Payload = Hex.decode("50,30,3d,00,01,a5".replace(",","")) // from logs
|
||||||
|
private val p0Content = Hex.decode("a5")
|
||||||
|
|
||||||
|
@Test fun testFormatKeysP0() {
|
||||||
|
val payload = StringLengthPrefixEncoding.formatKeys(arrayOf("P0="), arrayOf(p0Content))
|
||||||
|
assertEquals(p0Payload.toHex(), payload.toHex())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun testParseKeysP0() {
|
||||||
|
val parsed = StringLengthPrefixEncoding.parseKeys(arrayOf("P0="), p0Payload)
|
||||||
|
assertEquals(parsed.size, 1)
|
||||||
|
assertEquals(parsed[0].toHex(), p0Content.toHex())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue