File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -272,8 +272,10 @@ public class ProgramBuilder {
272
272
/// Returns a random integer value suitable as size of for example an array.
273
273
/// The returned value is guaranteed to be positive.
274
274
public func randomSize( upTo maximum: Int64 = 0x100000000 ) -> Int64 {
275
- assert ( maximum >= 0x1000 )
276
- if probability ( 0.5 ) {
275
+ assert ( maximum >= 0 )
276
+ if maximum < 0x1000 {
277
+ return Int64 . random ( in: 0 ... maximum)
278
+ } else if probability ( 0.5 ) {
277
279
return chooseUniform ( from: fuzzer. environment. interestingIntegers. filter ( { $0 >= 0 && $0 <= maximum } ) )
278
280
} else {
279
281
return withEqualProbability ( {
@@ -291,7 +293,7 @@ public class ProgramBuilder {
291
293
/// Returns a random non-negative integer value suitable as index.
292
294
public func randomNonNegativeIndex( upTo max: Int64 = 0x100000000 ) -> Int64 {
293
295
// Prefer small indices.
294
- if probability ( 0.33 ) {
296
+ if max > 10 && probability ( 0.33 ) {
295
297
return Int64 . random ( in: 0 ... 10 )
296
298
} else {
297
299
return randomSize ( upTo: max)
You can’t perform that action at this time.
0 commit comments