Rewrites InputBgTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-04 20:45:27 -07:00
parent 06b219aade
commit 23372a3167

View file

@ -2,7 +2,7 @@ package app.aaps.plugins.automation.elements
import app.aaps.core.interfaces.db.GlucoseUnit import app.aaps.core.interfaces.db.GlucoseUnit
import app.aaps.plugins.automation.triggers.TriggerTestBase import app.aaps.plugins.automation.triggers.TriggerTestBase
import org.junit.jupiter.api.Assertions import com.google.common.truth.Truth.assertThat
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.Mockito.`when` import org.mockito.Mockito.`when`
@ -12,12 +12,12 @@ class InputBgTest : TriggerTestBase() {
@Test @Test
fun setValueTest() { fun setValueTest() {
var i: InputBg = InputBg(profileFunction).setUnits(GlucoseUnit.MMOL).setValue(5.0) var i: InputBg = InputBg(profileFunction).setUnits(GlucoseUnit.MMOL).setValue(5.0)
Assertions.assertEquals(5.0, i.value, 0.01) assertThat(i.value).isWithin(0.01).of(5.0)
Assertions.assertEquals(InputBg.MMOL_MIN, i.minValue, 0.01) assertThat(i.minValue).isWithin(0.01).of(InputBg.MMOL_MIN)
i = InputBg(profileFunction).setValue(100.0).setUnits(GlucoseUnit.MGDL) i = InputBg(profileFunction).setValue(100.0).setUnits(GlucoseUnit.MGDL)
Assertions.assertEquals(100.0, i.value, 0.01) assertThat(i.value).isWithin(0.01).of(100.0)
Assertions.assertEquals(InputBg.MGDL_MIN, i.minValue, 0.01) assertThat(i.minValue).isWithin(0.01).of(InputBg.MGDL_MIN)
Assertions.assertEquals(GlucoseUnit.MGDL, i.units) assertThat(i.units).isEqualTo(GlucoseUnit.MGDL)
} }
@BeforeEach @BeforeEach