forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomUtilsTest.java
More file actions
46 lines (37 loc) · 1.03 KB
/
RandomUtilsTest.java
File metadata and controls
46 lines (37 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.examplehub.utils;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class RandomUtilsTest {
@Test
void testRandomInts() {
try {
int[] ints = RandomUtils.randomInts(50, -50, 10);
fail(); /* will not happen */
} catch (IllegalArgumentException e) {
assertTrue(true); /* will happen */
}
int[] ints = RandomUtils.randomInts(-50, 50, 100);
for (int anInt : ints) {
assertTrue(anInt >= -50 && anInt <= 50);
}
assertTrue(true);
}
@Test
void testRandomDoubles() {
try {
double[] ints = RandomUtils.randomDoubles(50, -50, 10);
fail(); /* will not happen */
} catch (IllegalArgumentException e) {
assertTrue(true); /* will happen */
}
double[] doubles = RandomUtils.randomDoubles(-50, 50, 100);
for (double anDouble : doubles) {
assertTrue(anDouble >= -50 && anDouble <= 50);
}
assertTrue(true);
}
@Test
void testRandomLetters() {
assert RandomUtils.randomLetters(8).length() == 8;
}
}