forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#14620: LITERAL_CASE token support in RightCurlyCheck
- Loading branch information
Showing
9 changed files
with
614 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
...s/checkstyle/checks/blocks/rightcurly/InputRightCurlyTestCaseBlocksInSwitchStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
/* | ||
RightCurly | ||
option = ALONE | ||
tokens = LITERAL_CASE | ||
*/ | ||
package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly; | ||
|
||
public class InputRightCurlyTestCaseBlocksInSwitchStatement { | ||
public static void test0() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 1: { | ||
int x = 1; | ||
break; | ||
} | ||
case 2: { | ||
int x = 0; | ||
break; | ||
} | ||
case 3: { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public static void test() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 1:{ | ||
int x = 1; | ||
break; | ||
} default : // violation '}' at column 13 should be alone on a line' | ||
int x = 0; | ||
} | ||
} | ||
|
||
public static void test1() { | ||
int k = 0; | ||
switch (k) { | ||
case 1:{ | ||
int x = 1; | ||
break; | ||
} case 2: // violation '}' at column 13 should be alone on a line' | ||
int x = 2; | ||
break; | ||
} | ||
} | ||
|
||
public static void test2() { | ||
int k = 0; | ||
switch (k) { | ||
case 1:{ | ||
int x = 1; | ||
break; | ||
} | ||
case 2: | ||
int x = 2; | ||
break; | ||
} | ||
} | ||
|
||
public static void test3() { | ||
int k = 0; | ||
switch (k) { | ||
case 1:{ | ||
int x = 1; | ||
break; | ||
} | ||
case 2:{ | ||
int x = 2; | ||
break; | ||
} } // violation '}' at column 13 should be alone on a line' | ||
} | ||
|
||
public static void test4() { | ||
int mode = 0; | ||
switch (mode) { case 0: {int x = 1;} break; default : int x = 5; } | ||
// violation above '}' at column 44 should be alone on a line' | ||
} | ||
|
||
public static void test5() { | ||
int mode = 0; | ||
switch (mode) { case 0: int x = 1;} | ||
} | ||
|
||
public static void test6() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 0: {int x = 1; break;} // violation '}' at column 39 should be alone on a line' | ||
default : break; | ||
} | ||
} | ||
|
||
public static void test7() { | ||
int mode = 0; | ||
switch (mode) { case 0: {int x = 1;} // violation '}' at column 44 should be alone on a line' | ||
break; default : break; } | ||
} | ||
|
||
public static void test8() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 0: int x = 1; | ||
case 1: x = 1; break; | ||
case 2: {x = 1; break;} // violation '}' at column 35 should be alone on a line' | ||
default : x = 5; | ||
} | ||
} | ||
|
||
public static void test9() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 0: int x = 1; | ||
case 1: x = 1; break; | ||
case 2: { | ||
x = 1; break; | ||
} default : x = 5; // violation '}' at column 13 should be alone on a line' | ||
} | ||
} | ||
|
||
public static void test10() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 0: { | ||
|
||
} case 1: int x = 1; break; // violation '}' at column 13 should be alone on a line' | ||
case 2: { | ||
|
||
} | ||
default : x = 5; | ||
} | ||
} | ||
public static void test11() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 0: { | ||
|
||
} case 1: int x = 1; break; // violation '}' at column 13 should be alone on a line' | ||
case 2: { | ||
|
||
} default : x = 5; // violation '}' at column 13 should be alone on a line' | ||
} | ||
} | ||
public static void test12() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 0: { | ||
|
||
} case 1: {int x = 1;} break; // 2 violations | ||
} | ||
} | ||
public static void test13() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 0: { | ||
|
||
} | ||
case 1: { | ||
|
||
} | ||
default : break; | ||
} | ||
} | ||
public static void test14() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 0: { | ||
|
||
} case 1: { } // 2 violations | ||
default : {break;} | ||
} | ||
} | ||
} |
Oops, something went wrong.