fix tests

This commit is contained in:
Milos Kozak 2020-11-29 11:56:24 +01:00
parent 7bc7388f06
commit 85104c3c9d
2 changed files with 6 additions and 9 deletions

View file

@ -63,10 +63,6 @@ abstract class InsulinOrefBasePlugin(
return profile?.dia ?: MIN_DIA return profile?.dia ?: MIN_DIA
} }
fun iobCalcForTreatment(treatment: Treatment, time: Long): Iob {
return this.iobCalcForTreatment(treatment, time, 0.0)
}
override fun iobCalcForTreatment(treatment: Treatment, time: Long, dia: Double): Iob { override fun iobCalcForTreatment(treatment: Treatment, time: Long, dia: Double): Iob {
val result = Iob() val result = Iob()
val peak = peak val peak = peak

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.insulin
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.data.Iob import info.nightscout.androidaps.data.Iob
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
@ -108,22 +109,22 @@ class InsulinOrefBasePluginTest {
// check directly after bolus // check directly after bolus
treatment.date = time treatment.date = time
treatment.insulin = 10.0 treatment.insulin = 10.0
Assert.assertEquals(10.0, sut.iobCalcForTreatment(treatment, time).iobContrib, 0.1) Assert.assertEquals(10.0, sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib, 0.1)
// check after 1 hour // check after 1 hour
treatment.date = time - 1 * 60 * 60 * 1000 // 1 hour treatment.date = time - 1 * 60 * 60 * 1000 // 1 hour
treatment.insulin = 10.0 treatment.insulin = 10.0
Assert.assertEquals(3.92, sut.iobCalcForTreatment(treatment, time).iobContrib, 0.1) Assert.assertEquals(3.92, sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib, 0.1)
// check after 2 hour // check after 2 hour
treatment.date = time - 2 * 60 * 60 * 1000 // 1 hour treatment.date = time - 2 * 60 * 60 * 1000 // 1 hour
treatment.insulin = 10.0 treatment.insulin = 10.0
Assert.assertEquals(0.77, sut.iobCalcForTreatment(treatment, time).iobContrib, 0.1) Assert.assertEquals(0.77, sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib, 0.1)
// check after 3 hour // check after 3 hour
treatment.date = time - 3 * 60 * 60 * 1000 // 1 hour treatment.date = time - 3 * 60 * 60 * 1000 // 1 hour
treatment.insulin = 10.0 treatment.insulin = 10.0
Assert.assertEquals(0.10, sut.iobCalcForTreatment(treatment, time).iobContrib, 0.1) Assert.assertEquals(0.10, sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib, 0.1)
// check after dia // check after dia
treatment.date = time - 4 * 60 * 60 * 1000 treatment.date = time - 4 * 60 * 60 * 1000
treatment.insulin = 10.0 treatment.insulin = 10.0
Assert.assertEquals(0.0, sut.iobCalcForTreatment(treatment, time).iobContrib, 0.1) Assert.assertEquals(0.0, sut.iobCalcForTreatment(treatment, time, Constants.defaultDIA).iobContrib, 0.1)
} }
} }