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.blocks;
21
22 import static com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck.MSG_KEY_BLOCK_EMPTY;
23 import static com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck.MSG_KEY_BLOCK_NO_STATEMENT;
24
25 import org.junit.jupiter.api.Test;
26
27 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
28
29 public class EmptyBlockCheckExamplesTest extends AbstractExamplesModuleTestSupport {
30
31 @Override
32 public String getPackageLocation() {
33 return "com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock";
34 }
35
36 @Test
37 public void testExample1() throws Exception {
38 final String[] expected = {
39 "15:34: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "for"),
40 "19:9: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "try"),
41 };
42
43 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
44 }
45
46 @Test
47 public void testExample2() throws Exception {
48 final String[] expected = {
49 "22:9: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "try"),
50 };
51
52 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
53 }
54
55 @Test
56 public void testExample3() throws Exception {
57 final String[] expected = {
58 "30:15: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "case"),
59 "31:15: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "case"),
60 "32:15: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "case"),
61 "35:16: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "case"),
62 "48:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "case"),
63 "49:18: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "case"),
64 };
65
66 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
67 }
68
69 }