package tests;

import calc.*;

import junit.framework.TestCase;

/** Tests of the calculator.
 * @author Gary T. Leavens
 */
public class TestCalc extends TestCase {

    /**
     * Constructor for TestCalc.
     */
    public TestCalc(String name) {
        super(name);
    }

    public static void main(String[] args) {
        junit.textui.TestRunner.run(TestCalc.class);
    }

    /**
     * @see TestCase#setUp()
     */
    protected void setUp() throws Exception {
        super.setUp();
    }
    
    /**
     * Test simple summations in the calculator.
     */
    public void testSummation1() {
        Formula f1 = new Formula(0, 1);
        Formula f2 = new Formula(1, 2);
        Registers.put(0, 4.0);
        Registers.put(1, 8.0);
        Registers.put(2, -1.0);
        FormulaMap.put("add01", f1);
        FormulaMap.put("add12", f2);
        assertEquals(12.0, FormulaMap.get("add01").evaluate(), 0.01);
        assertEquals(7.0, FormulaMap.get("add12").evaluate(), 0.01);
    }

}
