Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckTest.java


1   package com.puppycrawl.tools.checkstyle.checks.blocks;
2   
3   import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
4   import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
5   
6   public class LeftCurlyCheckTest
7       extends BaseCheckTestCase
8   {
9       public void testDefault()
10          throws Exception
11      {
12          final DefaultConfiguration checkConfig =
13              createCheckConfig(LeftCurlyCheck.class);
14          final String[] expected = {
15              "8:1: '{' should be on the previous line.",
16              "12:5: '{' should be on the previous line.",
17              "21:5: '{' should be on the previous line.",
18              "30:5: '{' should be on the previous line.",
19              "39:5: '{' should be on the previous line.",
20          };
21          verify(checkConfig, getPath("InputScopeInnerInterfaces.java"), expected);
22      }
23  
24      public void testNL()
25          throws Exception
26      {
27          final DefaultConfiguration checkConfig =
28              createCheckConfig(LeftCurlyCheck.class);
29          checkConfig.addAttribute("option", LeftCurlyOption.NL.toString());
30          final String[] expected = {
31          };
32          verify(checkConfig, getPath("InputScopeInnerInterfaces.java"), expected);
33      }
34  
35      public void testNLOW()
36          throws Exception
37      {
38          final DefaultConfiguration checkConfig =
39              createCheckConfig(LeftCurlyCheck.class);
40          checkConfig.addAttribute("option", LeftCurlyOption.NLOW.toString());
41          final String[] expected = {
42              "8:1: '{' should be on the previous line.",
43              "12:5: '{' should be on the previous line.",
44              "21:5: '{' should be on the previous line.",
45              "30:5: '{' should be on the previous line.",
46              "39:5: '{' should be on the previous line.",
47          };
48          verify(checkConfig, getPath("InputScopeInnerInterfaces.java"), expected);
49      }
50      
51      public void testDefault2()
52          throws Exception
53      {
54          final DefaultConfiguration checkConfig =
55              createCheckConfig(LeftCurlyCheck.class);
56          final String[] expected = {
57              "12:1: '{' should be on the previous line.",
58              "17:5: '{' should be on the previous line.",
59              "24:5: '{' should be on the previous line.",
60              "31:5: '{' should be on the previous line.",
61          };
62          verify(checkConfig, getPath("InputLeftCurlyMethod.java"), expected);
63      }
64  
65      public void testNL2()
66          throws Exception
67      {
68          final DefaultConfiguration checkConfig =
69              createCheckConfig(LeftCurlyCheck.class);
70          checkConfig.addAttribute("option", LeftCurlyOption.NL.toString());
71          final String[] expected = {
72              "14:39: '{' should be on a new line.",
73              "21:20: '{' should be on a new line.",
74              "34:31: '{' should be on a new line.",
75          };
76          verify(checkConfig, getPath("InputLeftCurlyMethod.java"), expected);
77      }
78      public void testDefault3()
79          throws Exception
80      {
81          final DefaultConfiguration checkConfig =
82              createCheckConfig(LeftCurlyCheck.class);
83          final String[] expected = {
84              "12:1: '{' should be on the previous line.",
85              "15:5: '{' should be on the previous line.",
86              "19:9: '{' should be on the previous line.",
87              "21:13: '{' should be on the previous line.",
88              "23:17: '{' should be on the previous line.",
89              "30:17: '{' should be on the previous line.",
90              "34:17: '{' should be on the previous line.",
91              "42:13: '{' should be on the previous line.",
92              "46:13: '{' should be on the previous line.",
93              "52:9: '{' should be on the previous line.",
94              "54:13: '{' should be on the previous line.",
95              "63:9: '{' should be on the previous line.",
96          };
97          verify(checkConfig, getPath("InputLeftCurlyOther.java"), expected);
98      }
99  
100     public void testNL3()
101         throws Exception
102     {
103         final DefaultConfiguration checkConfig =
104             createCheckConfig(LeftCurlyCheck.class);
105         checkConfig.addAttribute("option", LeftCurlyOption.NL.toString());
106         final String[] expected = {
107             "26:33: '{' should be on a new line."
108         };
109         verify(checkConfig, getPath("InputLeftCurlyOther.java"), expected);
110     }
111 
112     public void testMissingBraces()
113         throws Exception
114     {
115         final DefaultConfiguration checkConfig =
116             createCheckConfig(LeftCurlyCheck.class);
117         final String[] expected = {
118             "12:1: '{' should be on the previous line.",
119             "15:5: '{' should be on the previous line.",
120             "21:5: '{' should be on the previous line.",
121             "34:5: '{' should be on the previous line.",
122             "51:5: '{' should be on the previous line.",
123             "69:5: '{' should be on the previous line.",
124             "105:5: '{' should be on the previous line.",
125         };
126         verify(checkConfig, getPath("InputBraces.java"), expected);
127     }
128 }