Rewrites PayloadSplitterTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-08 19:45:45 -07:00
parent 369c876d49
commit 16d0f562c7

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message
import com.google.common.truth.Truth.assertThat
import com.google.crypto.tink.subtle.Hex import com.google.crypto.tink.subtle.Hex
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadSplitter import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadSplitter
import info.nightscout.core.utils.toHex import info.nightscout.core.utils.toHex
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
class PayloadSplitterTest { class PayloadSplitterTest {
@ -16,10 +16,10 @@ class PayloadSplitterTest {
val splitter = PayloadSplitter(payload) val splitter = PayloadSplitter(payload)
val packets = splitter.splitInPackets() val packets = splitter.splitInPackets()
Assertions.assertEquals(packets.size, 2) assertThat(packets).hasSize(2)
Assertions.assertEquals(f1, packets[0].toByteArray().toHex()) assertThat(packets[0].toByteArray().toHex()).isEqualTo(f1)
val p2 = packets[1].toByteArray() val p2 = packets[1].toByteArray()
Assertions.assertTrue(p2.size >= 10) assertThat(p2.size).isAtLeast(10)
Assertions.assertEquals(f2.subSequence(0, 20), p2.copyOfRange(0, 10).toHex()) assertThat(p2.copyOfRange(0, 10).toHex()).isEqualTo(f2.subSequence(0, 20))
} }
} }