001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.commons.math.estimation;
019
020 import org.apache.commons.math.estimation.EstimatedParameter;
021
022 import junit.framework.*;
023
024 @Deprecated
025 public class EstimatedParameterTest
026 extends TestCase {
027
028 public EstimatedParameterTest(String name) {
029 super(name);
030 }
031
032 public void testConstruction() {
033
034 EstimatedParameter p1 = new EstimatedParameter("p1", 1.0);
035 assertTrue(p1.getName().equals("p1"));
036 checkValue(p1.getEstimate(), 1.0);
037 assertTrue(! p1.isBound());
038
039 EstimatedParameter p2 = new EstimatedParameter("p2", 2.0, true);
040 assertTrue(p2.getName().equals("p2"));
041 checkValue(p2.getEstimate(), 2.0);
042 assertTrue(p2.isBound());
043
044 }
045
046 public void testBound() {
047
048 EstimatedParameter p = new EstimatedParameter("p", 0.0);
049 assertTrue(! p.isBound());
050 p.setBound(true);
051 assertTrue(p.isBound());
052 p.setBound(false);
053 assertTrue(! p.isBound());
054
055 }
056
057 public void testEstimate() {
058
059 EstimatedParameter p = new EstimatedParameter("p", 0.0);
060 checkValue(p.getEstimate(), 0.0);
061
062 for (double e = 0.0; e < 10.0; e += 0.5) {
063 p.setEstimate(e);
064 checkValue(p.getEstimate(), e);
065 }
066
067 }
068
069 public static Test suite() {
070 return new TestSuite(EstimatedParameterTest.class);
071 }
072
073 private void checkValue(double value, double expected) {
074 assertTrue(Math.abs(value - expected) < 1.0e-10);
075 }
076
077 }