aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/com/puppycrawl
diff options
context:
space:
mode:
authorPiyush Sharma <ps26oct@gmail.com>2017-04-11 14:59:09 +0530
committerRoman Ivanov <romani@users.noreply.github.com>2017-04-21 05:35:38 -0700
commit8da98a9d3dc762c4dd026756eb5cc5533571a39b (patch)
tree8b3be041a760c34864d8d0e8105f5a08a9ebf02e /src/test/resources/com/puppycrawl
parent735a46d90442304897f134022fc90375a6c2cced (diff)
downloadcheckstyle-8da98a9d3dc762c4dd026756eb5cc5533571a39b.tar.gz
Issue #4159: LITERAL_DEFAULT is now processed by EmptyBlockCheck. Corresponding UTs added
Diffstat (limited to 'src/test/resources/com/puppycrawl')
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputEmptyDefault.java89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputEmptyDefault.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputEmptyDefault.java
new file mode 100644
index 000000000..d7a7984a1
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputEmptyDefault.java
@@ -0,0 +1,89 @@
+public class InputEmptyDefault {
+ void method1(int a) {
+ switch (a) {}
+ switch (a) {default: ; } // no violation
+ switch (a) {default: {}} // violation
+ switch (a) {
+ default:
+ }
+ switch (a) {
+ default: // violation
+ {}
+ }
+ switch (a) {
+ default: // violation if checking statements
+ { // text
+ }
+ }
+ }
+
+ void method2(int a) {
+ switch (a) {
+ case 1:a++;
+ case 2:a++;
+ default: // no violation
+ switch (a) {
+ default: { // violation if checking for statements
+
+ }
+ }
+ }
+ }
+
+ void method3(int a, int b) {
+ switch (a) {
+ case 1: break;
+ default: {} method2(a); // violation
+ }
+
+ switch (b) {
+ case 2: break;
+ default: method2(b); {} // no violation
+ }
+
+ switch (a+b) {case 1: break; default: {} ; } // violation
+ }
+
+ void method4(int a, int b) {
+ switch (a) {
+ case 1:
+ default: {} // violation
+ }
+
+ switch (b) {
+ case 1:
+ default: // no violation
+ }
+
+ switch (a+b) {
+ default: // no violation
+ case 1: { }
+ }
+
+ switch (a-b) {
+ case 1:
+ default: { // violation if checking statements
+
+ } ;
+ case 2: { }
+ }
+ }
+
+ void method5(int a, int b) {
+ switch (a) {
+ case 1:
+ case 2:
+ case 3:
+ default: // violation
+ {
+ }
+ }
+
+ switch (b) {
+ default: // no violation
+ case 1:
+ case 2: { } method2(b);
+ case 3:
+ }
+ }
+}