Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe44661

Browse files
committed
style update and ensure truly random distribution even if wasteful
1 parent fa6b9d2 commit fe44661

File tree

2 files changed

+293
-220
lines changed

2 files changed

+293
-220
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.random.test;
2+
3+
import static org.junit.Assert.assertNotNull;
4+
import static org.junit.Assert.assertTrue;
5+
6+
import org.junit.Assert;
7+
import org.junit.BeforeClass;
8+
import org.junit.Test;
9+
import org.random.util.RandomOrgRandom;
10+
11+
/** A set of tests for RandomOrgRandom.java
12+
**/
13+
public class RandomOrgRandomBasicTest {
14+
15+
private static RandomOrgRandom random;
16+
17+
private static final String API_KEY_1 = "YOUR_API_KEY_HERE";
18+
19+
@BeforeClass
20+
public static void testSetup() {
21+
random = new RandomOrgRandom(API_KEY_1);
22+
}
23+
24+
@Test
25+
public void testIntegerRange(){
26+
try {
27+
int i = random.nextInt(10);
28+
assertNotNull(i);
29+
assertTrue(i >= 0);
30+
assertTrue(i < 10);
31+
} catch (Exception e) {
32+
Assert.fail("Networking error: " + e.getClass().getName() + ":" + e.getMessage());
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)