diff options
author | Subbu Dantu <subbudantu@Subbus-MacBook-Pro.local> | 2017-04-16 13:36:22 +0530 |
---|---|---|
committer | Roman Ivanov <romani@users.noreply.github.com> | 2017-04-30 11:29:53 -0700 |
commit | 185f969cd163bbaaf41356c73bcac3831ac31fc9 (patch) | |
tree | 5bf1b47c46edada78fca0f5c24c1006e6ad426a3 /src/test/java | |
parent | da384319283ab296094f6097034eeddba7fc7483 (diff) | |
download | checkstyle-185f969cd163bbaaf41356c73bcac3831ac31fc9.tar.gz |
Issue #2399: New option 'onlyObjectReferences' for ExplicitInitializationCheck
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java index b77a3ac08..a7e28a72e 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java @@ -74,4 +74,24 @@ public class ExplicitInitializationCheckTest extends BaseCheckTestSupport { Assert.assertNotNull(check.getDefaultTokens()); Assert.assertNotNull(check.getRequiredTokens()); } + + @Test + public void testonlyObjectReferences() throws Exception { + final DefaultConfiguration checkConfig = + createCheckConfig(ExplicitInitializationCheck.class); + checkConfig.addAttribute("onlyObjectReferences", "true"); + final String[] expected = { + "5:20: " + getCheckMessage(MSG_KEY, "bar", "null"), + "14:22: " + getCheckMessage(MSG_KEY, "str1", "null"), + "14:35: " + getCheckMessage(MSG_KEY, "str3", "null"), + "15:9: " + getCheckMessage(MSG_KEY, "ar1", "null"), + "39:25: " + getCheckMessage(MSG_KEY, "bar", "null"), + "40:27: " + getCheckMessage(MSG_KEY, "barArray", "null"), + "48:29: " + getCheckMessage(MSG_KEY, "bar", "null"), + "49:31: " + getCheckMessage(MSG_KEY, "barArray", "null"), + "53:25: " + getCheckMessage(MSG_KEY, "bar", "null"), + "54:27: " + getCheckMessage(MSG_KEY, "barArray", "null"), + }; + verify(checkConfig, getPath("InputExplicitInitialization.java"), expected); + } } |