JUnit testing of serialization of all StorelessUnivariates
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141039 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
29aba171ed
commit
3c0ef74e44
|
@ -53,10 +53,11 @@
|
|||
*/
|
||||
package org.apache.commons.math.stat.univariate;
|
||||
|
||||
import org.apache.commons.math.TestUtils;
|
||||
|
||||
/**
|
||||
* Test cases for the {@link UnivariateStatistic} class.
|
||||
* @version $Revision: 1.8 $ $Date: 2003/11/14 22:22:23 $
|
||||
* @version $Revision: 1.9 $ $Date: 2003/11/19 13:35:10 $
|
||||
*/
|
||||
public abstract class StorelessUnivariateStatisticAbstractTest
|
||||
extends UnivariateStatisticAbstractTest {
|
||||
|
@ -88,4 +89,25 @@ public abstract class StorelessUnivariateStatisticAbstractTest
|
|||
|
||||
}
|
||||
|
||||
public void testSerialization() throws Exception {
|
||||
|
||||
StorelessUnivariateStatistic statistic =
|
||||
(StorelessUnivariateStatistic) getUnivariateStatistic();
|
||||
|
||||
statistic.clear();
|
||||
|
||||
for (int i = 0; i < testArray.length; i++) {
|
||||
statistic.increment(testArray[i]);
|
||||
if(i % 5 == 0)
|
||||
statistic = (StorelessUnivariateStatistic)TestUtils.serializeAndRecover(statistic);
|
||||
}
|
||||
|
||||
assertEquals(expectedValue(), statistic.getResult(), getTolerance());
|
||||
|
||||
statistic.clear();
|
||||
|
||||
assertTrue(Double.isNaN(statistic.getResult()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue