Add support for Commons-Lang's RandomUtils

This is realised by somewhat generalising our interfaces for modelling RNGs. We also add tests for randomness-related queries that didn't have any, and addtest cases checking the Apache random-number generators are interchangeable with the stdlib ones.
This commit is contained in:
Chris Smowton
2021-03-05 11:40:11 +00:00
parent 8d292070a4
commit e3cf5c235e
30 changed files with 464 additions and 149 deletions

View File

@@ -0,0 +1,20 @@
import java.util.Random;
import org.apache.commons.lang3.RandomUtils;
public class Test {
public static void test() {
Random r = new Random();
Math.abs(r.nextInt());
Math.abs(r.nextLong());
Math.abs(r.nextInt(100)); // GOOD: random value already has a restricted range
Math.abs(RandomUtils.nextInt());
Math.abs(RandomUtils.nextLong());
Math.abs(RandomUtils.nextInt(1, 10)); // GOOD: random value already has a restricted range
Math.abs(RandomUtils.nextLong(1, 10)); // GOOD: random value already has a restricted range
}
}