Rewrites DefaultProfileTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-19 21:20:18 -07:00
parent 77922ca76e
commit c0e8d4932b

View file

@ -1,9 +1,9 @@
package info.nightscout.ui.defaultProfile package info.nightscout.ui.defaultProfile
import com.google.common.truth.Truth.assertThat
import info.nightscout.core.profile.ProfileSealed import info.nightscout.core.profile.ProfileSealed
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.sharedtests.TestBaseWithProfile import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
class DefaultProfileTest : TestBaseWithProfile() { class DefaultProfileTest : TestBaseWithProfile() {
@ -12,18 +12,18 @@ class DefaultProfileTest : TestBaseWithProfile() {
fun profile() { fun profile() {
val dp = DefaultProfile(dateUtil, profileUtil).profile(5, 5.1 / 0.3, 0.0, GlucoseUnit.MMOL) val dp = DefaultProfile(dateUtil, profileUtil).profile(5, 5.1 / 0.3, 0.0, GlucoseUnit.MMOL)
var p = ProfileSealed.Pure(dp!!) var p = ProfileSealed.Pure(dp!!)
Assertions.assertEquals(0.150, p.getBasalTimeFromMidnight(0), 0.001) assertThat(p.getBasalTimeFromMidnight(0)).isWithin(0.001).of(0.150)
Assertions.assertEquals(15.0, p.getIcTimeFromMidnight(0), 0.001) assertThat(p.getIcTimeFromMidnight(0)).isWithin(0.001).of(15.0)
Assertions.assertEquals(11.8, p.getIsfTimeFromMidnight(0), 0.001) 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)!!) 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) assertThat(p.getBasalTimeFromMidnight(0)).isWithin(0.001).of(0.350)
Assertions.assertEquals(15.0, p.getIcTimeFromMidnight(0), 0.001) assertThat(p.getIcTimeFromMidnight(0)).isWithin(0.001).of(15.0)
Assertions.assertEquals(6.8, p.getIsfTimeFromMidnight(0), 0.001) 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)!!) 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) assertThat(p.getBasalTimeFromMidnight(0)).isWithin(0.001).of(0.80)
Assertions.assertEquals(10.0, p.getIcTimeFromMidnight(0), 0.001) assertThat(p.getIcTimeFromMidnight(0)).isWithin(0.001).of(10.0)
Assertions.assertEquals(2.2, p.getIsfTimeFromMidnight(0), 0.001) assertThat(p.getIsfTimeFromMidnight(0)).isWithin(0.001).of(2.2)
} }
} }