    1   package test.net.sourceforge.pmd.ast;
    2
    3   import net.sourceforge.pmd.PMD;
    4   import net.sourceforge.pmd.ast.ASTSwitchLabel;
    5   import test.net.sourceforge.pmd.testframework.ParserTst;
    6
    7   import java.util.Set;
    8
    9   public class ASTSwitchLabelTest extends ParserTst {
    10
    11      public void testDefaultOff() throws Throwable {
    12          Set ops = getNodes(ASTSwitchLabel.class, TEST1);
    13          assertFalse(((ASTSwitchLabel) (ops.iterator().next())).isDefault());
    14      }
    15
    16      public void testDefaultSet() throws Throwable {
    17          Set ops = getNodes(ASTSwitchLabel.class, TEST2);
    18          assertTrue(((ASTSwitchLabel) (ops.iterator().next())).isDefault());
    19      }
    20
    21
    22      private static final String TEST1 =
    23              "public class Foo {" + PMD.EOL +
    24              " void bar() {" + PMD.EOL +
    25              "  switch (x) {" + PMD.EOL +
    26              "   case 1: y = 2;" + PMD.EOL +
    27              "  }" + PMD.EOL +
    28              " }" + PMD.EOL +
    29              "}";
    30
    31      private static final String TEST2 =
    32              "public class Foo {" + PMD.EOL +
    33              " void bar() {" + PMD.EOL +
    34              "  switch (x) {" + PMD.EOL +
    35              "   default: y = 2;" + PMD.EOL +
    36              "  }" + PMD.EOL +
    37              " }" + PMD.EOL +
    38              "}";
    39  }