KickJava   Java API By Example, From Geeks To Geeks.

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


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 ParenPadCheckTest
7     extends BaseCheckTestCase
8 {
9     public void testDefault()
10         throws Exception JavaDoc
11     {
12         final DefaultConfiguration checkConfig =
13             createCheckConfig(ParenPadCheck.class);
14         final String JavaDoc[] expected = {
15             "58:12: '(' is followed by whitespace.",
16             "58:36: ')' is preceded with whitespace.",
17             "74:13: '(' is followed by whitespace.",
18             "74:18: ')' is preceded with whitespace.",
19             "232:27: ')' is preceded with whitespace.",
20             "241:24: '(' is followed by whitespace.",
21             "241:30: ')' is preceded with whitespace.",
22         };
23         verify(checkConfig, getPath("InputWhitespace.java"), expected);
24     }
25
26     public void testSpace()
27         throws Exception JavaDoc
28     {
29         final DefaultConfiguration checkConfig =
30             createCheckConfig(ParenPadCheck.class);
31         checkConfig.addAttribute("option", PadOption.SPACE.toString());
32         final String JavaDoc[] expected = {
33             "29:20: '(' is not followed by whitespace.",
34             "29:23: ')' is not preceded with whitespace.",
35             "37:22: '(' is not followed by whitespace.",
36             "37:26: ')' is not preceded with whitespace.",
37             "41:15: '(' is not followed by whitespace.",
38             "41:33: ')' is not preceded with whitespace.",
39             "76:20: '(' is not followed by whitespace.",
40             "76:21: ')' is not preceded with whitespace.",
41             "97:22: '(' is not followed by whitespace.",
42             "97:28: ')' is not preceded with whitespace.",
43             "98:14: '(' is not followed by whitespace.",
44             "98:18: ')' is not preceded with whitespace.",
45             "150:28: '(' is not followed by whitespace.",
46             "150:32: ')' is not preceded with whitespace.",
47             "153:16: '(' is not followed by whitespace.",
48             "153:20: ')' is not preceded with whitespace.",
49             "160:21: '(' is not followed by whitespace.",
50             "160:34: ')' is not preceded with whitespace.",
51             "162:20: '(' is not followed by whitespace.",
52             "165:10: ')' is not preceded with whitespace.",
53             "178:14: '(' is not followed by whitespace.",
54             "178:36: ')' is not preceded with whitespace.",
55             "225:14: '(' is not followed by whitespace.",
56             "235:14: '(' is not followed by whitespace.",
57             "235:39: ')' is not preceded with whitespace.",
58         };
59         verify(checkConfig, getPath("InputWhitespace.java"), expected);
60     }
61
62     public void testDefaultForIterator()
63         throws Exception JavaDoc
64     {
65         final DefaultConfiguration checkConfig =
66             createCheckConfig(ParenPadCheck.class);
67         final String JavaDoc[] expected = {
68             "17:34: ')' is preceded with whitespace.",
69             "20:35: ')' is preceded with whitespace.",
70             "40:14: '(' is followed by whitespace.",
71             "40:36: ')' is preceded with whitespace.",
72             "43:14: '(' is followed by whitespace.",
73             "48:27: ')' is preceded with whitespace.",
74             "51:26: ')' is preceded with whitespace.",
75         };
76         verify(checkConfig, getPath("InputForWhitespace.java"), expected);
77     }
78
79     public void testSpaceEmptyForIterator()
80         throws Exception JavaDoc
81     {
82         final DefaultConfiguration checkConfig =
83             createCheckConfig(ParenPadCheck.class);
84         checkConfig.addAttribute("option", PadOption.SPACE.toString());
85         final String JavaDoc[] expected = {
86             "11:14: '(' is not followed by whitespace.",
87             "11:35: ')' is not preceded with whitespace.",
88             "14:14: '(' is not followed by whitespace.",
89             "14:34: ')' is not preceded with whitespace.",
90             "17:14: '(' is not followed by whitespace.",
91             "20:14: '(' is not followed by whitespace.",
92             "23:14: '(' is not followed by whitespace.",
93             "27:14: '(' is not followed by whitespace.",
94             "32:14: '(' is not followed by whitespace.",
95         };
96         verify(checkConfig, getPath("InputForWhitespace.java"), expected);
97     }
98
99     public void test1322879() throws Exception JavaDoc
100     {
101         final DefaultConfiguration checkConfig =
102             createCheckConfig(ParenPadCheck.class);
103         checkConfig.addAttribute("option", PadOption.SPACE.toString());
104         final String JavaDoc[] expected = {
105         };
106         verify(checkConfig, getPath("whitespace/InputWhitespaceAround.java"),
107                expected);
108     }
109 }
110
Popular Tags