Skip to content

Commit 4f48317

Browse files
committed
Test that Rand.standard's choose method is inclusive of max parameter
1 parent 369e9b6 commit 4f48317

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package fj.test;
2+
3+
import fj.Ord;
4+
import fj.data.Stream;
5+
import org.junit.Test;
6+
7+
import static org.junit.Assert.assertTrue;
8+
9+
/**
10+
* Created by MarkPerry on 4/06/2015.
11+
*/
12+
public class TestRand {
13+
14+
@Test
15+
public void testRandLowHighInclusive() {
16+
int min = 5;
17+
int max = 10;
18+
int n = 100;
19+
Stream<Integer> s = Stream.range(0, n).map(i -> Rand.standard.choose(min, max)).sort(Ord.intOrd);
20+
// System.out.println(s);
21+
assertTrue(s.head() == min && s.last() == max);
22+
}
23+
24+
}

0 commit comments

Comments
 (0)