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.indentation;
21
22 import org.junit.jupiter.api.Test;
23
24 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
25
26 public class CommentsIndentationCheckExamplesTest extends AbstractExamplesModuleTestSupport {
27
28 @Override
29 public String getPackageLocation() {
30 return "com/puppycrawl/tools/checkstyle/checks/indentation/commentsindentation";
31 }
32
33 @Test
34 public void testExample1() throws Exception {
35 final String[] expected = {
36 "18:7: " + getCheckMessage(
37 CommentsIndentationCheck.MSG_KEY_BLOCK, 21, 6, 4),
38 "31:9: " + getCheckMessage(
39 CommentsIndentationCheck.MSG_KEY_SINGLE, 30, 8, 4),
40 };
41
42 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
43 }
44
45 @Test
46 public void testExample2() throws Exception {
47 final String[] expected = {
48 "33:9: " + getCheckMessage(
49 CommentsIndentationCheck.MSG_KEY_SINGLE, 32, 8, 4),
50 };
51
52 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
53 }
54
55 @Test
56 public void testUseCase1() throws Exception {
57 final String[] expected = {
58 "17:5: " + getCheckMessage(
59 CommentsIndentationCheck.MSG_KEY_SINGLE, 20, 4, 2),
60 };
61
62 verifyWithInlineConfigParser(getPath("UseCase1.java"), expected);
63 }
64
65 @Test
66 public void testUseCase2() throws Exception {
67 final String[] expected = {
68 "21:2: " + getCheckMessage(
69 CommentsIndentationCheck.MSG_KEY_SINGLE, 22, 1, 2),
70 };
71
72 verifyWithInlineConfigParser(getPath("UseCase2.java"), expected);
73 }
74
75 @Test
76 public void testUseCase3() throws Exception {
77 final String[] expected = {
78 "22:13: " + getCheckMessage(
79 CommentsIndentationCheck.MSG_KEY_SINGLE, 23, 12, 8),
80 "28:6: " + getCheckMessage(
81 CommentsIndentationCheck.MSG_KEY_SINGLE, "27, 29", 5, "6, 6"),
82 };
83
84 verifyWithInlineConfigParser(getPath("UseCase3.java"), expected);
85 }
86
87 @Test
88 public void testUseCase4() throws Exception {
89 final String[] expected = {
90 "15:5: " + getCheckMessage(
91 CommentsIndentationCheck.MSG_KEY_SINGLE, 16, 4, 8),
92 };
93
94 verifyWithInlineConfigParser(getPath("UseCase4.java"), expected);
95 }
96
97 @Test
98 public void testUseCase5() throws Exception {
99 final String[] expected = {
100 "22:15: " + getCheckMessage(
101 CommentsIndentationCheck.MSG_KEY_SINGLE, 25, 14, 4),
102 "23:10: " + getCheckMessage(
103 CommentsIndentationCheck.MSG_KEY_SINGLE, 25, 9, 4),
104 "24:8: " + getCheckMessage(
105 CommentsIndentationCheck.MSG_KEY_SINGLE, 25, 7, 4),
106 };
107
108 verifyWithInlineConfigParser(getPath("UseCase5.java"), expected);
109 }
110
111 @Test
112 public void testUseCase6() throws Exception {
113 final String[] expected = {
114 "24:6: " + getCheckMessage(
115 CommentsIndentationCheck.MSG_KEY_SINGLE, "23, 25", 5, "6, 4"),
116 };
117
118 verifyWithInlineConfigParser(getPath("UseCase6.java"), expected);
119 }
120
121 }