RandUtil { public static long nextLong(long n) { return Math.abs(insecureRandom.nextLong()) % n; } private  RandUtil(); static boolean nextBoolean(); static int nextInt(); static int nextInt(int lower, int upper); static long nextLong(long n); static long nextLong(long lower, long upper); static long nextLong(); static String nextAlphabetic(int characters); static String nextNumeric(int digits); static E nextItem(E[] array);  }
@Test @DisplayName("Test bounded long generation") void nextLong_1() { for (long[] range : new long[][] { { -2, 10 }, { -1, 1 }, { 1, 100 }, { -100, -1 }, { 0, 1 } }) { long min = range[0]; long max = range[1]; for (int i = 0; i < 1000; i++) { long rand = RandUtil.nextLong(min, max); assertTrue(rand >= min); assertTrue(rand <= max); } } }