View Javadoc

    1   package net.sourceforge.pmd.ast;
    2
    3   import static org.junit.Assert.assertFalse;
    4   import static org.junit.Assert.assertTrue;
    5   import net.sourceforge.pmd.PMD;
    6   import net.sourceforge.pmd.lang.java.ast.ASTBooleanLiteral;
    7   import net.sourceforge.pmd.testframework.ParserTst;
    8
    9   import org.junit.Test;
    10
    11
    12  import java.util.Set;
    13
    14  public class ASTBooleanLiteralTest extends ParserTst {
    15
    16      @Test
    17      public void testTrue() throws Throwable {
    18          Set ops = getNodes(ASTBooleanLiteral.class, TEST1);
    19          ASTBooleanLiteral b = (ASTBooleanLiteral) ops.iterator().next();
    20          assertTrue(b.isTrue());
    21      }
    22
    23      @Test
    24      public void testFalse() throws Throwable {
    25          Set ops = getNodes(ASTBooleanLiteral.class, TEST2);
    26          ASTBooleanLiteral b = (ASTBooleanLiteral) ops.iterator().next();
    27          assertFalse(b.isTrue());
    28      }
    29
    30      private static final String TEST1 =
    31              "class Foo { " + PMD.EOL +
    32              " boolean bar = true; " + PMD.EOL +
    33              "} ";
    34
    35      private static final String TEST2 =
    36              "class Foo { " + PMD.EOL +
    37              " boolean bar = false; " + PMD.EOL +
    38              "} ";
    39
    40      public static junit.framework.Test suite() {
    41          return new junit.framework.JUnit4TestAdapter(ASTBooleanLiteralTest.class);
    42      }
    43  }