Merge pull request #2806 from ryanhaining/assertthat_ui

Rewrites DefaultProfileTest with matchers
This commit is contained in:
Milos Kozak 2023-09-20 13:25:50 +02:00 committed by GitHub
commit 7a95cac727
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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