1 package com.puppycrawl.tools.checkstyle.checks.coding; 2 3 import java.io.File ; 4 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase; 5 import com.puppycrawl.tools.checkstyle.DefaultConfiguration; 6 7 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 { 18 final DefaultConfiguration checkConfig = 19 createCheckConfig(UnnecessaryParenthesesCheck.class); 20 21 final String [] expected = { 22 "4:22: Unnecessary parentheses around assignment right-hand side.", 23 "4:29: Unnecessary parentheses around expression.", 24 "4:31: Unnecessary parentheses around identifier 'i'.", 25 "4:46: Unnecessary parentheses around assignment right-hand side.", 26 "5:15: Unnecessary parentheses around assignment right-hand side.", 27 "6:14: Unnecessary parentheses around identifier 'x'.", 28 "6:17: Unnecessary parentheses around assignment right-hand side.", 29 "7:15: Unnecessary parentheses around assignment right-hand side.", 30 "8:14: Unnecessary parentheses around identifier 'x'.", 31 "8:17: Unnecessary parentheses around assignment right-hand side.", 32 "11:22: Unnecessary parentheses around assignment right-hand side.", 33 "11:30: Unnecessary parentheses around identifier 'i'.", 34 "11:46: Unnecessary parentheses around assignment right-hand side.", 35 "15:17: Unnecessary parentheses around literal '0'.", 36 "25:11: Unnecessary parentheses around assignment right-hand side.", 37 "29:11: Unnecessary parentheses around assignment right-hand side.", 38 "31:11: Unnecessary parentheses around assignment right-hand side.", 39 "33:11: Unnecessary parentheses around assignment right-hand side.", 40 "34:16: Unnecessary parentheses around identifier 'a'.", 41 "35:14: Unnecessary parentheses around identifier 'a'.", 42 "35:20: Unnecessary parentheses around identifier 'b'.", 43 "35:26: Unnecessary parentheses around literal '600'.", 44 "35:40: Unnecessary parentheses around literal '12.5f'.", 45 "35:56: Unnecessary parentheses around identifier 'arg2'.", 46 "36:14: Unnecessary parentheses around string \"this\".", 47 "36:25: Unnecessary parentheses around string \"that\".", 48 "37:11: Unnecessary parentheses around assignment right-hand side.", 49 "37:14: Unnecessary parentheses around string \"this is a really, really...\".", 50 "39:16: Unnecessary parentheses around return value.", 51 "43:21: Unnecessary parentheses around literal '1'.", 52 "43:26: Unnecessary parentheses around literal '13.5'.", 53 "44:22: Unnecessary parentheses around literal 'true'.", 54 "45:17: Unnecessary parentheses around identifier 'b'.", 55 "49:17: Unnecessary parentheses around assignment right-hand side.", 56 "51:11: Unnecessary parentheses around assignment right-hand side.", 57 "53:16: Unnecessary parentheses around return value.", 58 "63:13: Unnecessary parentheses around expression.", 59 "67:16: Unnecessary parentheses around expression.", 60 "72:19: Unnecessary parentheses around expression.", 61 "73:23: Unnecessary parentheses around literal '4000'.", 62 "78:19: Unnecessary parentheses around assignment right-hand side.", 63 "80:11: Unnecessary parentheses around assignment right-hand side.", 64 "80:16: Unnecessary parentheses around literal '3'.", 65 "81:27: Unnecessary parentheses around assignment right-hand side.", 66 }; 67 68 verify(checkConfig, getPath(TEST_FILE), expected); 69 } 70 71 public void test15Extensions() throws Exception 72 { 73 final DefaultConfiguration checkConfig = createCheckConfig(UnnecessaryParenthesesCheck.class); 74 final String [] expected = {}; 75 verify(checkConfig, getPath("Input15Extensions.java"), expected); 76 } 77 } 78 | Popular Tags |