01: package test.net.sourceforge.pmd.ast;
02:
03: import static org.junit.Assert.assertTrue;
04: import net.sourceforge.pmd.PMD;
05: import net.sourceforge.pmd.ast.ASTBooleanLiteral;
06:
07: import org.junit.Test;
08:
09: import test.net.sourceforge.pmd.testframework.ParserTst;
10:
11: import java.util.Set;
12:
13: public class ASTBooleanLiteralTest extends ParserTst {
14:
15: @Test
16: public void testTrue() throws Throwable {
17: Set ops = getNodes(ASTBooleanLiteral.class, TEST1);
18: ASTBooleanLiteral b = (ASTBooleanLiteral) ops.iterator().next();
19: assertTrue(b.isTrue());
20: }
21:
22: @Test
23: public void testFalse() throws Throwable {
24: Set ops = getNodes(ASTBooleanLiteral.class, TEST2);
25: ASTBooleanLiteral b = (ASTBooleanLiteral) ops.iterator().next();
26: assertTrue(!b.isTrue());
27: }
28:
29: private static final String TEST1 = "class Foo { " + PMD.EOL
30: + " boolean bar = true; " + PMD.EOL + "} ";
31:
32: private static final String TEST2 = "class Foo { " + PMD.EOL
33: + " boolean bar = false; " + PMD.EOL + "} ";
34:
35: public static junit.framework.Test suite() {
36: return new junit.framework.JUnit4TestAdapter(
37: ASTBooleanLiteralTest.class);
38: }
39: }
|