Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/puppycrawl/tools/checkstyle/checks/NoWhitespaceBeforeCheckTest.java


1   package com.puppycrawl.tools.checkstyle.checks;
2   
3   import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
4   import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
5   
6   public class NoWhitespaceBeforeCheckTest
7       extends BaseCheckTestCase
8   {
9       private DefaultConfiguration checkConfig;
10  
11      public void setUp() {
12          checkConfig = createCheckConfig(NoWhitespaceBeforeCheck.class);
13      }
14  
15      public void testDefault() throws Exception
16      {
17          final String[] expected = {
18              "30:14: '++' is preceeded with whitespace.",
19              "30:21: '--' is preceeded with whitespace.",
20              "176:18: ';' is preceeded with whitespace.",
21              "178:23: ';' is preceeded with whitespace.",
22          };
23          verify(checkConfig, getPath("InputWhitespace.java"), expected);
24      }
25  
26      public void testDot() throws Exception
27      {
28          checkConfig.addAttribute("tokens", "DOT");
29          final String[] expected = {
30              "5:12: '.' is preceeded with whitespace.",
31              "6:4: '.' is preceeded with whitespace.",
32              "129:17: '.' is preceeded with whitespace.",
33              "135:12: '.' is preceeded with whitespace.",
34              "136:10: '.' is preceeded with whitespace.",
35          };
36          verify(checkConfig, getPath("InputWhitespace.java"), expected);
37      }
38  
39  
40      public void testDotAllowLineBreaks() throws Exception
41      {
42          checkConfig.addAttribute("tokens", "DOT");
43          checkConfig.addAttribute("allowLineBreaks", "yes");
44          final String[] expected = {
45              "5:12: '.' is preceeded with whitespace.",
46              "129:17: '.' is preceeded with whitespace.",
47              "136:10: '.' is preceeded with whitespace.",
48          };
49          verify(checkConfig, getPath("InputWhitespace.java"), expected);
50      }
51  
52  }