parent
fea4d39ca7
commit
7a0635b6a8
1 changed files with 18 additions and 18 deletions
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.implementation.pump
|
package info.nightscout.implementation.pump
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.sharedtests.TestBase
|
import info.nightscout.sharedtests.TestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@ class TemporaryBasalStorageTest : TestBase() {
|
||||||
@Test
|
@Test
|
||||||
fun add() {
|
fun add() {
|
||||||
temporaryBasalStorage.store.clear()
|
temporaryBasalStorage.store.clear()
|
||||||
Assertions.assertEquals(0, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).isEmpty()
|
||||||
temporaryBasalStorage.add(info1)
|
temporaryBasalStorage.add(info1)
|
||||||
Assertions.assertEquals(1, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -40,38 +40,38 @@ class TemporaryBasalStorageTest : TestBase() {
|
||||||
// Look for exact bolus
|
// Look for exact bolus
|
||||||
setUp()
|
setUp()
|
||||||
var d = temporaryBasalStorage.findTemporaryBasal(1000000, 4.0)
|
var d = temporaryBasalStorage.findTemporaryBasal(1000000, 4.0)
|
||||||
Assertions.assertEquals(4.0, d!!.rate, 0.01)
|
assertThat(d!!.rate).isWithin(0.01).of(4.0)
|
||||||
Assertions.assertEquals(2, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(2)
|
||||||
// Look for exact bolus
|
// Look for exact bolus
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1000000, 3.0)
|
d = temporaryBasalStorage.findTemporaryBasal(1000000, 3.0)
|
||||||
Assertions.assertEquals(3.0, d!!.rate, 0.01)
|
assertThat(d!!.rate).isWithin(0.01).of(3.0)
|
||||||
Assertions.assertEquals(2, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(2)
|
||||||
// With less rate (bolus not delivered completely). Should return first one matching date
|
// With less rate (bolus not delivered completely). Should return first one matching date
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1000500, 2.0)
|
d = temporaryBasalStorage.findTemporaryBasal(1000500, 2.0)
|
||||||
Assertions.assertEquals(3.0, d!!.rate, 0.01)
|
assertThat(d!!.rate).isWithin(0.01).of(3.0)
|
||||||
Assertions.assertEquals(2, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(2)
|
||||||
// With less rate (bolus not delivered completely). Should return first one matching date
|
// With less rate (bolus not delivered completely). Should return first one matching date
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1000500, 3.5)
|
d = temporaryBasalStorage.findTemporaryBasal(1000500, 3.5)
|
||||||
Assertions.assertEquals(4.0, d!!.rate, 0.01)
|
assertThat(d!!.rate).isWithin(0.01).of(4.0)
|
||||||
Assertions.assertEquals(2, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(2)
|
||||||
// With more rate should return null
|
// With more rate should return null
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1000500, 4.5)
|
d = temporaryBasalStorage.findTemporaryBasal(1000500, 4.5)
|
||||||
Assertions.assertNull(d)
|
assertThat(d).isNull()
|
||||||
Assertions.assertEquals(3, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(3)
|
||||||
// With more than one minute off should return null
|
// With more than one minute off should return null
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1070000, 4.0)
|
d = temporaryBasalStorage.findTemporaryBasal(1070000, 4.0)
|
||||||
Assertions.assertNull(d)
|
assertThat(d).isNull()
|
||||||
Assertions.assertEquals(3, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(3)
|
||||||
// Use last, if bolus size is the same
|
// Use last, if bolus size is the same
|
||||||
setUp()
|
setUp()
|
||||||
d = temporaryBasalStorage.findTemporaryBasal(1070000, 5.0)
|
d = temporaryBasalStorage.findTemporaryBasal(1070000, 5.0)
|
||||||
Assertions.assertEquals(5.0, d!!.rate, 0.01)
|
assertThat(d!!.rate).isWithin(0.01).of(5.0)
|
||||||
Assertions.assertEquals(2, temporaryBasalStorage.store.size)
|
assertThat(temporaryBasalStorage.store).hasSize(2)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue