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
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)
}
}