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.whitespace;
21
22 import static com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck.MSG_CONTAINS_TAB;
23 import static com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck.MSG_FILE_CONTAINS_TAB;
24
25 import org.junit.jupiter.api.Test;
26
27 import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
28
29 public class FileTabCharacterCheckTest
30 extends AbstractModuleTestSupport {
31
32 @Override
33 protected String getPackageLocation() {
34 return "com/puppycrawl/tools/checkstyle/checks/whitespace/filetabcharacter";
35 }
36
37 @Test
38 public void testDefault() throws Exception {
39 final String[] expected = {
40 "22:25: " + getCheckMessage(MSG_FILE_CONTAINS_TAB),
41 };
42 verifyWithInlineConfigParser(
43 getPath("InputFileTabCharacterSimple.java"),
44 expected);
45 }
46
47 @Test
48 public void testCustomMessage() throws Exception {
49 final String msgFileContainsTab =
50 "File contains tab characters (this is the first instance) :)";
51 final String[] expected = {
52 "14:25: " + msgFileContainsTab,
53 };
54 verifyWithInlineConfigParser(
55 getPath("InputFileTabCharacterCustomMessage.java"),
56 expected);
57 }
58
59 @Test
60 public void testVerbose() throws Exception {
61 final String[] expected = {
62 "22:25: " + getCheckMessage(MSG_CONTAINS_TAB),
63 "148:35: " + getCheckMessage(MSG_CONTAINS_TAB),
64 "151:28: " + getCheckMessage(MSG_CONTAINS_TAB),
65 "159:9: " + getCheckMessage(MSG_CONTAINS_TAB),
66 "160:10: " + getCheckMessage(MSG_CONTAINS_TAB),
67 "161:1: " + getCheckMessage(MSG_CONTAINS_TAB),
68 "162:3: " + getCheckMessage(MSG_CONTAINS_TAB),
69 "163:3: " + getCheckMessage(MSG_CONTAINS_TAB),
70 };
71 verifyWithInlineConfigParser(
72 getPath("InputFileTabCharacterSimple1.java"),
73 expected);
74 }
75
76 }