diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java index 82630b81ae..f067b69670 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java @@ -284,7 +284,7 @@ public class IobCobCalculatorPlugin extends PluginBase { } // Normalize bucketed data - for (int i = bucketed_data.size() - 2; i > 0; i--) { + for (int i = bucketed_data.size() - 2; i >= 0; i--) { BgReading current = bucketed_data.get(i); BgReading previous = bucketed_data.get(i + 1); long msecDiff = current.date - previous.date; diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/IobCobCalculatorPlugin/IobCobCalculatorPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/IobCobCalculatorPlugin/IobCobCalculatorPluginTest.java index 7fde0b0465..d89e637557 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/IobCobCalculatorPlugin/IobCobCalculatorPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/IobCobCalculatorPlugin/IobCobCalculatorPluginTest.java @@ -146,11 +146,12 @@ public class IobCobCalculatorPluginTest { bgReadingList.add(new BgReading().date(T.mins(15).msecs() + T.secs(10).msecs()).value(100)); bgReadingList.add(new BgReading().date(T.mins(10).msecs() + T.secs(10).msecs()).value(100)); bgReadingList.add(new BgReading().date(T.mins(5).msecs() - T.secs(10).msecs()).value(100)); + bgReadingList.add(new BgReading().date(T.mins(0).msecs()).value(100)); iobCobCalculatorPlugin.setBgReadings(bgReadingList); iobCobCalculatorPlugin.createBucketedData(); - Assert.assertEquals(false, iobCobCalculatorPlugin.isAbout5minData()); // too much drift + Assert.assertEquals(true, iobCobCalculatorPlugin.isAbout5minData()); Assert.assertEquals(T.mins(20).msecs(), iobCobCalculatorPlugin.getBucketedData().get(0).date); Assert.assertEquals(T.mins(15).msecs(), iobCobCalculatorPlugin.getBucketedData().get(1).date); Assert.assertEquals(T.mins(10).msecs(), iobCobCalculatorPlugin.getBucketedData().get(2).date);