package testCal;

import junit.framework.TestCase;
import cal.ExpressionTreeController;

public class ExpressionTreeTest extends TestCase {

    private ExpressionTreeController expTree;

    @Override
    public void setUp() throws Exception {
    }

    @Override
    public void tearDown() throws Exception {
        expTree = null;
    }

    //
    // public void testParseToPostfix() {
    // String expected = "21-342*+-";
    // String result = expTree.parseToPostfix("((2-1)-(3+(4*2)))");
    // assertEquals(expected, result);
    // }

    // nested parentheses
    public void testParseResult() {
        String expected = "-10.0";
        expTree = new ExpressionTreeController("((2-1)-(3+(4*2)))");
        String actual = expTree.execute();
        assertEquals(expected, actual);
    }
    // simple calculation
    public void testParseResult2() {
        String expected = "8.0";
        expTree= new ExpressionTreeController("(1+2)*3-1");
        String actual = expTree.execute();
        assertEquals(expected, actual);
    }
    // two parentheses 
    public void testParseResult3() {
        String expected = "7.0";
        expTree= new ExpressionTreeController("(1+2)*3-(1*2)");
        String actual = expTree.execute();
        assertEquals(expected, actual);
    }
    
    public void testParseResult4() {
        String expected = "81.0";
        expTree= new ExpressionTreeController("((1+2)*3)^(1*2)");
        String actual = expTree.execute();
        assertEquals(expected, actual);
    }
    //nested parentheses
    public void testParseResult5() {
        String expected = "4.0";
        expTree= new ExpressionTreeController("(1-2)*3-((1*2)-9)");
        String actual = expTree.execute();
        assertEquals(expected, actual);
    }
    // nested parentheses
    public void testParseResult6() {
        String expected = "10.0";
        expTree= new ExpressionTreeController("(2-1)*3-((1*2)-9)");
        String actual = expTree.execute();
        assertEquals(expected, actual);
    }
    // more complicate case of single level parentheses 
    public void testParseResult7() {
        String expected = "64.0";
        expTree= new ExpressionTreeController("(6+2)*(10*4)/(2*2.5)");
        String actual = expTree.execute();
        assertEquals(expected, actual);
    }
    // nested parentheses with addition only
    public void testParseResult8() {
        String expected = "27.0";
        expTree= new ExpressionTreeController("((2+3)+5)+((2+8)+(4+3))");
        String actual = expTree.execute();
        assertEquals(expected, actual);
    }
}

@@ -340,212 +340,8 @@
  %7D%0A%0A
-    //%0A    // public void testParseToPostfix() %7B%0A    // String expected = %2221-342*+-%22;%0A    // String result = expTree.parseToPostfix(%22((2-1)-(3+(4*2)))%22);%0A    // assertEquals(expected, result);%0A    // %7D%0A%0A
     
@@ -354,32 +354,32 @@
 ted parentheses%0A
+
     public void 
@@ -587,24 +587,29 @@
 ual);%0A    %7D%0A
+    %0A
     // simpl
@@ -837,24 +837,29 @@
 ual);%0A    %7D%0A
+    %0A
     // two p
@@ -1320,24 +1320,29 @@
 ual);%0A    %7D%0A
+    %0A
     //nested
@@ -1573,32 +1573,37 @@
  actual);%0A    %7D%0A
+    %0A
     // nested pa
@@ -1836,24 +1836,29 @@
 ual);%0A    %7D%0A
+    %0A
     // more 
@@ -2129,24 +2129,29 @@
 ual);%0A    %7D%0A
+    %0A
     // neste
@@ -2250,24 +2250,24 @@
 d = %2227.0%22;%0A
-
         expT
@@ -2417,10 +2417,262 @@
 ;%0A    %7D%0A
+    %0A    // sin cos tan%0A    public void testParseResult9() %7B%0A        String expected = %220.72%22;%0A        expTree= new ExpressionTreeController(%22sin45*cos45*tan45%22);%0A        String actual = expTree.execute();%0A        assertEquals(expected, actual);%0A    %7D%0A
 %7D%0A

add test case for sin cos tan