psteitz 2004/06/26 15:09:07
Modified: math/src/test/org/apache/commons/math/stat/inference
ChiSquareTestTest.java
Log:
Added more tests for bad input data.
Revision Changes Path
1.3 +42 -4
jakarta-commons/math/src/test/org/apache/commons/math/stat/inference/ChiSquareTestTest.java
Index: ChiSquareTestTest.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/inference/ChiSquareTestTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ChiSquareTestTest.java 7 Jun 2004 20:30:16 -0000 1.2
+++ ChiSquareTestTest.java 26 Jun 2004 22:09:07 -0000 1.3
@@ -66,7 +66,7 @@
fail("alpha out of range, IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// expected
- }
+ }
long[] tooShortObs = { 0 };
double[] tooShortEx = { 1 };
@@ -77,6 +77,7 @@
// expected
}
+ // unmatched arrays
long[] unMatchedObs = { 0, 1, 2, 3 };
double[] unMatchedEx = { 1, 1, 2 };
try {
@@ -85,13 +86,26 @@
} catch (IllegalArgumentException ex) {
// expected
}
+
+ // 0 expected count
expected[0] = 0;
try {
testStatistic.chiSquareTest(expected, observed, .01);
fail("bad expected count, IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// expected
- }
+ }
+
+ // negative observed count
+ expected[0] = 1;
+ observed[0] = -1;
+ try {
+ testStatistic.chiSquareTest(expected, observed, .01);
+ fail("bad expected count, IllegalArgumentException expected");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+
}
public void testChiSquareIndependence() throws Exception {
@@ -125,7 +139,31 @@
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// expected
- }
+ }
+ long[][] counts5 = {{40}, {40}, {30}, {10}};
+ try {
+ testStatistic.chiSquare(counts5);
+ fail("Expecting IllegalArgumentException");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+
+ // negative counts
+ long[][] counts6 = {{10, -2}, {30, 40}, {60, 90} };
+ try {
+ testStatistic.chiSquare(counts6);
+ fail("Expecting IllegalArgumentException");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+
+ // bad alpha
+ try {
+ testStatistic.chiSquareTest(counts, 0);
+ fail("Expecting IllegalArgumentException");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
}
public void testChiSquareLargeTestStatistic() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]