From ff1b9b2cdde7702f4df34bd55d5d7049a9e06b2a Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 8 Oct 2024 17:15:18 +0200 Subject: [PATCH] [java] SwitchStmtsShouldHaveDefault - test for multiple case constants --- .../xml/SwitchStmtsShouldHaveDefault.xml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml index 145739199e..cd13ce5dc9 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml @@ -329,6 +329,39 @@ public class SwitchWithRecordPattern { } } } +]]> + + + + Multiple Case Constants + 0 + System.out.println("a or b"); + case C -> System.out.println("c"); + } + String s = switch(e) { + case A,B -> "a or b"; + case C -> "c"; + }; + System.out.println(s); + } +} ]]>