|
@@ -35,11 +35,23 @@ import Testing
|
|
|
#expect(ratio == 1) // 12 grams per exchange
|
|
#expect(ratio == 1) // 12 grams per exchange
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Test("should allow ratios of 1") func allowLowRatios() async throws {
|
|
|
|
|
+ let schedule = CarbRatios(
|
|
|
|
|
+ units: .grams,
|
|
|
|
|
+ schedule: [
|
|
|
|
|
+ CarbRatioEntry(start: "00:00:00", offset: 0, ratio: 1)
|
|
|
|
|
+ ]
|
|
|
|
|
+ )
|
|
|
|
|
+ let now = Calendar.current.date(from: DateComponents(year: 2025, month: 1, day: 26, hour: 2))!
|
|
|
|
|
+ let ratio = Carbs.carbRatioLookup(carbRatio: schedule, now: now)
|
|
|
|
|
+ #expect(ratio == 1)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Test("should reject invalid ratios") func rejectInvalidRatios() async throws {
|
|
@Test("should reject invalid ratios") func rejectInvalidRatios() async throws {
|
|
|
let invalidSchedule = CarbRatios(
|
|
let invalidSchedule = CarbRatios(
|
|
|
units: .grams,
|
|
units: .grams,
|
|
|
schedule: [
|
|
schedule: [
|
|
|
- CarbRatioEntry(start: "00:00:00", offset: 0, ratio: 2),
|
|
|
|
|
|
|
+ CarbRatioEntry(start: "00:00:00", offset: 0, ratio: 0.5),
|
|
|
CarbRatioEntry(start: "03:00:00", offset: 180, ratio: 15)
|
|
CarbRatioEntry(start: "03:00:00", offset: 180, ratio: 15)
|
|
|
]
|
|
]
|
|
|
)
|
|
)
|