View Javadoc

    1   package net.sourceforge.pmd.cpd;
    2
    3   import static org.junit.Assert.assertEquals;
    4   import net.sourceforge.pmd.PMD;
    5   import net.sourceforge.pmd.cpd.AnyTokenizer;
    6   import net.sourceforge.pmd.cpd.SourceCode;
    7   import net.sourceforge.pmd.cpd.Tokens;
    8
    9   import org.junit.Test;
    10
    11  public class AnyTokenizerTest {
    12
    13      @Test
    14      public void testMultiLineMacros() throws Throwable {
    15          AnyTokenizer tokenizer = new AnyTokenizer();
    16          SourceCode code = new SourceCode(new SourceCode.StringCodeLoader(TEST1));
    17          Tokens tokens = new Tokens();
    18          tokenizer.tokenize(code, tokens);
    19          assertEquals(30, tokens.size());
    20      }
    21
    22      private static final String TEST1 =
    23              "using System;" + PMD.EOL +
    24              "namespace HelloNameSpace {" + PMD.EOL +
    25              "" + PMD.EOL +
    26              "    public class HelloWorld {" + PMD.EOL +
    27              "        static void Main(string[] args) {" + PMD.EOL +
    28              "            Console.WriteLine(\"Hello World!\");" + PMD.EOL +
    29              "        }" + PMD.EOL +
    30              "    }" + PMD.EOL +
    31              "}" + PMD.EOL;
    32
    33      public static junit.framework.Test suite() {
    34          return new junit.framework.JUnit4TestAdapter(AnyTokenizerTest.class);
    35      }
    36  }