TestUtilities.swift 556 B

123456789101112131415161718
  1. //
  2. // TestUtilities.swift
  3. // OmniBLE
  4. //
  5. // Created by Bill Gestrich on 12/11/21.
  6. // Copyright © 2021 LoopKit Authors. All rights reserved.
  7. //
  8. extension String {
  9. //From start to, but not including, toIndex
  10. func substring(startIndex _startIndexInt: Int, toIndex _toIndexInt: Int) -> String? {
  11. assert(_startIndexInt < _toIndexInt)
  12. let startIndex = index(self.startIndex, offsetBy: _startIndexInt)
  13. let endIndex = index(self.startIndex, offsetBy: _toIndexInt - 1)
  14. return String(self[startIndex...endIndex])
  15. }
  16. }