    1   package test.net.sourceforge.pmd.rules;
    2
    3   import net.sourceforge.pmd.PMD;
    4   import net.sourceforge.pmd.rules.SuspiciousOctalEscape;
    5   import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
    6   import test.net.sourceforge.pmd.testframework.TestDescriptor;
    7
    8   public class SuspiciousOctalEscapeTest extends SimpleAggregatorTst {
    9       public void testAll() {
    10          runTests(new TestDescriptor[]{
    11              new TestDescriptor(TEST1, "ok use of octal", 0, new SuspiciousOctalEscape()),
    12              new TestDescriptor(TEST2, "should be flagged", 1, new SuspiciousOctalEscape()),
    13          });
    14      }
    15
    16      private static final String TEST1 =
    17              "public class Foo {" + PMD.EOL +
    18              " void bar() {" + PMD.EOL +
    19              "  int x = \128;" + PMD.EOL +
    20              " }" + PMD.EOL +
    21              "}";
    22
    23      private static final String TEST2 =
    24              "public class Foo {" + PMD.EOL +
    25              " void bar() {" + PMD.EOL +
    26              "  System.out.println(\"foo = //128\");" + PMD.EOL +
    27              " }" + PMD.EOL +
    28              "}";
    29  }