fixed an index error triggering ArrayIndexOutOfBoundException for an add after a clear
if size has grown git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@796021 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
36e2a9ee50
commit
b6d4e8649a
|
@ -375,6 +375,7 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
|
|||
*/
|
||||
public synchronized void clear() {
|
||||
numElements = 0;
|
||||
startIndex = 0;
|
||||
internalArray = new double[initialCapacity];
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,17 @@ public class DescriptiveStatisticsTest extends TestCase {
|
|||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void test20090720() {
|
||||
DescriptiveStatistics descriptiveStatistics = new DescriptiveStatistics(100);
|
||||
for (int i = 0; i < 161; i++) {
|
||||
descriptiveStatistics.addValue(1.2);
|
||||
}
|
||||
descriptiveStatistics.clear();
|
||||
descriptiveStatistics.addValue(1.2);
|
||||
assertEquals(1, descriptiveStatistics.getN());
|
||||
}
|
||||
|
||||
public void testRemoval() {
|
||||
|
||||
final DescriptiveStatistics dstat = createDescriptiveStatistics();
|
||||
|
|
Loading…
Reference in New Issue