forked from ronancpl/HeavenMS
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(cherry picked from commit 7babbac)
- Loading branch information
Sirinut Euaungkanakul
committed
Oct 7, 2024
1 parent
87f13e3
commit ffca73e
Showing
2 changed files
with
35 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package server.maps; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class MapleMapTest { | ||
|
||
@Test | ||
void randShouldIncludeEntireRange() { | ||
Map<Integer, Integer> rands = new HashMap<>(); | ||
|
||
final int rounds = 100_000; | ||
for (int i = 0; i < rounds; i++) { | ||
int randomValue = Randomizer.rand(-5, 5); | ||
rands.compute(randomValue, (k, v) -> v == null ? 0 : v + 1); | ||
} | ||
|
||
assertFalse(rands.containsKey(-6)); | ||
assertTrue(rands.containsKey(-5)); | ||
assertTrue(rands.containsKey(-4)); | ||
assertTrue(rands.containsKey(-3)); | ||
assertTrue(rands.containsKey(-2)); | ||
assertTrue(rands.containsKey(-1)); | ||
assertTrue(rands.containsKey(0)); | ||
assertTrue(rands.containsKey(1)); | ||
assertTrue(rands.containsKey(2)); | ||
assertTrue(rands.containsKey(3)); | ||
assertTrue(rands.containsKey(4)); | ||
assertTrue(rands.containsKey(5)); | ||
assertFalse(rands.containsKey(6)); | ||
} | ||
} |