View Javadoc
1   /*
2   RightCurly
3   option = ALONE
4   tokens = LITERAL_SWITCH, LITERAL_IF
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;
10  
11  public class InputRightCurlyTestSwitchCase {
12  
13      public static void method0() {
14          int mode = 0;
15          switch (mode) {
16              case 1:
17                  int x = 1;
18                  break;
19              default :
20                  x = 0; } // violation '}' at column 24 should be alone on a line'
21      }
22  
23      public static void method1() {
24          int mode = 0;
25          switch (mode) {
26          default :
27                 int x = 0; } // violation '}' at column 27 should be alone on a line'
28      }
29  
30      public static void method2() {
31          int mode = 0;
32          switch (mode) {
33              case 1:
34                  int x = 1;
35                  break;
36              default:
37                  x = 0;
38          }
39      }
40  
41      public static void method3() {
42          int mode = 0;
43          switch (mode) {
44          default :
45                 int x = 0;
46          }
47      }
48  
49      public static void method4() {
50          int mode = 0;
51          switch (mode) { default : int x = 0; }
52          // violation above '}' at column 46 should be alone on a line'
53      }
54  
55      public static void method5() {
56          int mode = 0;
57          switch (mode) { default : int x = 0;
58          }
59      }
60  
61      public static void method6() {
62          int mode = 0;
63          switch (mode) { case 0: int x = 1; break; default : x = 5;
64          }
65      }
66  
67      public static void method7() {
68          int mode = 0;
69          switch (mode) { case 0: int x = 1; break; default : x = 5; }
70          // violation above '}' at column 68 should be alone on a line'
71      }
72  
73      public static void method8() {
74          int mode = 0;
75          switch (mode) { case 0: int x = 1; break; case 80: x = 1; break; }
76          // violation above '}' at column 74 should be alone on a line'
77      }
78  
79      public static void method9() {
80          int mode = 0;
81          switch (mode) { case 0: int x = 1; break; default : x = 5;
82          }
83      }
84  
85      public static void method10() {
86          int mode = 0;
87          switch (mode) { case 0: int x = 1; break; case 80: x = 1; break;
88          }
89      }
90  
91      public static void method11() {
92          int mode = 0;
93          int x = 0;
94          switch (mode) {
95              case 0:
96                  if(0>9) {
97                      x = 9;
98                  }
99                  break;
100             case 80:
101                 x = 1;
102                 break;
103         }
104     }
105     public static void method12() {
106         int mode = 0;
107         int x = 0;
108         switch (mode) {
109             case 0:
110                 if(0>9) {
111                     x = 9;
112                 } else { // violation ''}' at column 17 should be alone on a line'
113                 }
114                 break;
115         }
116         switch (x) {}; // violation ''}' at column 21 should be alone on a line'
117         switch (x) {
118         }
119     }
120 }