-
Notifications
You must be signed in to change notification settings - Fork 1
/
ExpressionTest.java
executable file
·31 lines (25 loc) · 1.22 KB
/
ExpressionTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import junit.framework.TestCase;
public class ExpressionTest extends TestCase {
public void testExpressionTrees1() throws IllegalLineException {
Expression expr = new Expression("(((k&m)|b)=>(k&m))");
assertEquals(expr.myRoot.myItem, "=>");
assertEquals(expr.myRoot.myLeft.myItem, "|");
assertEquals(expr.myRoot.myRight.myItem, "&");
assertEquals(expr.myRoot.myLeft.myLeft.myItem, "&");
assertEquals(expr.myRoot.myLeft.myRight.myItem, "b");
assertEquals(expr.myRoot.myRight.myLeft.myItem, "k");
assertEquals(expr.myRoot.myRight.myRight.myItem, "m");
assertEquals(expr.myRoot.myLeft.myLeft.myLeft.myItem, "k");
assertEquals(expr.myRoot.myLeft.myLeft.myRight.myItem, "m");
}
public void testExpressionTrees2() throws IllegalLineException {
Expression expr = new Expression("~~(p&q)");
assertEquals(expr.myRoot.myItem, "~");
assertEquals(expr.myRoot.myLeft.myItem, "~");
assertEquals(expr.myRoot.myLeft.myLeft.myItem, "&");
assertEquals(expr.myRoot.myLeft.myLeft.myLeft.myItem, "p");
assertEquals(expr.myRoot.myLeft.myLeft.myRight.myItem, "q");
assertEquals(expr.myRoot.myLeft.myLeft.myRight.myLeft, null);
assertEquals(expr.myRoot.myLeft.myLeft.myRight.myRight, null);
}
}