1 package com.puppycrawl.tools.checkstyle.checks.naming; 2 3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase; 4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration; 5 6 public class ParameterNameCheckTest 7 extends BaseCheckTestCase 8 { 9 public void testCatch() 10 throws Exception 11 { 12 final DefaultConfiguration checkConfig = 13 createCheckConfig(ParameterNameCheck.class); 14 checkConfig.addAttribute("format", "^NO_WAY_MATEY$"); 15 final String [] expected = { 16 }; 17 verify(checkConfig, getPath("InputLeftCurlyOther.java"), expected); 18 } 19 20 public void testSpecified() 21 throws Exception 22 { 23 final DefaultConfiguration checkConfig = 24 createCheckConfig(ParameterNameCheck.class); 25 checkConfig.addAttribute("format", "^a[A-Z][a-zA-Z0-9]*$"); 26 final String [] expected = { 27 "71:19: Name 'badFormat1' must match pattern '^a[A-Z][a-zA-Z0-9]*$'.", 28 "71:34: Name 'badFormat2' must match pattern '^a[A-Z][a-zA-Z0-9]*$'.", 29 "72:25: Name 'badFormat3' must match pattern '^a[A-Z][a-zA-Z0-9]*$'.", 30 }; 31 verify(checkConfig, getPath("InputSimple.java"), expected); 32 } 33 34 public void testDefault() 35 throws Exception 36 { 37 final DefaultConfiguration checkConfig = 38 createCheckConfig(ParameterNameCheck.class); 39 final String [] expected = { 40 }; 41 verify(checkConfig, getPath("InputSimple.java"), expected); 42 } 43 } 44 | Popular Tags |