1 package com.puppycrawl.tools.checkstyle.checks.blocks; 2 3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase; 4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration; 5 6 public class RightCurlyCheckTest extends BaseCheckTestCase 7 { 8 private DefaultConfiguration mCheckConfig; 9 10 public void setUp() 11 { 12 mCheckConfig = createCheckConfig(RightCurlyCheck.class); 13 } 14 15 public void testDefault() throws Exception 16 { 17 final String [] expected = { 18 "25:17: '}' should be on the same line.", 19 "28:17: '}' should be on the same line.", 20 "40:13: '}' should be on the same line.", 21 "44:13: '}' should be on the same line.", 22 "93:27: '}' should be alone on a line.", 23 "93:27: '}' should be on a new line.", 24 }; 25 verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected); 26 } 27 28 public void testSame() throws Exception 29 { 30 mCheckConfig.addAttribute("option", RightCurlyOption.SAME.toString()); 31 final String [] expected = { 32 "25:17: '}' should be on the same line.", 33 "28:17: '}' should be on the same line.", 34 "40:13: '}' should be on the same line.", 35 "44:13: '}' should be on the same line.", 36 "93:27: '}' should be alone on a line.", 37 "93:27: '}' should be on a new line.", 38 }; 39 verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected); 40 } 41 42 public void testAlone() throws Exception 43 { 44 mCheckConfig.addAttribute("option", RightCurlyOption.ALONE.toString()); 45 final String [] expected = { 46 "93:27: '}' should be alone on a line.", 47 "93:27: '}' should be on a new line.", 48 }; 49 verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected); 50 } 51 52 public void testShouldStartLine() throws Exception 53 { 54 mCheckConfig.addAttribute("option", RightCurlyOption.ALONE.toString()); 55 mCheckConfig.addAttribute("shouldStartLine", "false"); 56 final String [] expected = { 57 "93:27: '}' should be alone on a line.", 58 }; 59 verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected); 60 } 61 } 62 | Popular Tags |