Source code: com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java
1 package com.puppycrawl.tools.checkstyle.checks.whitespace;
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 preceded with whitespace.",
19 "30:21: '--' is preceded with whitespace.",
20 "176:18: ';' is preceded with whitespace.",
21 "178:23: ';' is preceded with whitespace.",
22 "185:18: ';' is preceded with whitespace.",
23 "187:27: ';' is preceded with whitespace.",
24 "195:26: ';' is preceded with whitespace.",
25 "208:15: ';' is preceded with whitespace.",
26 };
27 verify(checkConfig, getPath("InputWhitespace.java"), expected);
28 }
29
30 public void testDot() throws Exception
31 {
32 checkConfig.addAttribute("tokens", "DOT");
33 final String[] expected = {
34 "5:12: '.' is preceded with whitespace.",
35 "6:4: '.' is preceded with whitespace.",
36 "129:17: '.' is preceded with whitespace.",
37 "135:12: '.' is preceded with whitespace.",
38 "136:10: '.' is preceded with whitespace.",
39 };
40 verify(checkConfig, getPath("InputWhitespace.java"), expected);
41 }
42
43
44 public void testDotAllowLineBreaks() throws Exception
45 {
46 checkConfig.addAttribute("tokens", "DOT");
47 checkConfig.addAttribute("allowLineBreaks", "yes");
48 final String[] expected = {
49 "5:12: '.' is preceded with whitespace.",
50 "129:17: '.' is preceded with whitespace.",
51 "136:10: '.' is preceded with whitespace.",
52 };
53 verify(checkConfig, getPath("InputWhitespace.java"), expected);
54 }
55
56 }