01: package com.puppycrawl.tools.checkstyle.checks.coding;
02:
03: import java.io.File;
04: import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
05: import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
06:
07: /**
08: * Test fixture for the UnnecessaryParenthesesCheck.
09: *
10: * @author Eric K. Roe
11: */
12: public class UnnecessaryParenthesesCheckTest extends BaseCheckTestCase {
13: private static final String TEST_FILE = "coding" + File.separator
14: + "InputUnnecessaryParentheses.java";
15:
16: public void testDefault() throws Exception {
17: final DefaultConfiguration checkConfig = createCheckConfig(UnnecessaryParenthesesCheck.class);
18:
19: final String[] expected = {
20: "4:22: Unnecessary parentheses around assignment right-hand side.",
21: "4:29: Unnecessary parentheses around expression.",
22: "4:31: Unnecessary parentheses around identifier 'i'.",
23: "4:46: Unnecessary parentheses around assignment right-hand side.",
24: "5:15: Unnecessary parentheses around assignment right-hand side.",
25: "6:14: Unnecessary parentheses around identifier 'x'.",
26: "6:17: Unnecessary parentheses around assignment right-hand side.",
27: "7:15: Unnecessary parentheses around assignment right-hand side.",
28: "8:14: Unnecessary parentheses around identifier 'x'.",
29: "8:17: Unnecessary parentheses around assignment right-hand side.",
30: "11:22: Unnecessary parentheses around assignment right-hand side.",
31: "11:30: Unnecessary parentheses around identifier 'i'.",
32: "11:46: Unnecessary parentheses around assignment right-hand side.",
33: "15:17: Unnecessary parentheses around literal '0'.",
34: "25:11: Unnecessary parentheses around assignment right-hand side.",
35: "29:11: Unnecessary parentheses around assignment right-hand side.",
36: "31:11: Unnecessary parentheses around assignment right-hand side.",
37: "33:11: Unnecessary parentheses around assignment right-hand side.",
38: "34:16: Unnecessary parentheses around identifier 'a'.",
39: "35:14: Unnecessary parentheses around identifier 'a'.",
40: "35:20: Unnecessary parentheses around identifier 'b'.",
41: "35:26: Unnecessary parentheses around literal '600'.",
42: "35:40: Unnecessary parentheses around literal '12.5f'.",
43: "35:56: Unnecessary parentheses around identifier 'arg2'.",
44: "36:14: Unnecessary parentheses around string \"this\".",
45: "36:25: Unnecessary parentheses around string \"that\".",
46: "37:11: Unnecessary parentheses around assignment right-hand side.",
47: "37:14: Unnecessary parentheses around string \"this is a really, really...\".",
48: "39:16: Unnecessary parentheses around return value.",
49: "43:21: Unnecessary parentheses around literal '1'.",
50: "43:26: Unnecessary parentheses around literal '13.5'.",
51: "44:22: Unnecessary parentheses around literal 'true'.",
52: "45:17: Unnecessary parentheses around identifier 'b'.",
53: "49:17: Unnecessary parentheses around assignment right-hand side.",
54: "51:11: Unnecessary parentheses around assignment right-hand side.",
55: "53:16: Unnecessary parentheses around return value.",
56: "63:13: Unnecessary parentheses around expression.",
57: "67:16: Unnecessary parentheses around expression.",
58: "72:19: Unnecessary parentheses around expression.",
59: "73:23: Unnecessary parentheses around literal '4000'.",
60: "78:19: Unnecessary parentheses around assignment right-hand side.",
61: "80:11: Unnecessary parentheses around assignment right-hand side.",
62: "80:16: Unnecessary parentheses around literal '3'.",
63: "81:27: Unnecessary parentheses around assignment right-hand side.", };
64:
65: verify(checkConfig, getPath(TEST_FILE), expected);
66: }
67:
68: public void test15Extensions() throws Exception {
69: final DefaultConfiguration checkConfig = createCheckConfig(UnnecessaryParenthesesCheck.class);
70: final String[] expected = {};
71: verify(checkConfig, getPath("Input15Extensions.java"), expected);
72: }
73: }
|