View Javadoc
1   /*
2   RightCurly
3   option = SAME
4   tokens = LITERAL_CASE
5   
6   */
7   package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;
8   
9   public class InputRightCurlyCaseBlocksInSwitchStatementSame2 {
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 = 1; break;
18              } default : x = 5;         // violation '}' at column 13 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  
42              } default : x = 5;            // violation '}' at column 13 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              } case 1: {int x = 1; break;} // violation '}' at column 13 should be alone on a line'
51          }
52      }
53      public static void test13() {
54          int mode = 0;
55          switch (mode) {
56              case 0: {
57  
58              }
59              case 1: {
60  
61              }
62              default : break;
63          }
64      }
65       public static void test14() {
66          int mode = 0;
67          switch (mode) {
68              case 0: {
69  
70              } case 1: {  }         // violation '}' at column 13 should be alone on a line'
71              default : {break;}
72          }
73      }
74  
75      public static void test15() {
76          int mode = 0;
77          switch (mode) {case 0: { } case 1: {  } } // 2 violations
78  
79      }
80  
81      public static void test16() {
82          int mode = 0;
83          switch (mode) {
84              case 0: int x = 1; { } break;
85              case 1: { } int y = 1; break; // violation '}' at column 23 should be alone on a line'
86  
87              case 2: int t = 1; { };
88          }
89      }
90      public static void test17() {
91          int mode = 0;
92          switch (mode) {
93              case 0:
94              int x = 1;
95              {  }
96              case 1:
97              mode++;
98              {
99              } int y; // ok, the braces is not a first child of case
100             case 3:
101             {
102 
103             } int z = 1; // violation '}' at column 13 should be alone on a line'
104         }
105     }
106     public static void test18() {
107         int mode = 0;
108         switch (mode) {
109             case 0: {
110             }
111             int x;
112             case 1:
113             int z;
114             {
115 
116             } break; default: break; // ok, the braces is not a first child of case
117         }
118     }
119 }