From c27c324358fa95676e677e5e1acc0c6492a0f17b Mon Sep 17 00:00:00 2001 From: Sam Spycher Date: Wed, 21 Oct 2020 16:52:13 +0200 Subject: [PATCH] fix testSetTempBasalPercent for input validation --- .../pump/omnipod/OmnipodPumpPluginTest.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPluginTest.java b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPluginTest.java index 64f7f48728..e2b4cd31ec 100644 --- a/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPluginTest.java +++ b/omnipod/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPluginTest.java @@ -89,7 +89,7 @@ public class OmnipodPumpPluginTest { PumpEnactResult result2 = plugin.setTempBasalPercent(5000, 30000, profile, false); PumpEnactResult result3 = plugin.setTempBasalPercent(0, 30, profile, false); PumpEnactResult result4 = plugin.setTempBasalPercent(0, 0, profile, false); - PumpEnactResult result5 = plugin.setTempBasalPercent(-50, -1, profile, false); + PumpEnactResult result5 = plugin.setTempBasalPercent(-50, 60, profile, false); // Then return correct values assertEquals(result1.absolute, 0.4d, 0.01d); assertEquals(result1.duration, 30); @@ -97,22 +97,22 @@ public class OmnipodPumpPluginTest { assertEquals(result2.duration, 30000); assertEquals(result3.absolute, 0d, 0.01d); assertEquals(result3.duration, 30); - assertEquals(result4.absolute, 0d, 0.01d); - assertEquals(result4.duration, 0); + assertEquals(result4.absolute, -1d, 0.01d); + assertEquals(result4.duration, -1); // this is validated downstream, see TempBasalExtraCommand assertEquals(result5.absolute, -0.25d, 0.01d); - assertEquals(result5.duration, -1); + assertEquals(result5.duration, 60); // Given zero basal when(profile.getBasal()).thenReturn(0d); // When - result1 = plugin.setTempBasalPercent(8000, 10, profile, false); - result2 = plugin.setTempBasalPercent(0, 00, profile, false); + result1 = plugin.setTempBasalPercent(8000, 90, profile, false); + result2 = plugin.setTempBasalPercent(0, 0, profile, false); // Then return zero values assertEquals(result1.absolute, 0d, 0.01d); - assertEquals(result1.duration, 10); - assertEquals(result2.absolute, 0d, 0.01d); - assertEquals(result2.duration, 0); + assertEquals(result1.duration, 90); + assertEquals(result2.absolute, -1d, 0.01d); + assertEquals(result2.duration, -1); // Given unhealthy basal when(profile.getBasal()).thenReturn(500d); @@ -125,18 +125,18 @@ public class OmnipodPumpPluginTest { // Given weird basal when(profile.getBasal()).thenReturn(1.234567d); // When treatment - result1 = plugin.setTempBasalPercent(280, 500, profile, false); + result1 = plugin.setTempBasalPercent(280, 600, profile, false); // Then return sane values assertEquals(result1.absolute, 3.4567876, 0.01d); - assertEquals(result1.duration, 500); + assertEquals(result1.duration, 600); // Given negative basal when(profile.getBasal()).thenReturn(-1.234567d); // When treatment - result1 = plugin.setTempBasalPercent(280, 500, profile, false); + result1 = plugin.setTempBasalPercent(280, 510, profile, false); // Then return negative value (this is validated further downstream, see TempBasalExtraCommand) assertEquals(result1.absolute, -3.4567876, 0.01d); - assertEquals(result1.duration, 500); + assertEquals(result1.duration, 510); } }