KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.File JavaDoc;
7
8 public class ExplicitInitializationCheckTest extends BaseCheckTestCase
9 {
10     public void testDefault() throws Exception JavaDoc
11     {
12         final DefaultConfiguration checkConfig =
13             createCheckConfig(ExplicitInitializationCheck.class);
14         final String JavaDoc[] expected = {
15             "2:17: Variable 'x' explicitly initialized to '0' (default value for its type).",
16             "3:20: Variable 'bar' explicitly initialized to 'null' (default value for its type).",
17             "7:18: Variable 'y4' explicitly initialized to '0' (default value for its type).",
18             "8:21: Variable 'b1' explicitly initialized to 'false' (default value for its type).",
19             "12:22: Variable 'str1' explicitly initialized to 'null' (default value for its type).",
20             "12:35: Variable 'str3' explicitly initialized to 'null' (default value for its type).",
21             "13:9: Variable 'ar1' explicitly initialized to 'null' (default value for its type).",
22             "16:11: Variable 'f1' explicitly initialized to '0' (default value for its type).",
23             "17:12: Variable 'd1' explicitly initialized to '0' (default value for its type).",
24             "20:17: Variable 'ch1' explicitly initialized to '\\0' (default value for its type).",
25             "21:17: Variable 'ch2' explicitly initialized to '\\0' (default value for its type).",
26             "37:25: Variable 'bar' explicitly initialized to 'null' (default value for its type).",
27             "38:27: Variable 'barArray' explicitly initialized to 'null' (default value for its type).",
28             "45:21: Variable 'x' explicitly initialized to '0' (default value for its type).",
29             "46:29: Variable 'bar' explicitly initialized to 'null' (default value for its type).",
30             "47:31: Variable 'barArray' explicitly initialized to 'null' (default value for its type).",
31             "50:17: Variable 'x' explicitly initialized to '0' (default value for its type).",
32             "51:25: Variable 'bar' explicitly initialized to 'null' (default value for its type).",
33             "52:27: Variable 'barArray' explicitly initialized to 'null' (default value for its type).",
34         };
35         verify(checkConfig,
36                getPath("coding" + File.separator + "InputExplicitInit.java"),
37                expected);
38     }
39 }
40
Popular Tags