KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > whitespace > NoWhitespaceBeforeCheckTest


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 JavaDoc
16     {
17         final String JavaDoc[] 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             "211:15: ';' is preceded with whitespace.",
26         };
27         verify(checkConfig, getPath("InputWhitespace.java"), expected);
28     }
29
30     public void testDot() throws Exception JavaDoc
31     {
32         checkConfig.addAttribute("tokens", "DOT");
33         final String JavaDoc[] 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 JavaDoc
45     {
46         checkConfig.addAttribute("tokens", "DOT");
47         checkConfig.addAttribute("allowLineBreaks", "yes");
48         final String JavaDoc[] 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 }
57
Popular Tags