1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.puppycrawl.tools.checkstyle.checks.whitespace;
21
22 import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.MSG_WS_FOLLOWED;
23 import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.MSG_WS_NOT_FOLLOWED;
24 import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.MSG_WS_NOT_PRECEDED;
25 import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.MSG_WS_PRECEDED;
26
27 import org.junit.jupiter.api.Test;
28
29 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
30
31 public class ParenPadExamplesTest extends AbstractExamplesModuleTestSupport {
32 @Override
33 public String getPackageLocation() {
34 return "com/puppycrawl/tools/checkstyle/checks/whitespace/parenpad";
35 }
36
37 @Test
38 public void testExample1() throws Exception {
39 final String[] expected = {
40 "25:10: " + getCheckMessage(MSG_WS_FOLLOWED, "("),
41 "27:23: " + getCheckMessage(MSG_WS_PRECEDED, ")"),
42 "28:9: " + getCheckMessage(MSG_WS_FOLLOWED, "("),
43 "28:33: " + getCheckMessage(MSG_WS_PRECEDED, ")"),
44 "35:11: " + getCheckMessage(MSG_WS_FOLLOWED, "("),
45 "45:15: " + getCheckMessage(MSG_WS_PRECEDED, ")"),
46 "48:12: " + getCheckMessage(MSG_WS_FOLLOWED, "("),
47 "48:16: " + getCheckMessage(MSG_WS_PRECEDED, ")"),
48 "51:11: " + getCheckMessage(MSG_WS_FOLLOWED, "("),
49 };
50
51 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
52 }
53
54 @Test
55 public void testExample2() throws Exception {
56 final String[] expected = {
57 "29:25: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"),
58 "31:10: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("),
59 "49:12: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("),
60 "55:34: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"),
61 };
62
63 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
64 }
65
66 @Test
67 public void testExample3() throws Exception {
68 final String[] expected = {};
69 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
70 }
71 }