-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
org.jacoco.core.test/src/org/jacoco/core/test/filter/EnumSwitchTest.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,34 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Evgeny Mandrikov - initial API and implementation | ||
* | ||
*******************************************************************************/ | ||
package org.jacoco.core.test.filter; | ||
|
||
import org.jacoco.core.analysis.ICounter; | ||
import org.jacoco.core.test.filter.targets.EnumSwitch; | ||
import org.jacoco.core.test.validation.ValidationTestBase; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test of filtering of a synthetic class that is generated for a enum in switch | ||
* statement. | ||
*/ | ||
public class EnumSwitchTest extends ValidationTestBase { | ||
|
||
public EnumSwitchTest() { | ||
super(EnumSwitch.class); | ||
} | ||
|
||
@Test | ||
public void testCoverageResult() { | ||
assertLine("switch", ICounter.PARTLY_COVERED, 0, 2); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
org.jacoco.core.test/src/org/jacoco/core/test/filter/targets/EnumSwitch.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,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Marc R. Hoffmann - initial API and implementation | ||
* | ||
*******************************************************************************/ | ||
package org.jacoco.core.test.filter.targets; | ||
|
||
import static org.jacoco.core.test.validation.targets.Stubs.nop; | ||
|
||
/** | ||
* This test target is a switch statement with a enum. | ||
*/ | ||
public class EnumSwitch { | ||
|
||
private enum E { | ||
V1, V2 | ||
} | ||
|
||
private static void example(E e) { | ||
switch (e) { // $line-switch$ | ||
case V1: | ||
nop("V1"); | ||
break; | ||
case V2: | ||
default: | ||
nop("V2"); | ||
break; | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
example(E.V1); | ||
example(E.V2); | ||
} | ||
|
||
} |