Enhance insulin plugin test

This commit is contained in:
Markus M. May 2018-01-30 19:52:57 +01:00
parent d4365a2352
commit a6f65f5d33

View file

@ -47,11 +47,33 @@ public class InsulinOrefBasePluginTest extends InsulinOrefBasePlugin {
assertEquals(expected, this.iobCalcForTreatment(treatment, 0, 0d)); assertEquals(expected, this.iobCalcForTreatment(treatment, 0, 0d));
this.peak = 30; this.peak = 30;
this.dia = 4;
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
// check directly after bolus
treatment.date = time;
treatment.insulin = 10d;
assertEquals(10d, this.iobCalcForTreatment(treatment, time).iobContrib, 0.1);
// check after 1 hour
treatment.date = time - 1 * 60 * 60 * 1000; // 1 hour treatment.date = time - 1 * 60 * 60 * 1000; // 1 hour
treatment.insulin = 10d; treatment.insulin = 10d;
assertEquals(3.92, this.iobCalcForTreatment(treatment, time).iobContrib, 0.1); assertEquals(3.92, this.iobCalcForTreatment(treatment, time).iobContrib, 0.1);
// check after 2 hour
treatment.date = time - 2 * 60 * 60 * 1000; // 1 hour
treatment.insulin = 10d;
assertEquals(0.77, this.iobCalcForTreatment(treatment, time).iobContrib, 0.1);
// check after 3 hour
treatment.date = time - 3 * 60 * 60 * 1000; // 1 hour
treatment.insulin = 10d;
assertEquals(0.10, this.iobCalcForTreatment(treatment, time).iobContrib, 0.1);
// check after dia
treatment.date = time - 4 * 60 * 60 * 1000;
treatment.insulin = 10d;
assertEquals(0d, this.iobCalcForTreatment(treatment, time).iobContrib, 0.1);
} }