parent
842a2d76de
commit
5ad0c2850c
1 changed files with 18 additions and 18 deletions
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.core.extensions
|
||||
|
||||
import app.aaps.shared.tests.TestBaseWithProfile
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import info.nightscout.database.entities.TemporaryBasal
|
||||
import info.nightscout.insulin.InsulinLyumjevPlugin
|
||||
import info.nightscout.interfaces.aps.AutosensResult
|
||||
|
@ -9,7 +10,6 @@ import info.nightscout.interfaces.insulin.Insulin
|
|||
import info.nightscout.interfaces.profile.ProfileFunction
|
||||
import info.nightscout.interfaces.ui.UiInteraction
|
||||
import info.nightscout.shared.utils.T
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.Mock
|
||||
|
@ -35,26 +35,28 @@ class TemporaryBasalExtensionKtTest : TestBaseWithProfile() {
|
|||
fun iobCalc() {
|
||||
val temporaryBasal = TemporaryBasal(timestamp = now - 1, rate = 200.0, isAbsolute = false, duration = T.hours(1).msecs(), type = TemporaryBasal.Type.NORMAL)
|
||||
// there should zero IOB after now
|
||||
Assertions.assertEquals(0.0, temporaryBasal.iobCalc(now, validProfile, insulin).basaliob, 0.01)
|
||||
assertThat(temporaryBasal.iobCalc(now, validProfile, insulin).basaliob).isWithin(0.01).of(0.0)
|
||||
// there should be significant IOB at EB finish
|
||||
Assertions.assertTrue(0.8 < temporaryBasal.iobCalc(now + T.hours(1).msecs(), validProfile, insulin).basaliob)
|
||||
assertThat(temporaryBasal.iobCalc(now + T.hours(1).msecs(), validProfile, insulin).basaliob).isGreaterThan(0.8)
|
||||
// there should be less that 5% after DIA -1
|
||||
Assertions.assertTrue(0.05 > temporaryBasal.iobCalc(now + T.hours(dia.toLong() - 1).msecs(), validProfile, insulin).basaliob)
|
||||
assertThat(temporaryBasal.iobCalc(now + T.hours(dia.toLong() - 1).msecs(), validProfile, insulin).basaliob).isLessThan(0.05)
|
||||
// there should be zero after DIA
|
||||
Assertions.assertEquals(0.0, temporaryBasal.iobCalc(now + T.hours(dia.toLong() + 1).msecs(), validProfile, insulin).basaliob)
|
||||
assertThat(temporaryBasal.iobCalc(now + T.hours(dia.toLong() + 1).msecs(), validProfile, insulin).basaliob).isEqualTo(0.0)
|
||||
// no IOB for invalid record
|
||||
temporaryBasal.isValid = false
|
||||
Assertions.assertEquals(0.0, temporaryBasal.iobCalc(now + T.hours(1).msecs(), validProfile, insulin).basaliob)
|
||||
assertThat(temporaryBasal.iobCalc(now + T.hours(1).msecs(), validProfile, insulin).basaliob).isEqualTo(0.0)
|
||||
|
||||
temporaryBasal.isValid = true
|
||||
val asResult = AutosensResult()
|
||||
// there should zero IOB after now
|
||||
Assertions.assertEquals(0.0, temporaryBasal.iobCalc(now, validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).basaliob, 0.01)
|
||||
assertThat(temporaryBasal.iobCalc(now, validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).basaliob).isWithin(0.01).of(0.0)
|
||||
// there should be significant IOB at EB finish
|
||||
Assertions.assertTrue(0.8 < temporaryBasal.iobCalc(now + T.hours(1).msecs(), validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).basaliob)
|
||||
assertThat(temporaryBasal.iobCalc(now + T.hours(1).msecs(), validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).basaliob).isGreaterThan(
|
||||
0.8
|
||||
)
|
||||
// there should be less that 5% after DIA -1
|
||||
Assertions.assertTrue(
|
||||
0.05 > temporaryBasal.iobCalc(
|
||||
assertThat(
|
||||
temporaryBasal.iobCalc(
|
||||
now + T.hours(dia.toLong() - 1).msecs(),
|
||||
validProfile,
|
||||
asResult,
|
||||
|
@ -63,10 +65,9 @@ class TemporaryBasalExtensionKtTest : TestBaseWithProfile() {
|
|||
true,
|
||||
insulin
|
||||
).basaliob
|
||||
)
|
||||
).isLessThan(0.05)
|
||||
// there should be zero after DIA
|
||||
Assertions.assertEquals(
|
||||
0.0,
|
||||
assertThat(
|
||||
temporaryBasal.iobCalc(
|
||||
now + T.hours(dia.toLong() + 1).msecs(),
|
||||
validProfile,
|
||||
|
@ -76,12 +77,11 @@ class TemporaryBasalExtensionKtTest : TestBaseWithProfile() {
|
|||
true,
|
||||
insulin
|
||||
).basaliob
|
||||
)
|
||||
).isEqualTo(0.0)
|
||||
// no IOB for invalid record
|
||||
temporaryBasal.isValid = false
|
||||
Assertions.assertEquals(
|
||||
0.0,
|
||||
assertThat(
|
||||
temporaryBasal.iobCalc(now + T.hours(1).msecs(), validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).basaliob
|
||||
)
|
||||
).isEqualTo(0.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue