View Javadoc
1   /*
2   RightCurly
3   option = ALONE_OR_SINGLELINE
4   tokens = LITERAL_CASE
5   
6   */
7   package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;
8   
9   public class InputRightCurlyCaseBlocksInSwitchStatementAloneOrSingleline2 {
10  
11      public static void test9() {
12          int mode = 0;
13          switch (mode) {
14              case 0: int x = 1;
15              case 1: x = 1; break;
16              case 2: {
17                  x =
18              1;} default : x = 5;         // violation '}' at column 15 should be alone on a line'
19          }
20      }
21  
22      public static void test10() {
23          int mode = 0;
24          switch (mode) {
25              case 0: {
26  
27              } case 1: int x = 1; break;    // violation '}' at column 13 should be alone on a line'
28              case 2: {
29  
30              }
31              default : x = 5;
32          }
33      }
34       public static void test11() {
35          int mode = 0;
36          switch (mode) {
37              case 0: {
38  
39              } case 1: int x = 1; break;   // violation '}' at column 13 should be alone on a line'
40              case 2: {
41                  int
42              y;} default : x = 5;         // violation '}' at column 15 should be alone on a line'
43          }
44      }
45      public static void test12() {
46          int mode = 0;
47          switch (mode) {
48              case 0: {
49  
50              int x = 1;} case 1: {int x = 1; break;}
51              // violation above '}' at column 23 should be alone on a line'
52          }
53      }
54      public static void test13() {
55          int mode = 0;
56          switch (mode) {
57              case 0: {
58  
59              }
60              case 1: {
61  
62              }
63              default : break;
64          }
65      }
66       public static void test14() {
67          int mode = 0;
68          switch (mode) {
69              case 0: { int x = 1;
70  
71              } case 1: {  }         // violation '}' at column 13 should be alone on a line'
72              default : {break;}
73          }
74      }
75  
76       public static void test15() {
77          int mode = 0;
78          switch (mode) {
79              case 0: int x = 1; { } break;
80              case 1: { } int y = 1; break; // violation '}' at column 23 should be alone on a line'
81  
82              case 2: int t = 1; { };
83          }
84      }
85  
86      public static void test17() {
87          int mode = 0;
88          switch (mode) {
89              case 0:
90              int x = 1;
91              {  }
92              case 1:
93              mode++;
94              {
95  
96              } int y; // ok, the braces is not a first child of case
97              case 3:
98              {
99  
100             } int z = 1;  // violation '}' at column 13 should be alone on a line'
101         }
102     }
103 
104     public static void test18() {
105         int mode = 0;
106         switch (mode) {
107             case 0: {
108 
109             }
110             case 1:
111             int z;
112             {
113 
114             } break; default: break; // ok, the braces is not a first child of case
115         }
116     }
117 }