diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt new file mode 100644 index 0000000000..e5802502d5 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt @@ -0,0 +1,5 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message + +import org.junit.Assert.* + +class MessagePacketTest \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt index 9d7ba06d0c..b1460fdb80 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/PayloadSplitJoinTest.kt @@ -7,8 +7,8 @@ import org.junit.Test import java.util.* class PayloadSplitJoinTest { + private val random = Random(42) - val random = Random(42) @Test fun testSplitAndJoinBack() { for (s in 0..250) { val payload = ByteArray(s) diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncodingTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncodingTest.kt new file mode 100644 index 0000000000..03800217b1 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncodingTest.kt @@ -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()) + } +} \ No newline at end of file