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.IllegalTokenTextCheck.MSG_KEY;
23
24 import org.junit.jupiter.api.Test;
25
26 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
27
28 public class IllegalTokenTextCheckExamplesTest extends AbstractExamplesModuleTestSupport {
29
30 @Override
31 public String getPackageLocation() {
32 return "com/puppycrawl/tools/checkstyle/checks/coding/illegaltokentext";
33 }
34
35 @Test
36 public void testExample1() throws Exception {
37 final String[] expected = {};
38
39 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
40 }
41
42 @Test
43 public void testExample2() throws Exception {
44 final String[] expected = {
45 "18:20: " + getCheckMessage(MSG_KEY, "a href"),
46 };
47
48 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
49 }
50
51 @Test
52 public void testExample3() throws Exception {
53 final String[] expected = {
54 "19:20: " + getCheckMessage(MSG_KEY, "a href"),
55 "21:20: " + getCheckMessage(MSG_KEY, "a href"),
56 };
57
58 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
59 }
60
61 @Test
62 public void testExample4() throws Exception {
63 final String[] expected = {
64 "1:3: " + getCheckMessage(MSG_KEY, "a href"),
65 "14:3: " + getCheckMessage(MSG_KEY, "a href"),
66 };
67
68 verifyWithInlineConfigParser(getPath("Example4.java"), expected);
69 }
70
71 @Test
72 public void testUseCase1() throws Exception {
73 final String[] expected = {
74 "23:29: " + getCheckMessage(MSG_KEY, '"'),
75 };
76
77 verifyWithInlineConfigParser(getPath("UseCase1.java"), expected);
78 }
79
80 @Test
81 public void testUseCase2() throws Exception {
82 final String[] expected = {
83 "28:16: " + getCheckMessage(MSG_KEY, "^0[^lx]"),
84 "30:17: " + getCheckMessage(MSG_KEY, "^0[^lx]"),
85 };
86
87 verifyWithInlineConfigParser(getPath("UseCase2.java"), expected);
88 }
89
90 @Test
91 public void testExample5() throws Exception {
92 final String[] expected = {
93 "19:20: Custom illegal text found",
94 "21:20: Custom illegal text found",
95 "22:19: Custom illegal text found",
96 };
97
98 verifyWithInlineConfigParser(getPath("Example5.java"), expected);
99 }
100
101 }