@@ -573,6 +573,52 @@ class RecommendBolusTests: XCTestCase {
573
573
}
574
574
}
575
575
576
+ func testStartBelowSuspendThresholdEndHigh( ) {
577
+ // 60 - 200 mg/dL
578
+ let glucose = loadGlucoseValueFixture ( " recommend_temp_basal_start_low_end_high " )
579
+
580
+ let dose = glucose. recommendedBolus (
581
+ to: glucoseTargetRange,
582
+ at: glucose. first!. startDate,
583
+ suspendThreshold: HKQuantity ( unit: . milligramsPerDeciliter( ) , doubleValue: 70 ) ,
584
+ sensitivity: insulinSensitivitySchedule,
585
+ model: insulinModel,
586
+ pendingInsulin: 0 ,
587
+ maxBolus: maxBolus
588
+ )
589
+
590
+ XCTAssertEqual ( 0 , dose. amount)
591
+
592
+ if case BolusRecommendationNotice . glucoseBelowSuspendThreshold( let glucose) = dose. notice! {
593
+ XCTAssertEqual ( glucose. quantity. doubleValue ( for: . milligramsPerDeciliter( ) ) , 60 )
594
+ } else {
595
+ XCTFail ( " Expected currentGlucoseBelowTarget, but got \( dose. notice!) " )
596
+ }
597
+ }
598
+
599
+ func testStartLowNoSuspendThresholdEndHigh( ) {
600
+ // 60 - 200 mg/dL
601
+ let glucose = loadGlucoseValueFixture ( " recommend_temp_basal_start_low_end_high " )
602
+
603
+ let dose = glucose. recommendedBolus (
604
+ to: glucoseTargetRange,
605
+ at: glucose. first!. startDate,
606
+ suspendThreshold: nil , // Expected to default to 90
607
+ sensitivity: insulinSensitivitySchedule,
608
+ model: insulinModel,
609
+ pendingInsulin: 0 ,
610
+ maxBolus: maxBolus
611
+ )
612
+
613
+ XCTAssertEqual ( 0 , dose. amount)
614
+
615
+ if case BolusRecommendationNotice . glucoseBelowSuspendThreshold( let glucose) = dose. notice! {
616
+ XCTAssertEqual ( glucose. quantity. doubleValue ( for: . milligramsPerDeciliter( ) ) , 60 )
617
+ } else {
618
+ XCTFail ( " Expected currentGlucoseBelowTarget, but got \( dose. notice!) " )
619
+ }
620
+ }
621
+
576
622
func testDroppingBelowRangeThenRising( ) {
577
623
let glucose = loadGlucoseValueFixture ( " recommend_temp_basal_dropping_then_rising " )
578
624
0 commit comments