KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class ReturnCountCheckTest extends BaseCheckTestCase
8 {
9     public void testDefault() throws Exception JavaDoc
10     {
11         final DefaultConfiguration checkConfig =
12             createCheckConfig(ReturnCountCheck.class);
13         final String JavaDoc[] expected = {
14             "18:5: Return count is 7 (max allowed is 2).",
15             "35:17: Return count is 6 (max allowed is 2).",
16         };
17         verify(checkConfig, getPath("coding" + File.separator + "InputReturnCount.java"), expected);
18     }
19
20     public void testFormat() throws Exception JavaDoc
21     {
22         final DefaultConfiguration checkConfig =
23             createCheckConfig(ReturnCountCheck.class);
24         checkConfig.addAttribute("format", "^$");
25         final String JavaDoc[] expected = {
26             "5:5: Return count is 7 (max allowed is 2).",
27             "18:5: Return count is 7 (max allowed is 2).",
28             "35:17: Return count is 6 (max allowed is 2).",
29         };
30         verify(checkConfig, getPath("coding" + File.separator + "InputReturnCount.java"), expected);
31     }
32 }
33
Popular Tags