01: package com.puppycrawl.tools.checkstyle.checks.usage;
02:
03: import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
04: import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
05:
06: public class OneMethodPrivateFieldCheckTest extends BaseCheckTestCase {
07: public void testDefault() throws Exception {
08: final DefaultConfiguration checkConfig = createCheckConfig(OneMethodPrivateFieldCheck.class);
09: final String[] expected = {
10: "6:24: Field 'SFIELD0' is used in only one method.",
11: "7:24: Field 'SFIELD1' is used in only one method.",
12: "8:24: Field 'SFIELD2' is used in only one method.",
13: "9:24: Field 'SFIELD3' is used in only one method.",
14: "11:17: Field 'mField0' is used in only one method.",
15: "12:17: Field 'mField1' is used in only one method.",
16: "13:17: Field 'mField2' is used in only one method.",
17: "47:17: Field 'mField0' is used in only one method.",
18: "48:17: Field 'mField1' is used in only one method.",
19: "49:17: Field 'mField2' is used in only one method.",
20: "105:19: Field 'mField' is used in only one method.", };
21: verify(checkConfig,
22: getPath("usage/InputOneMethodPrivateField.java"),
23: expected);
24: }
25:
26: public void testIgnoreFormat() throws Exception {
27: final DefaultConfiguration checkConfig = createCheckConfig(OneMethodPrivateFieldCheck.class);
28: checkConfig.addAttribute("ignoreFormat", "2$");
29: final String[] expected = {
30: "6:24: Field 'SFIELD0' is used in only one method.",
31: "7:24: Field 'SFIELD1' is used in only one method.",
32: "9:24: Field 'SFIELD3' is used in only one method.",
33: "11:17: Field 'mField0' is used in only one method.",
34: "12:17: Field 'mField1' is used in only one method.",
35: "47:17: Field 'mField0' is used in only one method.",
36: "48:17: Field 'mField1' is used in only one method.",
37: "105:19: Field 'mField' is used in only one method.", };
38: verify(checkConfig,
39: getPath("usage/InputOneMethodPrivateField.java"),
40: expected);
41: }
42: }
|