45 |
|
static final long MAX_LONG_BOUND = (1L << 42); |
46 |
|
|
47 |
|
// Number of replications for other checks |
48 |
< |
static final int REPS = 20; |
48 |
> |
static final int REPS = |
49 |
> |
Integer.getInteger("SplittableRandomTest.reps", 4); |
50 |
|
|
51 |
|
/** |
52 |
|
* Repeated calls to nextInt produce at least two distinct results |
284 |
|
*/ |
285 |
|
public void testBadStreamSize() { |
286 |
|
SplittableRandom r = new SplittableRandom(); |
287 |
< |
try { |
288 |
< |
java.util.stream.IntStream x = r.ints(-1L); |
289 |
< |
shouldThrow(); |
290 |
< |
} catch (IllegalArgumentException success) {} |
291 |
< |
try { |
292 |
< |
java.util.stream.IntStream x = r.ints(-1L, 2, 3); |
293 |
< |
shouldThrow(); |
294 |
< |
} catch (IllegalArgumentException success) {} |
295 |
< |
try { |
295 |
< |
java.util.stream.LongStream x = r.longs(-1L); |
296 |
< |
shouldThrow(); |
297 |
< |
} catch (IllegalArgumentException success) {} |
298 |
< |
try { |
299 |
< |
java.util.stream.LongStream x = r.longs(-1L, -1L, 1L); |
300 |
< |
shouldThrow(); |
301 |
< |
} catch (IllegalArgumentException success) {} |
302 |
< |
try { |
303 |
< |
java.util.stream.DoubleStream x = r.doubles(-1L); |
304 |
< |
shouldThrow(); |
305 |
< |
} catch (IllegalArgumentException success) {} |
306 |
< |
try { |
307 |
< |
java.util.stream.DoubleStream x = r.doubles(-1L, .5, .6); |
308 |
< |
shouldThrow(); |
309 |
< |
} catch (IllegalArgumentException success) {} |
287 |
> |
Runnable[] throwingActions = { |
288 |
> |
() -> { java.util.stream.IntStream x = r.ints(-1L); }, |
289 |
> |
() -> { java.util.stream.IntStream x = r.ints(-1L, 2, 3); }, |
290 |
> |
() -> { java.util.stream.LongStream x = r.longs(-1L); }, |
291 |
> |
() -> { java.util.stream.LongStream x = r.longs(-1L, -1L, 1L); }, |
292 |
> |
() -> { java.util.stream.DoubleStream x = r.doubles(-1L); }, |
293 |
> |
() -> { java.util.stream.DoubleStream x = r.doubles(-1L, .5, .6); }, |
294 |
> |
}; |
295 |
> |
assertThrows(IllegalArgumentException.class, throwingActions); |
296 |
|
} |
297 |
|
|
298 |
|
/** |
301 |
|
*/ |
302 |
|
public void testBadStreamBounds() { |
303 |
|
SplittableRandom r = new SplittableRandom(); |
304 |
< |
try { |
305 |
< |
java.util.stream.IntStream x = r.ints(2, 1); |
306 |
< |
shouldThrow(); |
307 |
< |
} catch (IllegalArgumentException success) {} |
308 |
< |
try { |
309 |
< |
java.util.stream.IntStream x = r.ints(10, 42, 42); |
310 |
< |
shouldThrow(); |
311 |
< |
} catch (IllegalArgumentException success) {} |
312 |
< |
try { |
327 |
< |
java.util.stream.LongStream x = r.longs(-1L, -1L); |
328 |
< |
shouldThrow(); |
329 |
< |
} catch (IllegalArgumentException success) {} |
330 |
< |
try { |
331 |
< |
java.util.stream.LongStream x = r.longs(10, 1L, -2L); |
332 |
< |
shouldThrow(); |
333 |
< |
} catch (IllegalArgumentException success) {} |
334 |
< |
try { |
335 |
< |
java.util.stream.DoubleStream x = r.doubles(0.0, 0.0); |
336 |
< |
shouldThrow(); |
337 |
< |
} catch (IllegalArgumentException success) {} |
338 |
< |
try { |
339 |
< |
java.util.stream.DoubleStream x = r.doubles(10, .5, .4); |
340 |
< |
shouldThrow(); |
341 |
< |
} catch (IllegalArgumentException success) {} |
304 |
> |
Runnable[] throwingActions = { |
305 |
> |
() -> { java.util.stream.IntStream x = r.ints(2, 1); }, |
306 |
> |
() -> { java.util.stream.IntStream x = r.ints(10, 42, 42); }, |
307 |
> |
() -> { java.util.stream.LongStream x = r.longs(-1L, -1L); }, |
308 |
> |
() -> { java.util.stream.LongStream x = r.longs(10, 1L, -2L); }, |
309 |
> |
() -> { java.util.stream.DoubleStream x = r.doubles(0.0, 0.0); }, |
310 |
> |
() -> { java.util.stream.DoubleStream x = r.doubles(10, .5, .4); }, |
311 |
> |
}; |
312 |
> |
assertThrows(IllegalArgumentException.class, throwingActions); |
313 |
|
} |
314 |
|
|
315 |
|
/** |