DailyValueSchedule.swift 600 B

123456789101112131415161718192021
  1. //
  2. // DailyValueSchedule.swift
  3. // LoopKitTests
  4. //
  5. // Created by Michael Pangburn on 3/25/19.
  6. // Copyright © 2019 LoopKit Authors. All rights reserved.
  7. //
  8. import LoopKit
  9. extension DailyValueSchedule where T: FloatingPoint {
  10. func equals(_ other: DailyValueSchedule<T>, accuracy epsilon: T) -> Bool {
  11. guard items.count == other.items.count else { return false }
  12. return Swift.zip(items, other.items).allSatisfy { thisItem, otherItem in
  13. thisItem.startTime == otherItem.startTime
  14. && abs(thisItem.value - otherItem.value) <= epsilon
  15. }
  16. }
  17. }