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.sizes;
21
22 import static com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck.MSG_KEY;
23
24 import org.junit.jupiter.api.Test;
25
26 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
27 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
28
29 public class LineLengthCheckExamplesTest extends AbstractExamplesModuleTestSupport {
30 @Override
31 protected String getPackageLocation() {
32 return "com/puppycrawl/tools/checkstyle/checks/sizes/linelength";
33 }
34
35 @Test
36 public void testExample1() throws Exception {
37 final String[] expected = {
38 "13: " + getCheckMessage(MSG_KEY, 80, 84),
39 "21: " + getCheckMessage(MSG_KEY, 80, 92),
40 };
41
42 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
43 }
44
45 @Test
46 public void testExample2() throws Exception {
47 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
48 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
49 }
50
51 @Test
52 public void testExample3() throws Exception {
53 final String[] expected = {
54 "11: " + getCheckMessage(MSG_KEY, 80, 83),
55 "23: " + getCheckMessage(MSG_KEY, 80, 92),
56 };
57
58 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
59 }
60
61 @Test
62 public void testExample4() throws Exception {
63 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
64 verifyWithInlineConfigParser(getPath("Example4.java"), expected);
65 }
66
67 @Test
68 public void testExample5() throws Exception {
69 final String[] expected = {
70 "11: " + getCheckMessage(MSG_KEY, 60, 64),
71 "17: " + getCheckMessage(MSG_KEY, 60, 84),
72 "25: " + getCheckMessage(MSG_KEY, 60, 92),
73 };
74
75 verifyWithInlineConfigParser(getPath("Example5.java"), expected);
76 }
77 }