@@ -11,6 +11,7 @@ public class RandomNumbersGeneratorUnitTest {
1111
1212 private static final int MIN_RANGE = 1 ;
1313 private static final int MAX_RANGE = 10 ;
14+ private static final int MIN_RANGE_NEGATIVE = -10 ;
1415 private static final int ITERATIONS = 50 ;
1516 private static final long STREAM_SIZE = 50 ;
1617
@@ -19,7 +20,7 @@ public void whenGenerateRandomWithMathRandom_returnsSuccessfully() {
1920 RandomNumbersGenerator generator = new RandomNumbersGenerator ();
2021 for (int i = 0 ; i < ITERATIONS ; i ++) {
2122 int randomNumer = generator .generateRandomWithMathRandom (MIN_RANGE , MAX_RANGE );
22- assertTrue (isInRange (randomNumer , Integer . MIN_VALUE , Integer . MAX_VALUE ));
23+ assertTrue (isInRange (randomNumer , MIN_RANGE , MAX_RANGE ));
2324 }
2425 }
2526
@@ -97,10 +98,17 @@ public void whenGenerateRandomWithThreadLocalRandomFromZero_returnsSuccessfully(
9798 public void whenGenerateRandomWithSplittableRandom_returnsSuccessfully () {
9899 RandomNumbersGenerator generator = new RandomNumbersGenerator ();
99100 for (int i = 0 ; i < ITERATIONS ; i ++) {
100- int randomNumber = generator .generateRandomWithSplittableRandom (MIN_RANGE , MAX_RANGE );
101- assertTrue (isInRange (randomNumber , MIN_RANGE , MAX_RANGE ));
101+ int randomNumber = generator .generateRandomWithSplittableRandom (MIN_RANGE_NEGATIVE , MAX_RANGE );
102+ assertTrue (isInRange (randomNumber , MIN_RANGE_NEGATIVE , MAX_RANGE ));
102103 }
103104 }
105+
106+ @ Test
107+ public void whenGenerateRandomWithSplittableRandomLimitedIntStreamWithinARange_returnsSuccessfully () {
108+ RandomNumbersGenerator generator = new RandomNumbersGenerator ();
109+ generator .generateRandomWithSplittableRandomLimitedIntStreamWithinARange (MIN_RANGE , MAX_RANGE , STREAM_SIZE )
110+ .forEach (randomNumber -> assertTrue (isInRange (randomNumber , MIN_RANGE , MAX_RANGE )));
111+ }
104112
105113 @ Test
106114 public void whenGenerateRandomWithSecureRandom_returnsSuccessfully () {
@@ -110,6 +118,15 @@ public void whenGenerateRandomWithSecureRandom_returnsSuccessfully() {
110118 assertTrue (isInRange (randomNumber , Integer .MIN_VALUE , Integer .MAX_VALUE ));
111119 }
112120 }
121+
122+ @ Test
123+ public void whenGenerateRandomWithSecureRandomWithinARange_returnsSuccessfully () {
124+ RandomNumbersGenerator generator = new RandomNumbersGenerator ();
125+ for (int i = 0 ; i < ITERATIONS ; i ++) {
126+ int randomNumber = generator .generateRandomWithSecureRandomWithinARange (MIN_RANGE , MAX_RANGE );
127+ assertTrue (isInRange (randomNumber , MIN_RANGE , MAX_RANGE ));
128+ }
129+ }
113130
114131 @ Test
115132 public void whenGenerateRandomWithRandomDataGenerator_returnsSuccessfully () {
0 commit comments