View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.cpd;
5   
6   import static org.junit.Assert.assertEquals;
7   import net.sourceforge.pmd.PMD;
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  }