improved test coverage

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@592695 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2007-11-07 10:56:52 +00:00
parent 48d35f0b78
commit a2e16279da
2 changed files with 10 additions and 5 deletions

View File

@ -417,8 +417,11 @@ public class GaussNewtonEstimatorTest
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6); GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
estimator.estimate(problem); estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10); assertEquals(0, estimator.getRMS(problem), 1.0e-10);
assertEquals(2.0, p[0].getEstimate(), 1.0e-10); EstimatedParameter[] all = problem.getAllParameters();
assertEquals(1.0, p[1].getEstimate(), 1.0e-10); for (int i = 0; i < all.length; ++i) {
assertEquals(all[i].getName().equals("p0") ? 2.0 : 1.0,
all[i].getEstimate(), 1.0e-10);
}
} }

View File

@ -453,8 +453,11 @@ public class LevenbergMarquardtEstimatorTest
circle.addPoint(110.0, -20.0); circle.addPoint(110.0, -20.0);
circle.addPoint( 35.0, 15.0); circle.addPoint( 35.0, 15.0);
circle.addPoint( 45.0, 97.0); circle.addPoint( 45.0, 97.0);
checkEstimate(circle, 100.0, 1000, 1.0e-10, 1.0e-10, 1.0e-10, false); checkEstimate(circle, 0.1, 10, 1.0e-14, 1.0e-16, 1.0e-10, false);
checkEstimate(circle, 1.0e-12, 10, 1.0e-20, 1.0e-20, 1.0e-20, true); checkEstimate(circle, 0.1, 10, 1.0e-15, 1.0e-17, 1.0e-10, true);
checkEstimate(circle, 0.1, 5, 1.0e-15, 1.0e-16, 1.0e-10, true);
circle.addPoint(300, -300);
checkEstimate(circle, 0.1, 20, 1.0e-18, 1.0e-16, 1.0e-10, true);
} }
private void checkEstimate(EstimationProblem problem, private void checkEstimate(EstimationProblem problem,
@ -471,7 +474,6 @@ public class LevenbergMarquardtEstimatorTest
estimator.estimate(problem); estimator.estimate(problem);
assertTrue(! shouldFail); assertTrue(! shouldFail);
} catch (EstimationException ee) { } catch (EstimationException ee) {
System.out.println(ee.getClass().getName() + " " + ee.getMessage());
assertTrue(shouldFail); assertTrue(shouldFail);
} catch (Exception e) { } catch (Exception e) {
fail("wrong exception type caught"); fail("wrong exception type caught");