1 package com.puppycrawl.tools.checkstyle.checks.whitespace; 2 3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase; 4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration; 5 6 public class MethodParamPadCheckTest 7 extends BaseCheckTestCase 8 { 9 private DefaultConfiguration checkConfig; 10 11 public void setUp() 12 { 13 checkConfig = createCheckConfig(MethodParamPadCheck.class); 14 } 15 16 public void testDefault() throws Exception 17 { 18 final String [] expected = { 19 "11:32: '(' is preceded with whitespace.", 20 "13:15: '(' is preceded with whitespace.", 21 "17:9: '(' should be on the previous line.", 22 "20:13: '(' should be on the previous line.", 23 "27:24: '(' is preceded with whitespace.", 24 "32:9: '(' should be on the previous line.", 25 "36:39: '(' is preceded with whitespace.", 26 "38:13: '(' should be on the previous line.", 27 "42:16: '(' is preceded with whitespace.", 28 "44:13: '(' should be on the previous line.", 29 "50:21: '(' is preceded with whitespace.", 30 "52:13: '(' should be on the previous line.", 31 "56:18: '(' is preceded with whitespace.", 32 "58:13: '(' should be on the previous line.", 33 "61:36: '(' is preceded with whitespace.", 34 "63:13: '(' should be on the previous line.", 35 }; 36 verify(checkConfig, getPath("whitespace/InputMethodParamPad.java"), expected); 37 } 38 39 public void testAllowLineBreaks() throws Exception 40 { 41 checkConfig.addAttribute("allowLineBreaks", "true"); 42 final String [] expected = { 43 "11:32: '(' is preceded with whitespace.", 44 "13:15: '(' is preceded with whitespace.", 45 "27:24: '(' is preceded with whitespace.", 46 "36:39: '(' is preceded with whitespace.", 47 "42:16: '(' is preceded with whitespace.", 48 "50:21: '(' is preceded with whitespace.", 49 "56:18: '(' is preceded with whitespace.", 50 "61:36: '(' is preceded with whitespace.", 51 }; 52 verify(checkConfig, getPath("whitespace/InputMethodParamPad.java"), expected); 53 } 54 55 public void testSpaceOption() throws Exception 56 { 57 checkConfig.addAttribute("option", "space"); 58 final String [] expected = { 59 "6:31: '(' is not preceded with whitespace.", 60 "8:14: '(' is not preceded with whitespace.", 61 "17:9: '(' should be on the previous line.", 62 "20:13: '(' should be on the previous line.", 63 "23:23: '(' is not preceded with whitespace.", 64 "32:9: '(' should be on the previous line.", 65 "35:58: '(' is not preceded with whitespace.", 66 "38:13: '(' should be on the previous line.", 67 "41:15: '(' is not preceded with whitespace.", 68 "44:13: '(' should be on the previous line.", 69 "47:28: '(' is not preceded with whitespace.", 70 "49:20: '(' is not preceded with whitespace.", 71 "52:13: '(' should be on the previous line.", 72 "54:56: '(' is not preceded with whitespace.", 73 "55:17: '(' is not preceded with whitespace.", 74 "58:13: '(' should be on the previous line.", 75 "60:35: '(' is not preceded with whitespace.", 76 "63:13: '(' should be on the previous line.", 77 "66:25: '(' is not preceded with whitespace.", 78 "69:66: '(' is not preceded with whitespace.", 79 "70:57: '(' is not preceded with whitespace.", 80 }; 81 verify(checkConfig, getPath("whitespace/InputMethodParamPad.java"), expected); 82 } 83 84 public void test1322879() throws Exception 85 { 86 checkConfig.addAttribute("option", PadOption.SPACE.toString()); 87 final String [] expected = { 88 }; 89 verify(checkConfig, getPath("whitespace/InputWhitespaceAround.java"), 90 expected); 91 } 92 } 93 | Popular Tags |