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.regexp;
21
22 import org.junit.jupiter.api.Test;
23
24 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
25
26 public class RegexpCheckExamplesTest extends AbstractExamplesModuleTestSupport {
27 @Override
28 public String getPackageLocation() {
29 return "com/puppycrawl/tools/checkstyle/checks/regexp/regexp";
30 }
31
32 @Test
33 public void testExample0() throws Exception {
34 final String[] expected = {
35
36 };
37
38 verifyWithInlineConfigParser(getPath("Example0.java"), expected);
39 }
40
41 @Test
42 public void testExample1() throws Exception {
43 final String[] expected = {};
44
45 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
46 }
47
48 @Test
49 public void testExample2() throws Exception {
50 final String[] expected = {
51 "1: Required pattern '// This code is copyrighted\\.' missing in file.",
52 };
53
54 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
55 }
56
57 @Test
58 public void testExample3() throws Exception {
59 final String[] expected = {
60
61 };
62
63 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
64 }
65
66 @Test
67 public void testExample4() throws Exception {
68 final String[] expected = {
69 "20: Found duplicate pattern '// This code is copyrighted\\n// \\(c\\) MyCompany'.",
70 };
71
72 verifyWithInlineConfigParser(getPath("Example4.java"), expected);
73 }
74
75 @Test
76 public void testExample5() throws Exception {
77 final String[] expected = {
78 "1: Required pattern 'Copyright' missing in file.",
79 };
80
81 verifyWithInlineConfigParser(getPath("Example5.java"), expected);
82 }
83
84 @Test
85 public void testExample6() throws Exception {
86 final String[] expected = {
87 "23: Line matches the illegal pattern 'System\\.out\\.println'.",
88 "24: Line matches the illegal pattern 'System\\.out\\.println'.",
89 };
90
91 verifyWithInlineConfigParser(getPath("Example6.java"), expected);
92 }
93
94 @Test
95 public void testExample7() throws Exception {
96 final String[] expected = {
97 "24: Line matches the illegal pattern 'System\\.out\\.println'.",
98 };
99
100 verifyWithInlineConfigParser(getPath("Example7.java"), expected);
101 }
102
103 @Test
104 public void testExample8() throws Exception {
105 final String[] expected = {
106 "17: Line matches the illegal pattern 'Trailing whitespace'.",
107 };
108
109 verifyWithInlineConfigParser(getPath("Example8.java"), expected);
110 }
111
112 @Test
113 public void testExample9() throws Exception {
114 final String[] expected = {
115 "17: Line matches the illegal pattern '(?i)fix me\\.'.",
116 };
117
118 verifyWithInlineConfigParser(getPath("Example9.java"), expected);
119 }
120
121 @Test
122 public void testExample10() throws Exception {
123 final String[] expected = {
124 "26: Line matches the illegal pattern"
125 + " 'The error limit has been exceeded, the check is aborting,"
126 + " there may be more unreported errors.(?i)fix me\\.'.",
127 };
128
129 verifyWithInlineConfigParser(getPath("Example10.java"), expected);
130 }
131
132 @Test
133 public void testExample11() throws Exception {
134 final String[] expected = {
135
136 };
137
138 verifyWithInlineConfigParser(getPath("Example11.java"), expected);
139 }
140 }