Java Code Examples for java.util.concurrent.ThreadLocalRandom#longs()

The following examples show how to use java.util.concurrent.ThreadLocalRandom#longs() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Invoking sized ints, long, doubles, with negative sizes throws
 * IllegalArgumentException
 */
public void testBadStreamSize() {
    ThreadLocalRandom r = ThreadLocalRandom.current();
    Runnable[] throwingActions = {
        () -> r.ints(-1L),
        () -> r.ints(-1L, 2, 3),
        () -> r.longs(-1L),
        () -> r.longs(-1L, -1L, 1L),
        () -> r.doubles(-1L),
        () -> r.doubles(-1L, .5, .6),
    };
    assertThrows(IllegalArgumentException.class, throwingActions);
}
 
Example 2
/**
 * Invoking bounded ints, long, doubles, with illegal bounds throws
 * IllegalArgumentException
 */
public void testBadStreamBounds() {
    ThreadLocalRandom r = ThreadLocalRandom.current();
    Runnable[] throwingActions = {
        () -> r.ints(2, 1),
        () -> r.ints(10, 42, 42),
        () -> r.longs(-1L, -1L),
        () -> r.longs(10, 1L, -2L),
        () -> r.doubles(0.0, 0.0),
        () -> r.doubles(10, .5, .4),
    };
    assertThrows(IllegalArgumentException.class, throwingActions);
}
 
Example 3
Source Project: j2objc   File: ThreadLocalRandom8Test.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Invoking sized ints, long, doubles, with negative sizes throws
 * IllegalArgumentException
 */
public void testBadStreamSize() {
    ThreadLocalRandom r = ThreadLocalRandom.current();
    Runnable[] throwingActions = {
        () -> r.ints(-1L),
        () -> r.ints(-1L, 2, 3),
        () -> r.longs(-1L),
        () -> r.longs(-1L, -1L, 1L),
        () -> r.doubles(-1L),
        () -> r.doubles(-1L, .5, .6),
    };
    assertThrows(IllegalArgumentException.class, throwingActions);
}
 
Example 4
Source Project: j2objc   File: ThreadLocalRandom8Test.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Invoking bounded ints, long, doubles, with illegal bounds throws
 * IllegalArgumentException
 */
public void testBadStreamBounds() {
    ThreadLocalRandom r = ThreadLocalRandom.current();
    Runnable[] throwingActions = {
        () -> r.ints(2, 1),
        () -> r.ints(10, 42, 42),
        () -> r.longs(-1L, -1L),
        () -> r.longs(10, 1L, -2L),
        () -> r.doubles(0.0, 0.0),
        () -> r.doubles(10, .5, .4),
    };
    assertThrows(IllegalArgumentException.class, throwingActions);
}