diff options
author | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2018-08-09 19:46:04 +0200 |
---|---|---|
committer | Evgeny Mandrikov <Godin@users.noreply.github.com> | 2018-08-09 19:46:04 +0200 |
commit | 1001adda9a37f262c6162c1fec99487a5a79e7fa (patch) | |
tree | ba8e6436a44ba6d6525df8eda33f60dc14898954 /org.jacoco.core.test.validation.kotlin/src/org/jacoco/core | |
parent | 592533c898da5c11d99c9fa09177d92ad50a0455 (diff) | |
download | jacoco-1001adda9a37f262c6162c1fec99487a5a79e7fa.tar.gz |
Simplify validation test setup (#718)
Diffstat (limited to 'org.jacoco.core.test.validation.kotlin/src/org/jacoco/core')
4 files changed, 25 insertions, 94 deletions
diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinTopLevelFunctionTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinTopLevelFunctionTest.java index a647be4a..6d5a00f5 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinTopLevelFunctionTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinTopLevelFunctionTest.java @@ -11,10 +11,8 @@ *******************************************************************************/ package org.jacoco.core.test.validation.kotlin; -import org.jacoco.core.analysis.ICounter; import org.jacoco.core.test.validation.ValidationTestBase; import org.jacoco.core.test.validation.kotlin.targets.KotlinTopLevelFunctionTargetKt; -import org.junit.Test; /** * Test of top level function. @@ -25,9 +23,4 @@ public class KotlinTopLevelFunctionTest extends ValidationTestBase { super(KotlinTopLevelFunctionTargetKt.class); } - @Test - public void test() { - assertLine("fun", ICounter.FULLY_COVERED); - } - } diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenExpressionTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenExpressionTest.java index 22e920a0..a4f9615f 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenExpressionTest.java +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinWhenExpressionTest.java @@ -11,10 +11,8 @@ *******************************************************************************/ package org.jacoco.core.test.validation.kotlin; -import org.jacoco.core.analysis.ICounter; import org.jacoco.core.test.validation.ValidationTestBase; import org.jacoco.core.test.validation.kotlin.targets.KotlinWhenExpressionTarget; -import org.junit.Test; /** * Test of <code>when</code> expressions. @@ -25,64 +23,4 @@ public class KotlinWhenExpressionTest extends ValidationTestBase { super(KotlinWhenExpressionTarget.class); } - /** - * {@link KotlinWhenExpressionTarget#whenSealed(KotlinWhenExpressionTarget.Sealed)} - */ - @Test - public void whenSealed() { - assertLine("whenSealed.when", ICounter.FULLY_COVERED); - assertLine("whenSealed.case1", ICounter.FULLY_COVERED, 0, 2); - // without filter next line covered partly and has one uncovered branch: - assertLine("whenSealed.case2", ICounter.FULLY_COVERED); - assertLine("whenSealed.return", ICounter.FULLY_COVERED); - } - - /** - * {@link KotlinWhenExpressionTarget#whenSealedRedundantElse(KotlinWhenExpressionTarget.Sealed)} - */ - @Test - public void whenSealedRedundantElse() { - assertLine("whenSealedRedundantElse.when", ICounter.FULLY_COVERED); - assertLine("whenSealedRedundantElse.case1", ICounter.FULLY_COVERED, 0, 2); - assertLine("whenSealedRedundantElse.case2", ICounter.FULLY_COVERED, 1, 1); - assertLine("whenSealedRedundantElse.else", ICounter.NOT_COVERED); - assertLine("whenSealedRedundantElse.return", ICounter.FULLY_COVERED); - } - - /** - * {@link KotlinWhenExpressionTarget#whenEnum(KotlinWhenExpressionTarget.Enum)} - */ - @Test - public void whenEnum() { - assertLine("whenEnum.when", ICounter.FULLY_COVERED, 1, 2); - assertLine("whenEnum.case1", ICounter.FULLY_COVERED); - assertLine("whenEnum.case2", ICounter.PARTLY_COVERED); - assertLine("whenEnum.return", ICounter.FULLY_COVERED); - } - - /** - * {@link KotlinWhenExpressionTarget#whenEnumRedundantElse(KotlinWhenExpressionTarget.Enum)} - */ - @Test - public void whenEnumRedundantElse() { - assertLine("whenEnumRedundantElse.when", ICounter.FULLY_COVERED, 1, 2); - assertLine("whenEnumRedundantElse.case1", ICounter.FULLY_COVERED); - assertLine("whenEnumRedundantElse.case2", ICounter.FULLY_COVERED); - assertLine("whenEnumRedundantElse.else", ICounter.NOT_COVERED); - assertLine("whenEnumRedundantElse.return", ICounter.FULLY_COVERED); - } - - /** - * {@link KotlinWhenExpressionTarget#whenString(String)} - */ - @Test - public void whenString() { - assertLine("whenString.when", ICounter.FULLY_COVERED, 2, 7); - assertLine("whenString.case1", ICounter.FULLY_COVERED); - assertLine("whenString.case2", ICounter.FULLY_COVERED); - assertLine("whenString.case2", ICounter.FULLY_COVERED); - assertLine("whenString.else", ICounter.FULLY_COVERED); - assertLine("whenString.return", ICounter.FULLY_COVERED); - } - } diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinTopLevelFunctionTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinTopLevelFunctionTarget.kt index 424e58c0..9ec485d3 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinTopLevelFunctionTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinTopLevelFunctionTarget.kt @@ -15,4 +15,4 @@ package org.jacoco.core.test.validation.kotlin.targets * This test target is top level function. */ fun main(args: Array<String>) { -} // $line-fun$ +} // assertFullyCovered() diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenExpressionTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenExpressionTarget.kt index 73e3dae4..193977dd 100644 --- a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenExpressionTarget.kt +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinWhenExpressionTarget.kt @@ -21,40 +21,40 @@ object KotlinWhenExpressionTarget { object Sealed2 : Sealed() } - private fun whenSealed(p: Sealed): Int = when (p) { // $line-whenSealed.when$ - is Sealed.Sealed1 -> 1 // $line-whenSealed.case1$ - is Sealed.Sealed2 -> 2 // $line-whenSealed.case2$ - } // $line-whenSealed.return$ + private fun whenSealed(p: Sealed): Int = when (p) { // assertFullyCovered() + is Sealed.Sealed1 -> 1 // assertFullyCovered(0, 2) + is Sealed.Sealed2 -> 2 // assertFullyCovered() + } // assertFullyCovered() @Suppress("REDUNDANT_ELSE_IN_WHEN") - private fun whenSealedRedundantElse(p: Sealed): Int = when (p) { // $line-whenSealedRedundantElse.when$ - is Sealed.Sealed1 -> 1 // $line-whenSealedRedundantElse.case1$ - is Sealed.Sealed2 -> 2 // $line-whenSealedRedundantElse.case2$ - else -> throw NoWhenBranchMatchedException() // $line-whenSealedRedundantElse.else$ - } // $line-whenSealedRedundantElse.return$ + private fun whenSealedRedundantElse(p: Sealed): Int = when (p) { // assertFullyCovered() + is Sealed.Sealed1 -> 1 // assertFullyCovered(0, 2) + is Sealed.Sealed2 -> 2 // assertFullyCovered(1, 1) + else -> throw NoWhenBranchMatchedException() // assertNotCovered() + } // assertFullyCovered() private enum class Enum { A, B } - private fun whenEnum(p: Enum): Int = when (p) { // $line-whenEnum.when$ - Enum.A -> 1 // $line-whenEnum.case1$ - Enum.B -> 2 // $line-whenEnum.case2$ - } // $line-whenEnum.return$ + private fun whenEnum(p: Enum): Int = when (p) { // assertFullyCovered(1, 2) + Enum.A -> 1 // assertFullyCovered() + Enum.B -> 2 // assertPartlyCovered() + } // assertFullyCovered() @Suppress("REDUNDANT_ELSE_IN_WHEN") - private fun whenEnumRedundantElse(p: Enum): Int = when (p) { // $line-whenEnumRedundantElse.when$ - Enum.A -> 1 // $line-whenEnumRedundantElse.case1$ - Enum.B -> 2 // $line-whenEnumRedundantElse.case2$ - else -> throw NoWhenBranchMatchedException() // $line-whenEnumRedundantElse.else$ - } // $line-whenEnumRedundantElse.return$ + private fun whenEnumRedundantElse(p: Enum): Int = when (p) { // assertFullyCovered(1, 2) + Enum.A -> 1 // assertFullyCovered() + Enum.B -> 2 // assertFullyCovered() + else -> throw NoWhenBranchMatchedException() // assertNotCovered() + } // assertFullyCovered() - private fun whenString(p: String): Int = when (p) { // $line-whenString.when$ - "a" -> 1 // $line-whenString.case1$ - "b" -> 2 // $line-whenString.case2$ - "\u0000a" -> 3 // $line-whenString.case3$ - else -> 4 // $line-whenString.else$ - } // $line-whenString.return$ + private fun whenString(p: String): Int = when (p) { // assertFullyCovered(2, 7) + "a" -> 1 // assertFullyCovered() + "b" -> 2 // assertFullyCovered() + "\u0000a" -> 3 // assertFullyCovered() + else -> 4 // assertFullyCovered() + } // assertFullyCovered() @JvmStatic fun main(args: Array<String>) { |