MCPcopy Create free account
hub / github.com/PCGen/pcgen / testRoll

Method testRoll

code/src/utest/pcgen/core/RollingMethodsTest.java:26–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24 static final long SEED = -5450594;
25
26 @Test
27 public final void testRoll()
28 {
29 final Random random = new Random(SEED);
30 RandomUtil.setRandomGenerator(random);
31
32 random.setSeed(SEED);
33 int[] rolls = IntStream.generate(() -> RollingMethods.roll(SIDES)).limit(TIMES).sorted().toArray();
34
35 // Make sure the raw dice roll is in the correct range
36 assertTrue(IntStream.of(rolls).min().getAsInt() > 0);
37 assertTrue(IntStream.of(rolls).max().getAsInt() <= SIDES);
38
39 // compute the sum of all the rolls
40 final int sum = IntStream.of(rolls).sum();
41
42 // rest the seed so we generate the same random numbers
43 random.setSeed(SEED);
44 final int testSum = RollingMethods.roll(TIMES, SIDES);
45
46 // verify the RollingMethods generates the correct results
47 assertEquals(sum, testSum);
48 }
49
50 @Test
51 public final void testTopRoll()

Callers

nothing calls this directly

Calls 7

setRandomGeneratorMethod · 0.95
rollMethod · 0.95
ofMethod · 0.80
generateMethod · 0.65
toArrayMethod · 0.45
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected