Rewrites DecimalFormatterTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-19 22:41:56 -07:00
parent 7a0635b6a8
commit 8b3e39420e

View file

@ -1,9 +1,9 @@
package info.nightscout.implementation.utils package info.nightscout.implementation.utils
import com.google.common.truth.Truth.assertThat
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBase import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.mockito.Mock import org.mockito.Mock
@ -20,22 +20,22 @@ class DecimalFormatterTest : TestBase() {
} }
@Test fun to0DecimalTest() { @Test fun to0DecimalTest() {
Assertions.assertEquals("1", sut.to0Decimal(1.33).replace(",", ".")) assertThat(sut.to0Decimal(1.33).replace(",", ".")).isEqualTo("1")
Assertions.assertEquals("1U", sut.to0Decimal(1.33, "U").replace(",", ".")) assertThat(sut.to0Decimal(1.33, "U").replace(",", ".")).isEqualTo("1U")
} }
@Test fun to1DecimalTest() { @Test fun to1DecimalTest() {
Assertions.assertEquals("1.3", sut.to1Decimal(1.33).replace(",", ".")) assertThat(sut.to1Decimal(1.33).replace(",", ".")).isEqualTo("1.3")
Assertions.assertEquals("1.3U", sut.to1Decimal(1.33, "U").replace(",", ".")) assertThat(sut.to1Decimal(1.33, "U").replace(",", ".")).isEqualTo("1.3U")
} }
@Test fun to2DecimalTest() { @Test fun to2DecimalTest() {
Assertions.assertEquals("1.33", sut.to2Decimal(1.3333).replace(",", ".")) assertThat(sut.to2Decimal(1.3333).replace(",", ".")).isEqualTo("1.33")
Assertions.assertEquals("1.33U", sut.to2Decimal(1.3333, "U").replace(",", ".")) assertThat(sut.to2Decimal(1.3333, "U").replace(",", ".")).isEqualTo("1.33U")
} }
@Test fun to3DecimalTest() { @Test fun to3DecimalTest() {
Assertions.assertEquals("1.333", sut.to3Decimal(1.3333).replace(",", ".")) assertThat(sut.to3Decimal(1.3333).replace(",", ".")).isEqualTo("1.333")
Assertions.assertEquals("1.333U", sut.to3Decimal(1.3333, "U").replace(",", ".")) assertThat(sut.to3Decimal(1.3333, "U").replace(",", ".")).isEqualTo("1.333U")
} }
} }