aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/com
diff options
context:
space:
mode:
authorPiyush Sharma <ps26oct@gmail.com>2017-03-06 05:58:02 +0530
committerrnveach <rveach02@gmail.com>2017-04-05 11:41:01 -0400
commit350801597ccce93d019ab03f5f171d5acc27e3d9 (patch)
tree15e1526ce52c0bbe1c5e41d7259b0f32183742d0 /src/test/resources/com
parente0bb421ead241b65c5d8b4acafe5f8247aea8576 (diff)
downloadcheckstyle-350801597ccce93d019ab03f5f171d5acc27e3d9.tar.gz
Issue #3839: One new method to optimise design and detect empty LITERAL_CASE. Added corresponding UTs. Updated documentation
Diffstat (limited to 'src/test/resources/com')
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputEmptyCase.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputEmptyCase.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputEmptyCase.java
new file mode 100644
index 000000000..b8c1df3f6
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputEmptyCase.java
@@ -0,0 +1,36 @@
+////////////////////////////////////////////////////////////////////////////////
+// Input test file for testing empty LITERAL_CASE.
+// Created: 2017
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.blocks;
+
+class InputEmptyCase
+{
+ void method1(int a) {
+ switch (a) {}
+ switch (a) {case 1: ; } // no violation
+ switch (a) {case 1:{}} // 1 violation
+ switch (a) {
+ case 1:
+ }
+ switch (a) {
+ case 1: // 1 violation
+ {}
+ }
+ switch (a) {
+ case 1: // 1 violation if checking statements
+ {// none if checking text
+ }
+ }
+ }
+
+ public void method2(char c) {
+ switch(c) { case 0: } // no violation
+ switch(c) { case 0: {} method1(1); } // 1 violation
+ switch(c) { case 0: method1(0); {} } // no violation
+ switch(c) { case 0: case 1: {} } // 1 violation
+ switch(c) { case 0: {} case 1: {// 2 violations if checking statements
+ }
+ }
+ }
+}