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;
21
22 import static com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck.MSG_KEY;
23
24 import org.junit.jupiter.api.Test;
25
26 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
27
28 public class TodoCommentCheckExamplesTest extends AbstractExamplesModuleTestSupport {
29
30 @Override
31 public String getPackageLocation() {
32 return "com/puppycrawl/tools/checkstyle/checks/todocomment";
33 }
34
35 @Test
36 public void testExample1() throws Exception {
37 final String[] expected = {
38 "16:14: " + getCheckMessage(MSG_KEY, "TODO:"),
39 };
40
41 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
42 }
43
44 @Test
45 public void testExample2() throws Exception {
46 final String[] expected = {
47 "1:3: " + getCheckMessage(MSG_KEY, "(?i)(TODO)|(FIXME)"),
48 "20:14: " + getCheckMessage(MSG_KEY, "(?i)(TODO)|(FIXME)"),
49 "22:14: " + getCheckMessage(MSG_KEY, "(?i)(TODO)|(FIXME)"),
50 "24:14: " + getCheckMessage(MSG_KEY, "(?i)(TODO)|(FIXME)"),
51 };
52
53 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
54 }
55
56 @Test
57 public void testUseCase1() throws Exception {
58 final String[] expected = {
59 "17:3: Comment uses box-like repetitive character pattern.",
60 "26:5: Comment uses box-like repetitive character pattern.",
61 "32:5: Comment uses box-like repetitive character pattern.",
62 "38:5: Comment uses box-like repetitive character pattern.",
63 };
64
65 verifyWithInlineConfigParser(getPath("UseCase1.java"), expected);
66 }
67
68 }