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 LeftCurlyCheckTest extends BaseCheckTestCase 7 { 8 private DefaultConfiguration mCheckConfig; 9 10 public void setUp() 11 { 12 mCheckConfig = createCheckConfig(LeftCurlyCheck.class); 13 } 14 15 public void testDefault() throws Exception 16 { 17 final String [] expected = { 18 "8:1: '{' should be on the previous line.", 19 "12:5: '{' should be on the previous line.", 20 "21:5: '{' should be on the previous line.", 21 "30:5: '{' should be on the previous line.", 22 "39:5: '{' should be on the previous line.", 23 }; 24 verify(mCheckConfig, getPath("InputScopeInnerInterfaces.java"), expected); 25 } 26 27 public void testNL() throws Exception 28 { 29 mCheckConfig.addAttribute("option", LeftCurlyOption.NL.toString()); 30 final String [] expected = { 31 "49:14: '{' should be on a new line.", 32 "53:14: '{' should be on a new line.", 33 "58:18: '{' should be on a new line.", 34 "62:18: '{' should be on a new line.", 35 "67:12: '{' should be on a new line.", 36 "72:18: '{' should be on a new line.", 37 }; 38 verify(mCheckConfig, getPath("InputScopeInnerInterfaces.java"), expected); 39 } 40 41 public void testNLOW() throws Exception 42 { 43 mCheckConfig.addAttribute("option", LeftCurlyOption.NLOW.toString()); 44 final String [] expected = { 45 "8:1: '{' should be on the previous line.", 46 "12:5: '{' should be on the previous line.", 47 "21:5: '{' should be on the previous line.", 48 "30:5: '{' should be on the previous line.", 49 "39:5: '{' should be on the previous line.", 50 "49:14: '{' should be on a new line.", 51 "53:14: '{' should be on a new line.", 52 "58:18: '{' should be on a new line.", 53 "62:18: '{' should be on a new line.", 54 "67:12: '{' should be on a new line.", 55 "72:18: '{' should be on a new line.", 56 }; 57 verify(mCheckConfig, getPath("InputScopeInnerInterfaces.java"), expected); 58 } 59 60 public void testDefault2() throws Exception 61 { 62 final String [] expected = { 63 "12:1: '{' should be on the previous line.", 64 "17:5: '{' should be on the previous line.", 65 "24:5: '{' should be on the previous line.", 66 "31:5: '{' should be on the previous line.", 67 "39:1: '{' should be on the previous line.", 68 "41:5: '{' should be on the previous line.", 69 "46:9: '{' should be on the previous line.", 70 "53:9: '{' should be on the previous line.", 71 "69:5: '{' should be on the previous line.", 72 "77:5: '{' should be on the previous line.", 73 "84:5: '{' should be on the previous line.", 74 }; 75 verify(mCheckConfig, getPath("InputLeftCurlyMethod.java"), expected); 76 } 77 78 public void testNL2() throws Exception 79 { 80 mCheckConfig.addAttribute("option", LeftCurlyOption.NL.toString()); 81 final String [] expected = { 82 "14:39: '{' should be on a new line.", 83 "21:20: '{' should be on a new line.", 84 "34:31: '{' should be on a new line.", 85 "43:24: '{' should be on a new line.", 86 "56:35: '{' should be on a new line.", 87 "60:24: '{' should be on a new line.", 88 "74:20: '{' should be on a new line.", 89 "87:31: '{' should be on a new line.", 90 }; 91 verify(mCheckConfig, getPath("InputLeftCurlyMethod.java"), expected); 92 } 93 public void testDefault3() throws Exception 94 { 95 final String [] expected = { 96 "12:1: '{' should be on the previous line.", 97 "15:5: '{' should be on the previous line.", 98 "19:9: '{' should be on the previous line.", 99 "21:13: '{' should be on the previous line.", 100 "23:17: '{' should be on the previous line.", 101 "30:17: '{' should be on the previous line.", 102 "34:17: '{' should be on the previous line.", 103 "42:13: '{' should be on the previous line.", 104 "46:13: '{' should be on the previous line.", 105 "52:9: '{' should be on the previous line.", 106 "54:13: '{' should be on the previous line.", 107 "63:9: '{' should be on the previous line.", 108 "83:5: '{' should be on the previous line.", 109 "89:5: '{' should be on the previous line.", 110 }; 111 verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected); 112 } 113 114 public void testNL3() throws Exception 115 { 116 mCheckConfig.addAttribute("option", LeftCurlyOption.NL.toString()); 117 final String [] expected = { 118 "26:33: '{' should be on a new line.", 119 "91:19: '{' should be on a new line.", 120 "97:19: '{' should be on a new line.", 121 }; 122 verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected); 123 } 124 125 public void testMissingBraces() throws Exception 126 { 127 final String [] expected = { 128 "12:1: '{' should be on the previous line.", 129 "15:5: '{' should be on the previous line.", 130 "21:5: '{' should be on the previous line.", 131 "34:5: '{' should be on the previous line.", 132 "51:5: '{' should be on the previous line.", 133 "69:5: '{' should be on the previous line.", 134 "105:5: '{' should be on the previous line.", 135 }; 136 verify(mCheckConfig, getPath("InputBraces.java"), expected); 137 } 138 } 139 | Popular Tags |