MATH-795:
- added in RealVectorAbstractTest tests for RealVector.getEntry() preconditions, - modified exceptions thrown in RealVectorTest.TestVectorImpl accordingly. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1347395 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3a7911512f
commit
00bc945db4
|
@ -154,6 +154,16 @@ public abstract class RealVectorAbstractTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(expected=OutOfRangeException.class)
|
||||
public void testGetEntryInvalidIndex1() {
|
||||
create(data1).getEntry(-1);
|
||||
}
|
||||
|
||||
@Test(expected=OutOfRangeException.class)
|
||||
public void testGetEntryInvalidIndex2() {
|
||||
create(data1).getEntry(data1.length);
|
||||
}
|
||||
|
||||
private void doTestAppendVector(final String message, final RealVector v1,
|
||||
final RealVector v2, final double delta) {
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ import org.junit.Test;
|
|||
import org.junit.Assert;
|
||||
import org.apache.commons.math3.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math3.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math3.exception.OutOfRangeException;
|
||||
import org.apache.commons.math3.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math3.linear.RealVector.Entry;
|
||||
import org.apache.commons.math3.util.MathArrays;
|
||||
|
||||
|
@ -125,12 +127,22 @@ public class RealVectorTest extends RealVectorAbstractTest{
|
|||
|
||||
@Override
|
||||
public double getEntry(int index) {
|
||||
return values[index];
|
||||
try {
|
||||
return values[index];
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new OutOfRangeException(LocalizedFormats.INDEX, index, 0,
|
||||
getDimension() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntry(int index, double value) {
|
||||
values[index] = value;
|
||||
try {
|
||||
values[index] = value;
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new OutOfRangeException(LocalizedFormats.INDEX, index, 0,
|
||||
getDimension() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue