You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2012/05/27 20:45:49 UTC
svn commit: r1343077 -
/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/random/RandomDataTest.java
Author: psteitz
Date: Sun May 27 18:45:48 2012
New Revision: 1343077
URL: http://svn.apache.org/viewvc?rev=1343077&view=rev
Log:
* Changed testNextHex, textNextSecureHex to use ChiSquareTest via TestUtils method
(These tests were written before either of these existed.)
* Dropped @Retry from testNextHex (no longer needed because randomData is now
initialized with a fixed seed).
* Dropped extraneous checks (must have been cut-paste error).
JIRA: MATH-598
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/random/RandomDataTest.java
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/random/RandomDataTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/random/RandomDataTest.java?rev=1343077&r1=1343076&r2=1343077&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/random/RandomDataTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/random/RandomDataTest.java Sun May 27 18:45:48 2012
@@ -506,8 +506,7 @@ public class RandomDataTest {
/** test dispersion and failure modes for nextHex() */
@Test
- @Retry(3)
- public void testNextHex() {
+ public void testNextHex() throws Exception {
try {
randomData.nextHexString(-1);
Assert.fail("negative length supplied -- MathIllegalArgumentException expected");
@@ -534,9 +533,6 @@ public class RandomDataTest {
} catch (MathIllegalArgumentException ex) {
// ignored
}
- if (hexString.length() != 1) {
- Assert.fail("incorrect length for generated string");
- }
Frequency f = new Frequency();
for (int i = 0; i < smallSampleSize; i++) {
hexString = randomData.nextHexString(100);
@@ -553,17 +549,12 @@ public class RandomDataTest {
expected[i] = (double) smallSampleSize * 100 / 16;
observed[i] = f.getCount(hex[i]);
}
- /*
- * Use ChiSquare dist with df = 16-1 = 15, alpha = .001 Change to 30.58
- * for alpha = .01
- */
- Assert.assertTrue("chi-square test -- will fail about 1 in 1000 times",
- testStatistic.chiSquare(expected, observed) < 37.70);
+ TestUtils.assertChiSquareAccept(expected, observed, 0.001);
}
/** test dispersion and failure modes for nextHex() */
@Test
- public void testNextSecureHex() {
+ public void testNextSecureHex() throws Exception {
try {
randomData.nextSecureHexString(-1);
Assert.fail("negative length -- MathIllegalArgumentException expected");
@@ -590,9 +581,6 @@ public class RandomDataTest {
} catch (MathIllegalArgumentException ex) {
// ignored
}
- if (hexString.length() != 1) {
- Assert.fail("incorrect length for generated string");
- }
Frequency f = new Frequency();
for (int i = 0; i < smallSampleSize; i++) {
hexString = randomData.nextSecureHexString(100);
@@ -609,12 +597,7 @@ public class RandomDataTest {
expected[i] = (double) smallSampleSize * 100 / 16;
observed[i] = f.getCount(hex[i]);
}
- /*
- * Use ChiSquare dist with df = 16-1 = 15, alpha = .001 Change to 30.58
- * for alpha = .01
- */
- Assert.assertTrue("chi-square test -- will fail about 1 in 1000 times",
- testStatistic.chiSquare(expected, observed) < 37.70);
+ TestUtils.assertChiSquareAccept(expected, observed, 0.001);
}
@Test