1 package test.net.sourceforge.pmd.ast;
2
3 import static org.junit.Assert.assertTrue;
4 import net.sourceforge.pmd.PMD;
5 import net.sourceforge.pmd.ast.ASTBooleanLiteral;
6
7 import org.junit.Test;
8
9 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 =
30 "class Foo { " + PMD.EOL +
31 " boolean bar = true; " + PMD.EOL +
32 "} ";
33
34 private static final String TEST2 =
35 "class Foo { " + PMD.EOL +
36 " boolean bar = false; " + PMD.EOL +
37 "} ";
38
39 public static junit.framework.Test suite() {
40 return new junit.framework.JUnit4TestAdapter(ASTBooleanLiteralTest.class);
41 }
42 }