package org.nwapw.abacus.tests;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.nwapw.abacus.Abacus;
import org.nwapw.abacus.number.NumberInterface;
import org.nwapw.abacus.plugin.StandardPlugin;
import org.nwapw.abacus.tree.TreeNode;

public class CalculationTests {

    private static Abacus abacus = new Abacus();

    @BeforeClass
    public static void prepareTests(){
        abacus.getPluginManager().addInstantiated(new StandardPlugin(abacus.getPluginManager()));
        abacus.getPluginManager().load();
    }

    private void testOutput(String input, String parseOutput, String output){
        TreeNode parsedTree = abacus.parseString(input);
        Assert.assertNotNull(parsedTree);
        Assert.assertEquals(parsedTree.toString(), parseOutput);
        NumberInterface result = abacus.evaluateTree(parsedTree);
        Assert.assertNotNull(result);
        Assert.assertTrue(result.toString().startsWith(output));
    }

    private void testEvalError(String input, String parseOutput){
        TreeNode parsedTree = abacus.parseString(input);
        Assert.assertNotNull(parsedTree);
        Assert.assertEquals(parsedTree.toString(), parseOutput);
        Assert.assertNull(abacus.evaluateTree(parsedTree));
    }

}

@@ -81,16 +81,39 @@
 eClass;%0A
+import org.junit.Test;%0A
 import o
@@ -1272,10 +1272,415 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testAddition()%7B%0A        testOutput(%229.5+10%22, %22(9.5+10)%22, %2219.5%22);%0A    %7D%0A%0A    @Test%0A    public void testSubtraction()%7B%0A        testOutput(%229.5-10%22, %22(9.5-10)%22, %22-0.5%22);%0A    %7D%0A%0A    @Test%0A    public void testMultiplication()%7B%0A        testOutput(%229.5*10%22, %22(9.5*10)%22, %2295%22);%0A    %7D%0A%0A    @Test%0A    public void testDivision()%7B%0A        testOutput(%229.5/2%22, %22(9.5/2)%22, %224.75%22);%0A    %7D%0A    %0A
 %7D%0A

Add tests for basic operations.