fix and add test
This commit is contained in:
parent
72a8bbfc75
commit
c7c8aea65c
|
@ -44,11 +44,12 @@ object DetailedBolusInfoStorage {
|
|||
// If not found, use last record if amount is the same
|
||||
if (store.size > 0) {
|
||||
val d = store[store.size - 1]
|
||||
if (abs(d.insulin - bolus) < 0.01)
|
||||
if (abs(d.insulin - bolus) < 0.01) {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Using LAST & removing bolus info: $d")
|
||||
store.removeAt(store.size - 1)
|
||||
return d
|
||||
store.removeAt(store.size - 1)
|
||||
return d
|
||||
}
|
||||
}
|
||||
//Not found
|
||||
if (L.isEnabled(L.PUMP))
|
||||
|
|
|
@ -82,6 +82,11 @@ class DetailedBolusInfoStorageTest {
|
|||
d = DetailedBolusInfoStorage.findDetailedBolusInfo(1070000, 4.0)
|
||||
assertNull(d)
|
||||
assertEquals(3, DetailedBolusInfoStorage.store.size)
|
||||
// Use last, if bolus size is the same
|
||||
setUp()
|
||||
d = DetailedBolusInfoStorage.findDetailedBolusInfo(1070000, 5.0)
|
||||
assertEquals(5.0, d!!.insulin, 0.01)
|
||||
assertEquals(2, DetailedBolusInfoStorage.store.size)
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue