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 NoWhitespaceAfterCheckTest 7 extends BaseCheckTestCase 8 { 9 private DefaultConfiguration checkConfig; 10 11 public void setUp() 12 { 13 checkConfig = createCheckConfig(NoWhitespaceAfterCheck.class); 14 } 15 16 public void testDefault() throws Exception 17 { 18 checkConfig.addAttribute("allowLineBreaks", "false"); 19 final String [] expected = { 20 "5:14: '.' is followed by whitespace.", 21 "6:12: '.' is followed by whitespace.", 22 "29:14: '-' is followed by whitespace.", 23 "29:21: '+' is followed by whitespace.", 24 "31:15: '++' is followed by whitespace.", 25 "31:22: '--' is followed by whitespace.", 26 "111:22: '!' is followed by whitespace.", 27 "112:23: '~' is followed by whitespace.", 28 "129:24: '.' is followed by whitespace.", 29 "132:11: '.' is followed by whitespace.", 30 "136:12: '.' is followed by whitespace.", 31 }; 32 verify(checkConfig, getPath("InputWhitespace.java"), expected); 33 } 34 35 public void testDotAllowLineBreaks() throws Exception 36 { 37 checkConfig.addAttribute("tokens", "DOT"); 38 final String [] expected = { 39 "5:14: '.' is followed by whitespace.", 40 "129:24: '.' is followed by whitespace.", 41 "136:12: '.' is followed by whitespace." 42 }; 43 verify(checkConfig, getPath("InputWhitespace.java"), expected); 44 } 45 46 public void testTypecast() throws Exception 47 { 48 checkConfig.addAttribute("tokens", "TYPECAST"); 49 final String [] expected = { 50 "87:28: ')' is followed by whitespace.", 51 "89:23: ')' is followed by whitespace.", 52 "241:22: ')' is followed by whitespace.", 53 }; 54 verify(checkConfig, getPath("InputWhitespace.java"), expected); 55 } 56 57 } 58 | Popular Tags |