@@ -33,6 +33,8 @@ enum MissedMealTestType {
33
33
case dynamicCarbAutofill
34
34
/// Test case for purely testing the notifications (not the algorithm)
35
35
case notificationTest
36
+ /// Test case for testing the algorithm with settings in mmol/L
37
+ case mmolUser
36
38
}
37
39
38
40
extension MissedMealTestType {
@@ -48,7 +50,7 @@ extension MissedMealTestType {
48
50
return " noisy_cgm_counteraction_effect "
49
51
case . manyMeals, . missedMealWithCOB:
50
52
return " realistic_report_counteraction_effect "
51
- case . dynamicCarbAutofill:
53
+ case . dynamicCarbAutofill, . mmolUser :
52
54
return " dynamic_autofill_counteraction_effect "
53
55
}
54
56
}
@@ -65,7 +67,7 @@ extension MissedMealTestType {
65
67
return Self . dateFormatter. date ( from: " 2022-10-19T19:50:15 " ) !
66
68
case . manyMeals:
67
69
return Self . dateFormatter. date ( from: " 2022-10-19T21:50:15 " ) !
68
- case . dynamicCarbAutofill:
70
+ case . dynamicCarbAutofill, . mmolUser :
69
71
return Self . dateFormatter. date ( from: " 2022-10-17T07:51:09 " ) !
70
72
}
71
73
}
@@ -78,7 +80,7 @@ extension MissedMealTestType {
78
80
return Self . dateFormatter. date ( from: " 2022-10-19T19:00:00 " )
79
81
case . manyMeals:
80
82
return Self . dateFormatter. date ( from: " 2022-10-19T20:40:00 " )
81
- case . dynamicCarbAutofill:
83
+ case . dynamicCarbAutofill, . mmolUser :
82
84
return Self . dateFormatter. date ( from: " 2022-10-17T07:20:00 " ) !
83
85
default :
84
86
return nil
@@ -136,13 +138,26 @@ extension MissedMealTestType {
136
138
}
137
139
138
140
var insulinSensitivitySchedule : InsulinSensitivitySchedule {
139
- InsulinSensitivitySchedule (
140
- unit: HKUnit . milligramsPerDeciliter,
141
- dailyItems: [
142
- RepeatingScheduleValue ( startTime: 0.0 , value: 50.0 )
143
- ] ,
144
- timeZone: . utcTimeZone
145
- ) !
141
+ let value = 50.0
142
+ switch self {
143
+ case . mmolUser:
144
+ return InsulinSensitivitySchedule (
145
+ unit: HKUnit . millimolesPerLiter,
146
+ dailyItems: [
147
+ RepeatingScheduleValue ( startTime: 0.0 ,
148
+ value: HKQuantity ( unit: . milligramsPerDeciliter, doubleValue: value) . doubleValue ( for: . millimolesPerLiter) )
149
+ ] ,
150
+ timeZone: . utcTimeZone
151
+ ) !
152
+ default :
153
+ return InsulinSensitivitySchedule (
154
+ unit: HKUnit . milligramsPerDeciliter,
155
+ dailyItems: [
156
+ RepeatingScheduleValue ( startTime: 0.0 , value: value)
157
+ ] ,
158
+ timeZone: . utcTimeZone
159
+ ) !
160
+ }
146
161
}
147
162
}
148
163
@@ -335,6 +350,19 @@ class MealDetectionManagerTests: XCTestCase {
335
350
updateGroup. wait ( )
336
351
}
337
352
353
+ func testMMOLUser( ) {
354
+ let testType = MissedMealTestType . mmolUser
355
+ let counteractionEffects = setUp ( for: testType)
356
+
357
+ let updateGroup = DispatchGroup ( )
358
+ updateGroup. enter ( )
359
+ mealDetectionManager. hasMissedMeal ( insulinCounteractionEffects: counteractionEffects, carbEffects: mealDetectionCarbEffects ( using: counteractionEffects) ) { status in
360
+ XCTAssertEqual ( status, . hasMissedMeal( startTime: testType. missedMealDate!, carbAmount: 25 ) )
361
+ updateGroup. leave ( )
362
+ }
363
+ updateGroup. wait ( )
364
+ }
365
+
338
366
// MARK: - Notification Tests
339
367
func testNoMissedMealLastNotificationTime( ) {
340
368
setUp ( for: . notificationTest)
0 commit comments