more test coverage of obscure situations
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@138003 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
57b94c34ea
commit
bcd86e7fbe
|
@ -25,7 +25,7 @@ import junit.framework.TestSuite;
|
|||
* Test cases for the {@link RandomUtils} class.
|
||||
*
|
||||
* @author <a href="mailto:phil@steitz.com">Phil Steitz</a>
|
||||
* @version $Revision: 1.7 $ $Date: 2004/02/18 23:02:38 $
|
||||
* @version $Revision: 1.8 $ $Date: 2004/12/25 17:52:19 $
|
||||
*/
|
||||
|
||||
public final class RandomUtilsTest extends TestCase {
|
||||
|
@ -55,6 +55,12 @@ public final class RandomUtilsTest extends TestCase {
|
|||
tstNextInt(rnd);
|
||||
}
|
||||
|
||||
/** test distribution of JVMRandom.nextInt() */
|
||||
public void testJvmRandomNextInt() {
|
||||
tstNextInt(RandomUtils.JVM_RANDOM);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate 1000 values for nextInt(bound) and compare
|
||||
* the observed frequency counts to expected counts using
|
||||
|
@ -268,14 +274,49 @@ public final class RandomUtilsTest extends TestCase {
|
|||
chiSquare(expected,observed) < 10.83);
|
||||
}
|
||||
|
||||
/** make sure that setSeed fails */
|
||||
public void testSetSeed() {
|
||||
/** make sure that unimplemented methods fail */
|
||||
public void testUnimplementedMethods() {
|
||||
|
||||
try {
|
||||
RandomUtils.JVM_RANDOM.setSeed(1000);
|
||||
fail("expecting UnsupportedOperationException");
|
||||
} catch (UnsupportedOperationException ex) {
|
||||
// empty
|
||||
}
|
||||
|
||||
try {
|
||||
RandomUtils.JVM_RANDOM.nextGaussian();
|
||||
fail("expecting UnsupportedOperationException");
|
||||
} catch (UnsupportedOperationException ex) {
|
||||
// empty
|
||||
}
|
||||
|
||||
try {
|
||||
RandomUtils.JVM_RANDOM.nextBytes(null);
|
||||
fail("expecting UnsupportedOperationException");
|
||||
} catch (UnsupportedOperationException ex) {
|
||||
// empty
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** make sure that illegal arguments fail */
|
||||
public void testIllegalArguments() {
|
||||
|
||||
try {
|
||||
RandomUtils.JVM_RANDOM.nextInt(-1);
|
||||
fail("expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// empty
|
||||
}
|
||||
|
||||
try {
|
||||
JVMRandom.nextLong( -1L );
|
||||
fail("expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// empty
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue