iobplugin tests
This commit is contained in:
parent
c98ffb2df1
commit
1b6e54f8a8
2 changed files with 26 additions and 2 deletions
|
@ -351,11 +351,11 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Long findPreviousTimeFromBucketedData(long time) {
|
public Long findPreviousTimeFromBucketedData(long time) {
|
||||||
if (bucketed_data == null)
|
if (bucketed_data == null)
|
||||||
return null;
|
return null;
|
||||||
for (int index = 0; index < bucketed_data.size(); index++) {
|
for (int index = 0; index < bucketed_data.size(); index++) {
|
||||||
if (bucketed_data.get(index).date < time)
|
if (bucketed_data.get(index).date <= time)
|
||||||
return bucketed_data.get(index).date;
|
return bucketed_data.get(index).date;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -242,6 +242,30 @@ public class IobCobCalculatorPluginTest {
|
||||||
Assert.assertEquals(null, iobCobCalculatorPlugin.findOlder(T.mins(4).msecs()));
|
Assert.assertEquals(null, iobCobCalculatorPlugin.findOlder(T.mins(4).msecs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void findPreviousTimeFromBucketedDataTest() {
|
||||||
|
List<BgReading> bgReadingList = new ArrayList<>();
|
||||||
|
|
||||||
|
iobCobCalculatorPlugin.setBgReadings(bgReadingList);
|
||||||
|
iobCobCalculatorPlugin.createBucketedData();
|
||||||
|
Assert.assertEquals(null, iobCobCalculatorPlugin.findPreviousTimeFromBucketedData(1000));
|
||||||
|
|
||||||
|
// Super data should not be touched
|
||||||
|
bgReadingList.clear();
|
||||||
|
bgReadingList.add(new BgReading().date(T.mins(20).msecs()).value(100));
|
||||||
|
bgReadingList.add(new BgReading().date(T.mins(15).msecs()).value(100));
|
||||||
|
bgReadingList.add(new BgReading().date(T.mins(10).msecs()).value(100));
|
||||||
|
bgReadingList.add(new BgReading().date(T.mins(5).msecs()).value(100));
|
||||||
|
|
||||||
|
iobCobCalculatorPlugin.setBgReadings(bgReadingList);
|
||||||
|
iobCobCalculatorPlugin.createBucketedData();
|
||||||
|
|
||||||
|
Assert.assertEquals(null, iobCobCalculatorPlugin.findPreviousTimeFromBucketedData(T.mins(4).msecs()));
|
||||||
|
Assert.assertEquals((Long)T.mins(5).msecs(), iobCobCalculatorPlugin.findPreviousTimeFromBucketedData(T.mins(6).msecs()));
|
||||||
|
Assert.assertEquals((Long)T.mins(20).msecs(), iobCobCalculatorPlugin.findPreviousTimeFromBucketedData(T.mins(20).msecs()));
|
||||||
|
Assert.assertEquals((Long)T.mins(20).msecs(), iobCobCalculatorPlugin.findPreviousTimeFromBucketedData(T.mins(25).msecs()));
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void doMock() {
|
public void doMock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
|
|
Loading…
Reference in a new issue