View Javadoc

1   package org.kuali.student.common.messagebuilder.booleanmessage.ast;
2   
3   import java.util.List;
4   
5   import org.junit.Assert;
6   import org.junit.Test;
7   import org.kuali.student.common.messagebuilder.booleanmessage.ast.BooleanFunction;
8   
9   public class BooleanFunctionTest {
10  
11  	@Test
12  	public void testVariables() throws Exception {
13  		BooleanFunction bf = new BooleanFunction("(A*B)+(C*D)");
14  		List<String> variables = bf.getVariables();
15  		
16  		Assert.assertEquals(4, variables.size());
17  		Assert.assertTrue(variables.contains("A"));
18  		Assert.assertTrue(variables.contains("B"));
19  		Assert.assertTrue(variables.contains("C"));
20  		Assert.assertTrue(variables.contains("D"));
21  	}
22  
23  	@Test
24  	public void testSymbols() throws Exception {
25  		BooleanFunction bf = new BooleanFunction("(A*B)+(C*D)");
26  		List<String> symbols = bf.getSymbols();
27  		
28  		Assert.assertEquals(11, symbols.size());
29  		Assert.assertTrue(symbols.contains("("));
30  		Assert.assertTrue(symbols.contains("A"));
31  		Assert.assertTrue(symbols.contains("*"));
32  		Assert.assertTrue(symbols.contains("B"));
33  		Assert.assertTrue(symbols.contains(")"));
34  		Assert.assertTrue(symbols.contains("+"));
35  		Assert.assertTrue(symbols.contains("("));
36  		Assert.assertTrue(symbols.contains("C"));
37  		Assert.assertTrue(symbols.contains("*"));
38  		Assert.assertTrue(symbols.contains("D"));
39  		Assert.assertTrue(symbols.contains(")"));
40  	}
41  }