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.coding;
21
22 import static com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck.MSG_KEY;
23
24 import org.junit.jupiter.api.Test;
25
26 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
27
28 public class InnerAssignmentCheckExamplesTest extends AbstractExamplesModuleTestSupport {
29 @Override
30 protected String getPackageLocation() {
31 return "com/puppycrawl/tools/checkstyle/checks/coding/innerassignment";
32 }
33
34 @Test
35 public void testExample1() throws Exception {
36 final String[] expected = {
37 "21:11: " + getCheckMessage(MSG_KEY),
38 "22:11: " + getCheckMessage(MSG_KEY),
39 "29:51: " + getCheckMessage(MSG_KEY),
40 "33:24: " + getCheckMessage(MSG_KEY),
41 "40:17: " + getCheckMessage(MSG_KEY),
42 "44:20: " + getCheckMessage(MSG_KEY),
43 "54:16: " + getCheckMessage(MSG_KEY),
44 };
45
46 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
47 }
48
49 @Test
50 public void testExample2() throws Exception {
51 final String[] expected = {
52 "18:19: " + getCheckMessage(MSG_KEY),
53 "20:17: " + getCheckMessage(MSG_KEY),
54 "22:20: " + getCheckMessage(MSG_KEY),
55 "39:15: " + getCheckMessage(MSG_KEY),
56 };
57
58 verifyWithInlineConfigParser(
59 getNonCompilablePath("Example2.java"), expected);
60 }
61 }