1 package com.puppycrawl.tools.checkstyle.checks.coding; 2 3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase; 4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration; 5 6 import java.io.File ; 7 public class ReturnCountCheckTest extends BaseCheckTestCase 8 { 9 public void testDefault() throws Exception 10 { 11 final DefaultConfiguration checkConfig = 12 createCheckConfig(ReturnCountCheck.class); 13 final String [] expected = { 14 "18:5: Return count is 7 (max allowed is 2).", 15 "35:17: Return count is 6 (max allowed is 2).", 16 }; 17 verify(checkConfig, getPath("coding" + File.separator + "InputReturnCount.java"), expected); 18 } 19 20 public void testFormat() throws Exception 21 { 22 final DefaultConfiguration checkConfig = 23 createCheckConfig(ReturnCountCheck.class); 24 checkConfig.addAttribute("format", "^$"); 25 final String [] expected = { 26 "5:5: Return count is 7 (max allowed is 2).", 27 "18:5: Return count is 7 (max allowed is 2).", 28 "35:17: Return count is 6 (max allowed is 2).", 29 }; 30 verify(checkConfig, getPath("coding" + File.separator + "InputReturnCount.java"), expected); 31 } 32 } 33 | Popular Tags |