diff options
author | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2015-11-10 23:18:22 +0100 |
---|---|---|
committer | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2015-11-10 23:19:46 +0100 |
commit | e175fb33ac0673aca6ac6505bacfbd3d5e61715c (patch) | |
tree | 94e86e330a6e0b8b7e0ba74ca5066d35ada386d5 /org.jacoco.core.test | |
parent | f4622217085198f3ae42906934026961b29d1111 (diff) | |
parent | 0638deda4eb4907dd8067a524dc915b484d2c22a (diff) | |
download | jacoco-e175fb33ac0673aca6ac6505bacfbd3d5e61715c.tar.gz |
Merge branch 'issue-cleanup-refactoring'
Diffstat (limited to 'org.jacoco.core.test')
5 files changed, 117 insertions, 3 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/data/ExecutionDataReaderWriterTest.java b/org.jacoco.core.test/src/org/jacoco/core/data/ExecutionDataReaderWriterTest.java index 0efcf7a3..2b6dcbc3 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/data/ExecutionDataReaderWriterTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/data/ExecutionDataReaderWriterTest.java @@ -135,8 +135,8 @@ public class ExecutionDataReaderWriterTest { createReader().read(); } - @Test(expected = IOException.class) - public void testInvalidHeaderVersion() throws IOException { + @Test(expected = IncompatibleExecDataVersionException.class) + public void testInvalidVersion() throws IOException { buffer = new ByteArrayOutputStream(); buffer.write(ExecutionDataWriter.BLOCK_HEADER); buffer.write(0xC0); diff --git a/org.jacoco.core.test/src/org/jacoco/core/data/IncompatibleExecDataVersionExceptionTest.java b/org.jacoco.core.test/src/org/jacoco/core/data/IncompatibleExecDataVersionExceptionTest.java new file mode 100644 index 00000000..e1735fc1 --- /dev/null +++ b/org.jacoco.core.test/src/org/jacoco/core/data/IncompatibleExecDataVersionExceptionTest.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2009, 2015 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.data; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +/** + * Unit tests for {@link IncompatibleExecDataVersionExceptionTest}. + */ +public class IncompatibleExecDataVersionExceptionTest { + + private IncompatibleExecDataVersionException exception; + + @Before + public void setup() { + exception = new IncompatibleExecDataVersionException(0x1234); + } + + @Test + public void testGetMessage() { + String expected = "Cannot read execution data version 0x1234. " + + "This version of JaCoCo uses execution data version 0x" + + Integer.toHexString(ExecutionDataWriter.FORMAT_VERSION) + "."; + assertEquals(expected, exception.getMessage()); + } + + @Test + public void testGetActualVersion() { + assertEquals(0x1234, exception.getActualVersion()); + } + + @Test + public void testGetExpectedVersion() { + assertEquals(ExecutionDataWriter.FORMAT_VERSION, + exception.getExpectedVersion()); + } +} diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java index deb2d493..3a290551 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java @@ -16,7 +16,7 @@ import org.jacoco.core.test.validation.ValidationTestBase; import org.junit.Test; /** - * Tests of basic Java control structures. + * Tests for different lambda expressions. */ public class LambdaExpressionsTest extends ValidationTestBase { diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTarget.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTarget.java new file mode 100644 index 00000000..733e59ad --- /dev/null +++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTarget.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2009, 2015 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.validation.java8; + +import static org.jacoco.core.test.validation.targets.Stubs.nop; + +/** + * This test target builds a constant with a lambda value in an interface. + */ +public interface LambdaInInterfaceTarget { + + public static final Runnable RUN = () -> { + nop(); // $line-lambdabody$ + }; + +} diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java new file mode 100644 index 00000000..895884c5 --- /dev/null +++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2009, 2015 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.validation.java8; + +import org.jacoco.core.analysis.ICounter; +import org.jacoco.core.test.validation.ValidationTestBase; +import org.junit.Test; + +/** + * Tests a constant with a lambda value in an interface. + */ +public class LambdaInInterfaceTest extends ValidationTestBase { + + public LambdaInInterfaceTest() { + super(LambdaInInterfaceTarget.class); + } + + @Override + protected void run(final Class<?> targetClass) throws Exception { + ((Runnable) targetClass.getField("RUN").get(null)).run(); + } + + @Test + public void testCoverageResult() { + + // Coverage of lambda body + assertLine("lambdabody", ICounter.FULLY_COVERED); + + } + +} |