KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > coding > NestedIfDepthCheckTest


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 public class NestedIfDepthCheckTest extends BaseCheckTestCase
7 {
8     public void testDefault() throws Exception JavaDoc
9     {
10         final DefaultConfiguration checkConfig =
11             createCheckConfig(NestedIfDepthCheck.class);
12
13         final String JavaDoc[] expected = {
14             "17:17: Nested if-else depth is 2 (max allowed is 1).",
15             "43:17: Nested if-else depth is 2 (max allowed is 1).",
16         };
17
18         verify(checkConfig, getPath("coding/InputNestedIfDepth.java"), expected);
19     }
20     // checkConfig.addAttribute("max", "2");
21

22     public void testCustomNestingDepth() throws Exception JavaDoc
23     {
24         final DefaultConfiguration checkConfig =
25             createCheckConfig(NestedIfDepthCheck.class);
26         checkConfig.addAttribute("max", "2");
27
28         final String JavaDoc[] expected = {
29         };
30
31         verify(checkConfig, getPath("coding/InputNestedIfDepth.java"), expected);
32     }
33 }
34
Popular Tags