File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ extension Gen where Value == Date {
117
117
/// - Parameter range: A range which contains all generated dates. Undefined bounds will be set to 60 years from the other bound.
118
118
/// - Returns: A new generator.
119
119
public static func dateTime( in range: Range < Date > ) -> Generator < Date , DateTimeShrink > {
120
+ precondition ( !range. isEmpty, " Range must not be empty " )
121
+
120
122
let interval = range. lowerBound. timeIntervalSinceReferenceDate..< range. upperBound. timeIntervalSinceReferenceDate
121
123
let end = Date ( ) . timeIntervalSinceReferenceDate
122
124
@@ -215,6 +217,8 @@ extension Gen where Value == Date {
215
217
/// - Parameter range: A range which contains all generated dates. Undefined bounds will be set to 60 years from the other bound.
216
218
/// - Returns: A new generator.
217
219
public static func date( in range: Range < Date > ) -> Generator < Date , Shrink . Integer < Int > > {
220
+ precondition ( !range. isEmpty, " Range must not be empty " )
221
+
218
222
let newUpper = range. upperBound. timeIntervalSinceReferenceDate - secondsPerDay
219
223
return date ( in: range. lowerBound... Date ( timeIntervalSinceReferenceDate: newUpper) )
220
224
}
You can’t perform that action at this time.
0 commit comments