    1   package test.net.sourceforge.pmd.ast;
    2
    3   import net.sourceforge.pmd.PMD;
    4   import net.sourceforge.pmd.ast.ASTLiteral;
    5   import test.net.sourceforge.pmd.testframework.ParserTst;
    6
    7   import java.util.Set;
    8
    9   public class ASTLiteralTest extends ParserTst {
    10
    11      public void testIsStringLiteral() throws Throwable {
    12          Set literals = getNodes(ASTLiteral.class, TEST1);
    13          assertTrue(((ASTLiteral)(literals.iterator().next())).isStringLiteral());
    14      }
    15
    16      public void testIsNotStringLiteral() throws Throwable {
    17          Set literals = getNodes(ASTLiteral.class, TEST2);
    18          assertTrue(!((ASTLiteral)(literals.iterator().next())).isStringLiteral());
    19      }
    20
    21      private static final String TEST1 =
    22      "public class Foo {" + PMD.EOL +
    23      "  String x = \"foo\";" + PMD.EOL +
    24      "}";
    25
    26      private static final String TEST2 =
    27      "public class Foo {" + PMD.EOL +
    28      "  int x = 42;" + PMD.EOL +
    29      "}";
    30
    31  }