Skip to content

Commit

Permalink
(WIP) add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin committed Apr 3, 2018
1 parent 65ad735 commit 6d42429
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
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);
}

}
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);
}

}

0 comments on commit 6d42429

Please sign in to comment.