From c0e8d4932b31452cce5552ec1e02059b21d6ebcc Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Tue, 19 Sep 2023 21:20:18 -0700 Subject: [PATCH] Rewrites DefaultProfileTest with matchers Issue #2745 --- .../ui/defaultProfile/DefaultProfileTest.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ui/src/test/java/info/nightscout/ui/defaultProfile/DefaultProfileTest.kt b/ui/src/test/java/info/nightscout/ui/defaultProfile/DefaultProfileTest.kt index 3d7a4e8de8..028f3c2f7b 100644 --- a/ui/src/test/java/info/nightscout/ui/defaultProfile/DefaultProfileTest.kt +++ b/ui/src/test/java/info/nightscout/ui/defaultProfile/DefaultProfileTest.kt @@ -1,9 +1,9 @@ package info.nightscout.ui.defaultProfile +import com.google.common.truth.Truth.assertThat import info.nightscout.core.profile.ProfileSealed import info.nightscout.interfaces.GlucoseUnit import info.nightscout.sharedtests.TestBaseWithProfile -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class DefaultProfileTest : TestBaseWithProfile() { @@ -12,18 +12,18 @@ class DefaultProfileTest : TestBaseWithProfile() { fun profile() { val dp = DefaultProfile(dateUtil, profileUtil).profile(5, 5.1 / 0.3, 0.0, GlucoseUnit.MMOL) var p = ProfileSealed.Pure(dp!!) - Assertions.assertEquals(0.150, p.getBasalTimeFromMidnight(0), 0.001) - Assertions.assertEquals(15.0, p.getIcTimeFromMidnight(0), 0.001) - Assertions.assertEquals(11.8, p.getIsfTimeFromMidnight(0), 0.001) + assertThat(p.getBasalTimeFromMidnight(0)).isWithin(0.001).of(0.150) + assertThat(p.getIcTimeFromMidnight(0)).isWithin(0.001).of(15.0) + assertThat(p.getIsfTimeFromMidnight(0)).isWithin(0.001).of(11.8) p = ProfileSealed.Pure(DefaultProfile(dateUtil, profileUtil).profile(7, 10.0 / 0.4, 0.0, GlucoseUnit.MMOL)!!) - Assertions.assertEquals(0.350, p.getBasalTimeFromMidnight(0), 0.001) - Assertions.assertEquals(15.0, p.getIcTimeFromMidnight(0), 0.001) - Assertions.assertEquals(6.8, p.getIsfTimeFromMidnight(0), 0.001) + assertThat(p.getBasalTimeFromMidnight(0)).isWithin(0.001).of(0.350) + assertThat(p.getIcTimeFromMidnight(0)).isWithin(0.001).of(15.0) + assertThat(p.getIsfTimeFromMidnight(0)).isWithin(0.001).of(6.8) p = ProfileSealed.Pure(DefaultProfile(dateUtil, profileUtil).profile(12, 25.0 / 0.5, 0.0, GlucoseUnit.MMOL)!!) - Assertions.assertEquals(0.80, p.getBasalTimeFromMidnight(0), 0.001) - Assertions.assertEquals(10.0, p.getIcTimeFromMidnight(0), 0.001) - Assertions.assertEquals(2.2, p.getIsfTimeFromMidnight(0), 0.001) + assertThat(p.getBasalTimeFromMidnight(0)).isWithin(0.001).of(0.80) + assertThat(p.getIcTimeFromMidnight(0)).isWithin(0.001).of(10.0) + assertThat(p.getIsfTimeFromMidnight(0)).isWithin(0.001).of(2.2) } -} \ No newline at end of file +}