From 82731361c6b66f4f558fca988c7756908b6064bf Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sun, 8 Oct 2023 16:42:05 -0700 Subject: [PATCH] Rewrites WriteCommandPacketsTest with matchers Issue #2745 --- .../medtrum/comm/WriteCommandPacketsTest.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/WriteCommandPacketsTest.kt b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/WriteCommandPacketsTest.kt index 52e62336e3..848a54140e 100644 --- a/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/WriteCommandPacketsTest.kt +++ b/pump/medtrum/src/test/java/info/nightscout/pump/medtrum/comm/WriteCommandPacketsTest.kt @@ -1,6 +1,6 @@ package info.nightscout.pump.medtrum.comm -import org.junit.jupiter.api.Assertions +import com.google.common.truth.Truth.assertThat import org.junit.jupiter.api.Test class WriteCommandPacketsTest { @@ -8,20 +8,20 @@ class WriteCommandPacketsTest { @Test fun given14LongCommandExpectOnePacket() { val input = byteArrayOf(5, 2, 0, 0, 0, 0, -21, 57, -122, -56) - val expect = byteArrayOf(14, 5, 0, 0, 2, 0, 0, 0, 0, -21, 57, -122, -56, -93, 0) + val expected = byteArrayOf(14, 5, 0, 0, 2, 0, 0, 0, 0, -21, 57, -122, -56, -93, 0) val sequence = 0 val cmdPackets = WriteCommandPackets(input, sequence) val output = cmdPackets.getNextPacket() - Assertions.assertEquals(expect.contentToString(), output.contentToString()) + assertThat(output.contentToString()).isEqualTo(expected.contentToString()) } @Test fun given41LongCommandExpectThreePackets() { val input = byteArrayOf(18, 0, 12, 0, 3, 0, 1, 30, 32, 3, 16, 14, 0, 0, 1, 7, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -20, 36, 2, 100, -123, 2) - val expect1 = byteArrayOf(41, 18, 0, 1, 0, 12, 0, 3, 0, 1, 30, 32, 3, 16, 14, 0, 0, 1, 7, -121) - val expect2 = byteArrayOf(41, 18, 0, 2, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -3) - val expect3 = byteArrayOf(41, 18, 0, 3, -20, 36, 2, 100, -123, 2, -125, -89) + val expected1 = byteArrayOf(41, 18, 0, 1, 0, 12, 0, 3, 0, 1, 30, 32, 3, 16, 14, 0, 0, 1, 7, -121) + val expected2 = byteArrayOf(41, 18, 0, 2, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -3) + val expected3 = byteArrayOf(41, 18, 0, 3, -20, 36, 2, 100, -123, 2, -125, -89) val sequence = 0 val cmdPackets = WriteCommandPackets(input, sequence) @@ -31,10 +31,10 @@ class WriteCommandPacketsTest { val output4 = cmdPackets.getNextPacket() - Assertions.assertEquals(expect1.contentToString(), output1.contentToString()) - Assertions.assertEquals(expect2.contentToString(), output2.contentToString()) - Assertions.assertEquals(expect3.contentToString(), output3.contentToString()) - Assertions.assertNull(output4) - Assertions.assertEquals(true, cmdPackets.allPacketsConsumed()) + assertThat(output1.contentToString()).isEqualTo(expected1.contentToString()) + assertThat(output2.contentToString()).isEqualTo(expected2.contentToString()) + assertThat(output3.contentToString()).isEqualTo(expected3.contentToString()) + assertThat(output4).isNull() + assertThat(cmdPackets.allPacketsConsumed()).isTrue() } }