MATH-795: factored out testAddToEntry().

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1346245 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastien Brisard 2012-06-05 05:45:41 +00:00
parent 6d5b6eb0d1
commit ce5671bfb0
2 changed files with 14 additions and 13 deletions

View File

@ -740,19 +740,6 @@ public class ArrayRealVectorTest extends RealVectorAbstractTest {
}
}
@Test
public void testAddToEntry() {
final double[] v = new double[] { 1, 2, 3 };
final ArrayRealVector x = new ArrayRealVector(v);
final double inc = 7;
for (int i = 0; i < x.getDimension(); i++) {
x.addToEntry(i, inc);
}
for (int i = 0; i < x.getDimension(); i++) {
Assert.assertEquals(v[i] + inc, x.getEntry(i), 0);
}
}
@Override
public RealVector create(final double[] data) {
return new ArrayRealVector(data, true);

View File

@ -752,6 +752,20 @@ public abstract class RealVectorAbstractTest {
Assert.assertEquals(v,TestUtils.serializeAndRecover(v));
}
@Test
public void testAddToEntry() {
final double[] v = new double[] { 1, 2, 3 };
final RealVector x = create(v);
final double inc = 7;
for (int i = 0; i < x.getDimension(); i++) {
x.addToEntry(i, inc);
}
for (int i = 0; i < x.getDimension(); i++) {
Assert.assertEquals(v[i] + inc, x.getEntry(i), 0);
}
}
/*
* TESTS OF THE VISITOR PATTERN
*/