1 package com.puppycrawl.tools.checkstyle.checks.indentation; 2 3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase; 4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration; 5 import com.puppycrawl.tools.checkstyle.Checker; 6 7 11 public class IndentationCheckTest extends BaseCheckTestCase { 12 public void testInvalidLabel() 13 throws Exception 14 { 15 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 16 final String [] expected = { 17 "20: label child at indentation level 10 not at correct indentation, 8", 18 "24: label child at indentation level 16 not at correct indentation, 12", 19 "29: label child at indentation level 2 not at correct indentation, 4", 20 "32: label child at indentation level 18 not at correct indentation, 8", 21 "33: ctor def child at indentation level 18 not at correct indentation, 8", 22 "35: label child at indentation level 6 not at correct indentation, 8", 23 "35: method call child at indentation level 6 not at correct indentation, 8", 24 "37: label child at indentation level 6 not at correct indentation, 8", 25 "37: method call child at indentation level 6 not at correct indentation, 8", 26 }; 27 verify(checkConfig, getPath("indentation/InputInvalidLabelIndent.java"), expected); 28 } 29 30 public void testValidLabel() 31 throws Exception 32 { 33 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 34 final String [] expected = { 35 }; 36 verify(checkConfig, getPath("indentation/InputValidLabelIndent.java"), expected); 37 } 38 39 public void testValidIfWithChecker() 40 throws Exception 41 { 42 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 43 final Checker c = createChecker(checkConfig); 44 final String fname = getPath("indentation/InputValidIfIndent.java"); 45 final String [] expected = { 46 }; 47 verify(c, fname, expected); 48 } 49 50 public void testValidDotWithChecker() 51 throws Exception 52 { 53 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 54 final Checker c = createChecker(checkConfig); 55 final String fname = getPath("indentation/InputValidDotIndent.java"); 56 final String [] expected = { 57 }; 58 verify(c, fname, expected); 59 } 60 61 public void testValidMethodWithChecker() 62 throws Exception 63 { 64 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 65 final Checker c = createChecker(checkConfig); 66 final String fname = getPath("indentation/InputValidMethodIndent.java"); 67 final String [] expected = { 68 }; 69 verify(c, fname, expected); 70 } 71 72 public void testInvalidMethodWithChecker() 73 throws Exception 74 { 75 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 76 final Checker c = createChecker(checkConfig); 77 final String fname = getPath("indentation/InputInvalidMethodIndent.java"); 78 final String [] expected = { 79 "17: ctor def rcurly at indentation level 6 not at correct indentation, 4", 80 "20: ctor def modifier at indentation level 6 not at correct indentation, 4", 81 "21: ctor def lcurly at indentation level 2 not at correct indentation, 4", 82 "22: ctor def rcurly at indentation level 6 not at correct indentation, 4", 83 "25: method def modifier at indentation level 2 not at correct indentation, 4", 84 "26: method def rcurly at indentation level 6 not at correct indentation, 4", 85 "63: method def modifier at indentation level 5 not at correct indentation, 4", 86 "64: method def modifier at indentation level 5 not at correct indentation, 4", 87 "65: method def return type at indentation level 5 not at correct indentation, 4", 88 "74: method def modifier at indentation level 3 not at correct indentation, 4", 89 "75: method def modifier at indentation level 3 not at correct indentation, 4", 90 "76: method def return type at indentation level 3 not at correct indentation, 4", 91 "77: method def at indentation level 5 not at correct indentation, 4", 92 "87: ctor def child at indentation level 4 not at correct indentation, 8", 93 "87: method call child at indentation level 4 not at correct indentation, 8", 94 "92: method def child at indentation level 6 not at correct indentation, 8", 95 "93: if at indentation level 6 not at correct indentation, 8", 96 "94: if child at indentation level 10 not at correct indentation, 12", 97 "94: method call child at indentation level 10 not at correct indentation, 12", 98 "95: if rcurly at indentation level 6 not at correct indentation, 8", 99 "98: method call child at indentation level 10 not at correct indentation, 12", 100 "104: method call child at indentation level 14 not at correct indentation, 16", 101 "107: method call child at indentation level 10 not at correct indentation, 12", 102 "112: method call child at indentation level 14 not at correct indentation, 16", 103 "116: method call child at indentation level 10 not at correct indentation, 12", 104 "120: method call child at indentation level 10 not at correct indentation, 12", 105 "121: method call rparen at indentation level 6 not at correct indentation, 8", 106 "125: method call rparen at indentation level 6 not at correct indentation, 8", 107 "139: method call child at indentation level 10 not at correct indentation, 12", 108 "142: method call child at indentation level 10 not at correct indentation, 12", 109 "152: method call child at indentation level 6 not at correct indentation, 12", 110 "158: method def throws at indentation level 6 not at correct indentation, 8", 111 "164: method def child at indentation level 4 not at correct indentation, 8", 112 "169: method def child at indentation level 4 not at correct indentation, 8", 113 "173: method def return type at indentation level 0 not at correct indentation, 4", 114 }; 115 verify(c, fname, expected); 116 } 117 118 public void testInvalidSwitchWithChecker() 119 throws Exception 120 { 121 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 122 final Checker c = createChecker(checkConfig); 123 final String fname = getPath("indentation/InputInvalidSwitchIndent.java"); 124 final String [] expected = { 125 "26: switch at indentation level 6 not at correct indentation, 8", 126 "28: case child at indentation level 10 not at correct indentation, 12", 127 "29: block child at indentation level 14 not at correct indentation, 16", 128 "29: method call child at indentation level 14 not at correct indentation, 16", 129 "33: block child at indentation level 14 not at correct indentation, 16", 130 "35: case child at indentation level 14 not at correct indentation, 12", 131 "36: case child at indentation level 10 not at correct indentation, 12", 132 "39: case child at indentation level 10 not at correct indentation, 12", 133 "40: block child at indentation level 14 not at correct indentation, 16", 134 "40: method call child at indentation level 14 not at correct indentation, 16", 135 "41: block child at indentation level 14 not at correct indentation, 16", 136 "49: block child at indentation level 14 not at correct indentation, 16", 137 "49: method call child at indentation level 14 not at correct indentation, 16", 138 "50: block child at indentation level 18 not at correct indentation, 16", 139 "51: block rcurly at indentation level 10 not at correct indentation, 12", 140 "55: block lcurly at indentation level 10 not at correct indentation, 12", 141 "58: block rcurly at indentation level 14 not at correct indentation, 12", 142 "62: block lcurly at indentation level 14 not at correct indentation, 12", 143 "65: block rcurly at indentation level 10 not at correct indentation, 12", 144 "72: case child at indentation level 14 not at correct indentation, 16", 145 "77: case child at indentation level 14 not at correct indentation, 16", 146 "85: switch rcurly at indentation level 6 not at correct indentation, 8", 147 "88: switch lcurly at indentation level 6 not at correct indentation, 8", 148 "89: switch rcurly at indentation level 10 not at correct indentation, 8", 149 "91: switch lcurly at indentation level 10 not at correct indentation, 8", 150 "92: switch rcurly at indentation level 6 not at correct indentation, 8", 151 }; 152 verify(c, fname, expected); 153 } 154 155 public void testValidSwitchWithChecker() 156 throws Exception 157 { 158 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 159 final Checker c = createChecker(checkConfig); 160 final String fname = getPath("indentation/InputValidSwitchIndent.java"); 161 final String [] expected = { 162 }; 163 verify(c, fname, expected); 164 } 165 166 public void testValidArrayInitWithChecker() 167 throws Exception 168 { 169 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 170 final Checker c = createChecker(checkConfig); 171 final String fname = getPath("indentation/InputValidArrayInitIndent.java"); 172 final String [] expected = { 173 }; 174 verify(c, fname, expected); 175 } 176 177 public void testInvalidArrayInitWithChecker() 178 throws Exception 179 { 180 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 181 final Checker c = createChecker(checkConfig); 182 final String fname = getPath("indentation/InputInvalidArrayInitIndent.java"); 183 final String [] expected = { 184 "17: member def type at indentation level 2 not at correct indentation, 4", 185 "18: member def type at indentation level 6 not at correct indentation, 4", 186 "20: member def type at indentation level 2 not at correct indentation, 4", 187 "22: array initialization rcurly at indentation level 6 not at correct indentation, 2", 188 "24: member def type at indentation level 6 not at correct indentation, 4", 189 "25: array initialization child at indentation level 8 not at correct indentation, 10", 190 "26: array initialization rcurly at indentation level 4 not at correct indentation, 6", 191 "29: array initialization child at indentation level 9 not at correct indentation, 8", 192 "30: array initialization child at indentation level 7 not at correct indentation, 8", 193 "31: array initialization child at indentation level 9 not at correct indentation, 8", 194 "36: array initialization lcurly at indentation level 2 not at correct indentation, 4", 195 "40: array initialization rcurly at indentation level 6 not at correct indentation, 4", 196 "44: array initialization lcurly at indentation level 2 not at correct indentation, 4", 197 "48: array initialization child at indentation level 20 not at correct indentation, [8, 31]", 198 "49: array initialization child at indentation level 4 not at correct indentation, [8, 31]", 199 "54: array initialization child at indentation level 6 not at correct indentation, 8", 200 "59: member def type at indentation level 2 not at correct indentation, 4", 201 "61: member def type at indentation level 6 not at correct indentation, 4", 202 "62: array initialization rcurly at indentation level 2 not at correct indentation, 6", 203 "65: array initialization child at indentation level 6 not at correct indentation, 8", 204 "72: array initialization child at indentation level 10 not at correct indentation, 12", 205 "85: array initialization child at indentation level 8 not at correct indentation, 12", 206 "96: array initialization child at indentation level 10 not at correct indentation, 12", 207 "97: array initialization child at indentation level 14 not at correct indentation, 12", 208 "100: array initialization child at indentation level 10 not at correct indentation, 12", 209 "101: array initialization child at indentation level 14 not at correct indentation, 12", 210 "102: array initialization rcurly at indentation level 6 not at correct indentation, 8", 211 "105: array initialization lcurly at indentation level 6 not at correct indentation, 8", 212 "106: array initialization child at indentation level 14 not at correct indentation, 12", 213 "107: array initialization child at indentation level 10 not at correct indentation, 12", 214 "108: array initialization rcurly at indentation level 6 not at correct indentation, 8", 215 }; 216 verify(c, fname, expected); 217 } 218 219 public void testValidTryWithChecker() 220 throws Exception 221 { 222 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 223 final Checker c = createChecker(checkConfig); 224 final String fname = getPath("indentation/InputValidTryIndent.java"); 225 final String [] expected = { 226 }; 227 verify(c, fname, expected); 228 } 229 230 public void testInvalidTryWithChecker() 231 throws Exception 232 { 233 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 234 final Checker c = createChecker(checkConfig); 235 final String fname = getPath("indentation/InputInvalidTryIndent.java"); 236 final String [] expected = { 237 "21: try at indentation level 9 not at correct indentation, 8", 238 "22: try rcurly at indentation level 7 not at correct indentation, 8", 239 "24: catch rcurly at indentation level 7 not at correct indentation, 8", 240 "26: try at indentation level 4 not at correct indentation, 8", 241 "27: method call child at indentation level 8 not at correct indentation, 12", 242 "27: try child at indentation level 8 not at correct indentation, 12", 243 "28: try rcurly at indentation level 4 not at correct indentation, 8", 244 "29: finally child at indentation level 8 not at correct indentation, 12", 245 "29: method call child at indentation level 8 not at correct indentation, 12", 246 "34: catch child at indentation level 8 not at correct indentation, 12", 247 "34: method call child at indentation level 8 not at correct indentation, 12", 248 "39: try rcurly at indentation level 10 not at correct indentation, 8", 249 "41: catch rcurly at indentation level 6 not at correct indentation, 8", 250 "48: catch rcurly at indentation level 5 not at correct indentation, 8", 251 "55: catch child at indentation level 10 not at correct indentation, 12", 252 "55: method call child at indentation level 10 not at correct indentation, 12", 253 "56: catch child at indentation level 14 not at correct indentation, 12", 254 "57: catch child at indentation level 10 not at correct indentation, 12", 255 "57: method call child at indentation level 10 not at correct indentation, 12", 256 "59: catch at indentation level 6 not at correct indentation, 8", 257 "66: try lcurly at indentation level 10 not at correct indentation, 8", 258 "68: try rcurly at indentation level 10 not at correct indentation, 8", 259 "70: catch lcurly at indentation level 6 not at correct indentation, 8", 260 "73: catch rcurly at indentation level 10 not at correct indentation, 8", 261 "76: catch child at indentation level 10 not at correct indentation, 12", 262 "76: method call child at indentation level 10 not at correct indentation, 12", 263 }; 264 verify(c, fname, expected); 265 } 266 267 public void testInvalidClassDefWithChecker() 269 throws Exception 270 { 271 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 272 final Checker c = createChecker(checkConfig); 273 final String fname = getPath("indentation/InputInvalidClassDefIndent.java"); 274 final String [] expected = { 275 "19: class def ident at indentation level 2 not at correct indentation, 0", 276 "19: class def modifier at indentation level 2 not at correct indentation, 0", 277 "25: class def lcurly at indentation level 2 not at correct indentation, 0", 278 "28: class def rcurly at indentation level 2 not at correct indentation, 0", 279 "31: class def ident at indentation level 2 not at correct indentation, 0", 280 "35: class def rcurly at indentation level 2 not at correct indentation, 0", 281 "40: class def child at indentation level 2 not at correct indentation, 4", 282 "41: class def child at indentation level 2 not at correct indentation, 4", 283 "47: class def child at indentation level 2 not at correct indentation, 4", 284 "55: class def child at indentation level 2 not at correct indentation, 4", 285 "56: class def child at indentation level 2 not at correct indentation, 4", 286 "61: class def ident at indentation level 2 not at correct indentation, 0", 287 "61: class def modifier at indentation level 2 not at correct indentation, 0", 288 "62: class def lcurly at indentation level 2 not at correct indentation, 0", 289 "70: class def rcurly at indentation level 2 not at correct indentation, 0", 290 "74: class def child at indentation level 2 not at correct indentation, 4", 291 "83: class def child at indentation level 2 not at correct indentation, 4", 292 "83: class def ident at indentation level 2 not at correct indentation, 4", 293 "85: class def ident at indentation level 6 not at correct indentation, 4", 294 "88: class def child at indentation level 2 not at correct indentation, 4", 295 "88: class def ident at indentation level 2 not at correct indentation, 4", 296 "92: member def modifier at indentation level 6 not at correct indentation, 8", 297 "93: member def type at indentation level 12 not at correct indentation, 8", 298 "98: member def type at indentation level 10 not at correct indentation, 8", 299 "103: member def modifier at indentation level 6 not at correct indentation, 8", 300 "108: class def rcurly at indentation level 6 not at correct indentation, 4", 301 "110: class def ident at indentation level 6 not at correct indentation, 4", 302 "116: class def child at indentation level 6 not at correct indentation, 8", 303 "116: class def ident at indentation level 6 not at correct indentation, 8", 304 "119: class def ident at indentation level 10 not at correct indentation, 8", 305 "121: class def rcurly at indentation level 10 not at correct indentation, 8", 306 "124: member def type at indentation level 10 not at correct indentation, 12", 307 "129: method def child at indentation level 10 not at correct indentation, 8", 308 "130: object def lcurly at indentation level 8 not at correct indentation, [10, 14]", 309 "134: object def rcurly at indentation level 8 not at correct indentation, [10, 14]", 310 "138: object def lcurly at indentation level 6 not at correct indentation, [8, 12]", 311 312 "139: method def modifier at indentation level 12 not at correct indentation, 10", 313 "141: method def rcurly at indentation level 12 not at correct indentation, 10", 314 315 "142: object def rcurly at indentation level 6 not at correct indentation, [8, 12]", 316 "147: method def modifier at indentation level 10 not at correct indentation, 12", 317 "149: method def rcurly at indentation level 10 not at correct indentation, 12", 318 }; 320 verify(c, fname, expected); 321 } 322 323 public void testInvalidBlockWithChecker() 324 throws Exception 325 { 326 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 327 final Checker c = createChecker(checkConfig); 328 final String fname = getPath("indentation/InputInvalidBlockIndent.java"); 329 final String [] expected = { 330 "22: block lcurly at indentation level 7 not at correct indentation, 8", 331 "23: block lcurly at indentation level 9 not at correct indentation, 8", 332 "25: block lcurly at indentation level 9 not at correct indentation, 8", 333 "26: block rcurly at indentation level 7 not at correct indentation, 8", 334 "28: block lcurly at indentation level 6 not at correct indentation, 8", 335 "30: block rcurly at indentation level 6 not at correct indentation, 8", 336 "31: block lcurly at indentation level 6 not at correct indentation, 8", 337 "34: block lcurly at indentation level 9 not at correct indentation, 8", 338 "35: block child at indentation level 13 not at correct indentation, 12", 339 "37: block child at indentation level 13 not at correct indentation, 12", 340 "38: block rcurly at indentation level 9 not at correct indentation, 8", 341 "41: block lcurly at indentation level 6 not at correct indentation, 8", 342 "42: block child at indentation level 10 not at correct indentation, 12", 343 "44: block child at indentation level 10 not at correct indentation, 12", 344 "45: block rcurly at indentation level 6 not at correct indentation, 8", 345 "48: block lcurly at indentation level 6 not at correct indentation, 8", 346 "51: block child at indentation level 10 not at correct indentation, 12", 347 "55: block lcurly at indentation level 10 not at correct indentation, 12", 348 "59: block rcurly at indentation level 10 not at correct indentation, 12", 349 "64: block child at indentation level 10 not at correct indentation, 12", 350 "66: block lcurly at indentation level 10 not at correct indentation, 12", 351 "67: block child at indentation level 14 not at correct indentation, 16", 352 "82: block rcurly at indentation level 10 not at correct indentation, 12", 353 "91: static initialization at indentation level 2 not at correct indentation, 4", 354 "92: static initialization at indentation level 6 not at correct indentation, 4", 355 "96: static initialization child at indentation level 7 not at correct indentation, 8", 356 "99: static initialization at indentation level 6 not at correct indentation, 4", 357 "101: static initialization rcurly at indentation level 2 not at correct indentation, 4", 358 "103: static initialization at indentation level 2 not at correct indentation, 4", 359 "105: static initialization rcurly at indentation level 6 not at correct indentation, 4", 360 "107: static initialization at indentation level 2 not at correct indentation, 4", 361 "109: static initialization child at indentation level 6 not at correct indentation, 8", 362 "112: static initialization lcurly at indentation level 2 not at correct indentation, 4", 363 "113: static initialization child at indentation level 6 not at correct indentation, 8", 364 "114: static initialization rcurly at indentation level 6 not at correct indentation, 4", 365 "119: static initialization child at indentation level 6 not at correct indentation, 8", 366 "124: static initialization child at indentation level 4 not at correct indentation, 8", 367 "125: static initialization rcurly at indentation level 2 not at correct indentation, 4", 368 "130: static initialization rcurly at indentation level 6 not at correct indentation, 4", 369 "133: block lcurly at indentation level 2 not at correct indentation, 4", 370 "134: block lcurly at indentation level 6 not at correct indentation, 4", 371 "137: block lcurly at indentation level 2 not at correct indentation, 4", 372 "139: block rcurly at indentation level 6 not at correct indentation, 4", 373 "141: block lcurly at indentation level 6 not at correct indentation, 4", 374 "143: block rcurly at indentation level 2 not at correct indentation, 4", 375 "146: block child at indentation level 6 not at correct indentation, 8", 376 377 }; 378 verify(c, fname, expected); 379 } 380 381 public void testInvalidIfWithChecker() 382 throws Exception 383 { 384 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 385 final Checker c = createChecker(checkConfig); 386 final String fname = getPath("indentation/InputInvalidIfIndent.java"); 387 final String [] expected = { 388 "50: if at indentation level 1 not at correct indentation, 8", 389 "55: if at indentation level 9 not at correct indentation, 8", 390 "56: if lcurly at indentation level 9 not at correct indentation, 8", 391 "57: if rcurly at indentation level 7 not at correct indentation, 8", 392 "59: if at indentation level 6 not at correct indentation, 8", 393 "60: if lcurly at indentation level 5 not at correct indentation, 8", 394 "61: if rcurly at indentation level 5 not at correct indentation, 8", 395 "65: if rcurly at indentation level 10 not at correct indentation, 8", 396 "66: else rcurly at indentation level 7 not at correct indentation, 8", 397 "69: if at indentation level 9 not at correct indentation, 8", 398 "70: if lcurly at indentation level 7 not at correct indentation, 8", 399 "72: else at indentation level 9 not at correct indentation, 8", 400 "74: else rcurly at indentation level 9 not at correct indentation, 8", 401 "77: if at indentation level 10 not at correct indentation, 8", 402 "78: if rcurly at indentation level 7 not at correct indentation, 8", 403 "79: else at indentation level 9 not at correct indentation, 8", 404 "80: else lcurly at indentation level 7 not at correct indentation, 8", 405 "81: else rcurly at indentation level 9 not at correct indentation, 8", 406 "85: if at indentation level 9 not at correct indentation, 8", 407 "86: if lcurly at indentation level 9 not at correct indentation, 8", 408 "87: if rcurly at indentation level 9 not at correct indentation, 8", 409 "88: else lcurly at indentation level 7 not at correct indentation, 8", 410 "89: else rcurly at indentation level 10 not at correct indentation, 8", 411 "92: if at indentation level 6 not at correct indentation, 8", 412 "93: if lcurly at indentation level 10 not at correct indentation, 8", 413 "94: if rcurly at indentation level 10 not at correct indentation, 8", 414 "95: else rcurly at indentation level 7 not at correct indentation, 8", 415 "98: if at indentation level 5 not at correct indentation, 8", 416 "99: if rcurly at indentation level 11 not at correct indentation, 8", 417 "100: else at indentation level 5 not at correct indentation, 8", 418 "101: else rcurly at indentation level 11 not at correct indentation, 8", 419 "121: if child at indentation level 14 not at correct indentation, 12", 421 "126: if lcurly at indentation level 10 not at correct indentation, 8", 422 "127: if child at indentation level 10 not at correct indentation, 12", 423 "127: method call child at indentation level 10 not at correct indentation, 12", 424 "132: if child at indentation level 14 not at correct indentation, 12", 425 "133: method call child at indentation level 10 not at correct indentation, 12", 427 "135: else child at indentation level 10 not at correct indentation, 12", 428 "135: method call child at indentation level 10 not at correct indentation, 12", 430 "136: method call child at indentation level 8 not at correct indentation, 12", 431 "143: if child at indentation level 16 not at correct indentation, 12", 432 "144: if rcurly at indentation level 9 not at correct indentation, 8", 433 "147: else child at indentation level 16 not at correct indentation, 12", 434 "153: if child at indentation level 0 not at correct indentation, 12", 435 "153: method call child at indentation level 0 not at correct indentation, 12", 436 "157: else child at indentation level 40 not at correct indentation, 12", 437 "164: if child at indentation level 14 not at correct indentation, 12", 438 "167: else child at indentation level 14 not at correct indentation, 12", 439 "173: if child at indentation level 10 not at correct indentation, 12", 440 "173: method call child at indentation level 10 not at correct indentation, 12", 441 "175: else child at indentation level 10 not at correct indentation, 12", 442 "175: method call child at indentation level 10 not at correct indentation, 12", 443 "179: if at indentation level 10 not at correct indentation, 8", 444 "180: if child at indentation level 14 not at correct indentation, 12", 445 "181: if rcurly at indentation level 10 not at correct indentation, 8", 446 "182: else at indentation level 10 not at correct indentation, 8", 447 "183: else child at indentation level 14 not at correct indentation, 12", 448 "184: else rcurly at indentation level 10 not at correct indentation, 8", 449 "187: if child at indentation level 9 not at correct indentation, 12", 450 "188: if child at indentation level 11 not at correct indentation, 12", 451 "192: if child at indentation level 10 not at correct indentation, 12", 452 "195: if rcurly at indentation level 7 not at correct indentation, 8", 453 "202: if child at indentation level 10 not at correct indentation, 12", 454 "202: method call child at indentation level 10 not at correct indentation, 12", 455 "204: if child at indentation level 10 not at correct indentation, 12", 456 "204: method call child at indentation level 10 not at correct indentation, 12", 457 "211: method call child at indentation level 10 not at correct indentation, 12", 458 "220: if at indentation level 10 not at correct indentation, 12", 459 "224: if child at indentation level 18 not at correct indentation, 20", 460 "224: method call child at indentation level 18 not at correct indentation, 20", 461 "228: if rcurly at indentation level 40 not at correct indentation, 8", 462 "235: if rparen at indentation level 10 not at correct indentation, 8", 463 "240: if rparen at indentation level 6 not at correct indentation, 8", 464 "246: if lparen at indentation level 6 not at correct indentation, 8", 465 "248: if rparen at indentation level 6 not at correct indentation, 8", 466 }; 467 verify(c, fname, expected); 468 } 469 470 public void testInvalidWhileWithChecker() 471 throws Exception 472 { 473 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 474 final Checker c = createChecker(checkConfig); 475 final String fname = getPath("indentation/InputInvalidWhileIndent.java"); 476 final String [] expected = { 477 "21: while at indentation level 9 not at correct indentation, 8", 478 "22: while rcurly at indentation level 7 not at correct indentation, 8", 479 "24: while at indentation level 7 not at correct indentation, 8", 480 "25: while lcurly at indentation level 9 not at correct indentation, 8", 481 "26: while rcurly at indentation level 9 not at correct indentation, 8", 482 "28: while at indentation level 9 not at correct indentation, 8", 483 "29: while lcurly at indentation level 6 not at correct indentation, 8", 484 "30: while child at indentation level 14 not at correct indentation, 12", 485 "31: while rcurly at indentation level 6 not at correct indentation, 8", 486 "33: while at indentation level 10 not at correct indentation, 8", 487 "35: while rcurly at indentation level 10 not at correct indentation, 8", 488 "37: while at indentation level 10 not at correct indentation, 8", 489 "40: while rcurly at indentation level 10 not at correct indentation, 8", 490 "42: while at indentation level 6 not at correct indentation, 8", 491 "43: while lcurly at indentation level 10 not at correct indentation, 8", 492 "46: while rcurly at indentation level 6 not at correct indentation, 8", 493 "49: if at indentation level 14 not at correct indentation, 12", 494 "50: if child at indentation level 18 not at correct indentation, 16", 495 "51: if rcurly at indentation level 14 not at correct indentation, 12", 496 "52: while child at indentation level 14 not at correct indentation, 12", 497 "53: while rcurly at indentation level 10 not at correct indentation, 8", 498 "56: while child at indentation level 10 not at correct indentation, 12", 499 "62: while child at indentation level 10 not at correct indentation, 12", 500 "67: while child at indentation level 10 not at correct indentation, 12", 501 "74: while rparen at indentation level 5 not at correct indentation, 8", 502 "81: while rparen at indentation level 10 not at correct indentation, 8", 503 "88: while rparen at indentation level 10 not at correct indentation, 8", 504 "95: while child at indentation level 8 not at correct indentation, 12", 505 }; 506 verify(c, fname, expected); 507 } 508 509 public void testInvalidForWithChecker() 510 throws Exception 511 { 512 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 513 final Checker c = createChecker(checkConfig); 514 final String fname = getPath("indentation/InputInvalidForIndent.java"); 515 final String [] expected = { 516 "22: for at indentation level 6 not at correct indentation, 8", 517 "23: for rcurly at indentation level 10 not at correct indentation, 8", 518 "25: for at indentation level 9 not at correct indentation, 8", 519 "26: for lcurly at indentation level 6 not at correct indentation, 8", 520 "27: for rcurly at indentation level 6 not at correct indentation, 8", 521 "31: for child at indentation level 10 not at correct indentation, 12", 522 "31: method call child at indentation level 10 not at correct indentation, 12", 523 "32: for rcurly at indentation level 10 not at correct indentation, 8", 524 "35: for lcurly at indentation level 10 not at correct indentation, 8", 525 "36: for child at indentation level 10 not at correct indentation, 12", 526 "44: for child at indentation level 10 not at correct indentation, 12", 527 "50: for at indentation level 7 not at correct indentation, 8", 528 "51: for child at indentation level 10 not at correct indentation, 12", 529 "60: for child at indentation level 7 not at correct indentation, 12", 530 "65: for at indentation level 6 not at correct indentation, 8", 531 "66: for child at indentation level 10 not at correct indentation, 12", 532 "67: for child at indentation level 14 not at correct indentation, 16", 533 "68: for child at indentation level 10 not at correct indentation, 12", 534 "73: for rcurly at indentation level 39 not at correct indentation, 8", 535 "77: for rparen at indentation level 12 not at correct indentation, 8", 536 }; 537 verify(c, fname, expected); 538 } 539 540 public void testValidForWithChecker() 541 throws Exception 542 { 543 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 544 final Checker c = createChecker(checkConfig); 545 final String fname = getPath("indentation/InputValidForIndent.java"); 546 final String [] expected = { 547 }; 548 verify(c, fname, expected); 549 } 550 551 public void testValidDoWhileWithChecker() 552 throws Exception 553 { 554 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 555 final Checker c = createChecker(checkConfig); 556 final String fname = getPath("indentation/InputValidDoWhileIndent.java"); 557 final String [] expected = { 558 }; 559 verify(c, fname, expected); 560 } 561 562 public void testValidBlockWithChecker() 563 throws Exception 564 { 565 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 566 final Checker c = createChecker(checkConfig); 567 final String fname = getPath("indentation/InputValidBlockIndent.java"); 568 final String [] expected = { 569 }; 570 verify(c, fname, expected); 571 } 572 573 574 public void testValidWhileWithChecker() 575 throws Exception 576 { 577 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 578 final Checker c = createChecker(checkConfig); 579 final String fname = getPath("indentation/InputValidWhileIndent.java"); 580 final String [] expected = { 581 }; 582 verify(c, fname, expected); 583 } 584 585 public void testValidClassDefWithChecker() 586 throws Exception 587 { 588 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 589 final Checker c = createChecker(checkConfig); 590 final String fname = getPath("indentation/InputValidClassDefIndent.java"); 591 final String [] expected = { 592 }; 593 verify(c, fname, expected); 594 } 595 596 public void testValidInterfaceDefWithChecker() 597 throws Exception 598 { 599 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 600 final Checker c = createChecker(checkConfig); 601 final String fname = getPath("indentation/InputValidInterfaceDefIndent.java"); 602 final String [] expected = { 603 }; 604 verify(c, fname, expected); 605 } 606 607 public void testValidCommaWithChecker() 608 throws Exception 609 { 610 611 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 612 final Checker c = createChecker(checkConfig); 613 final String fname = getPath("indentation/InputValidCommaIndent.java"); 614 final String [] expected = { 615 }; 616 verify(c, fname, expected); 617 } 618 619 public void testTabs() 620 throws Exception 621 { 622 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 623 checkConfig.addAttribute("basicOffset", new Integer (4).toString()); 624 checkConfig.addAttribute("tabWidth", new Integer (4).toString()); 625 final String [] expected = { 626 "25: ctor def child at indentation level 9 not at correct indentation, 8", 627 }; 628 verify(checkConfig, getPath("indentation/InputUseTabs.java"), expected); 629 } 630 631 public void testIndentationLevel() 632 throws Exception 633 { 634 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 635 checkConfig.addAttribute("basicOffset", new Integer (2).toString()); 636 final String [] expected = { 637 "25: ctor def child at indentation level 5 not at correct indentation, 4", 638 }; 639 verify(checkConfig, getPath("indentation/InputUseTwoSpaces.java"), expected); 640 } 641 642 public void testCaseLevel() 643 throws Exception 644 { 645 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 646 checkConfig.addAttribute("caseIndent", new Integer (0).toString()); 647 final String [] expected = { 648 "23: case child at indentation level 10 not at correct indentation, 8", 649 }; 650 verify(checkConfig, getPath("indentation/InputCaseLevel.java"), expected); 651 } 652 653 public void testBraceAdjustment() 654 throws Exception 655 { 656 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 657 checkConfig.addAttribute("braceAdjustment", new Integer (2).toString()); 658 final String [] expected = { 659 "24: if rcurly at indentation level 8 not at correct indentation, 10", 660 }; 661 verify(checkConfig, getPath("indentation/InputBraceAdjustment.java"), expected); 662 } 663 664 public void testInvalidAssignWithChecker() throws Exception 665 { 666 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 667 final String [] expected = { 668 "6: method call child at indentation level 10 not at correct indentation, 12", 669 "8: method call child at indentation level 10 not at correct indentation, 12", 670 "10: method call child at indentation level 10 not at correct indentation, 12", 671 "12: assign at indentation level 9 not at correct indentation, 12", 672 "13: assign child at indentation level 10 not at correct indentation, 12", 673 }; 674 verify(checkConfig, getPath("indentation/InputInvalidAssignIndent.java"), expected); 675 } 676 677 public void testValidAssignWithChecker() throws Exception 678 { 679 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 680 final String [] expected = {}; 681 verify(checkConfig, getPath("indentation/InputValidAssignIndent.java"), expected); 682 } 683 684 public void test15Extensions() throws Exception 685 { 686 final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); 687 final String [] expected = {}; 688 verify(checkConfig, getPath("Input15Extensions.java"), expected); 689 } 690 } 691 | Popular Tags |