aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java38
1 files changed, 31 insertions, 7 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
index bf96bbce..ab8be473 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2009, 2019 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
+ * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
- *
+ *
*******************************************************************************/
package org.jacoco.core.test.validation;
@@ -98,7 +99,7 @@ public abstract class ValidationTestBase {
/**
* All single line comments are interpreted as statements in the following
* format:
- *
+ *
* <pre>
* // statement1() statement2()
* </pre>
@@ -123,6 +124,29 @@ public abstract class ValidationTestBase {
source.getCoverage().getLastLine() <= source.getLines().size());
}
+ @Test
+ public void all_missed_instructions_should_have_line_number() {
+ CounterImpl c = CounterImpl.COUNTER_0_0;
+ for (Line line : source.getLines()) {
+ c = c.increment(line.getCoverage().getInstructionCounter());
+ }
+ assertEquals(
+ "sum of missed instructions of all lines should be equal to missed instructions of file",
+ source.getCoverage().getInstructionCounter().getMissedCount(),
+ c.getMissedCount());
+ }
+
+ @Test
+ public void all_branches_should_have_line_number() {
+ CounterImpl c = CounterImpl.COUNTER_0_0;
+ for (Line line : source.getLines()) {
+ c = c.increment(line.getCoverage().getBranchCounter());
+ }
+ assertEquals(
+ "sum of branch counters of all lines should be equal to branch counter of file",
+ source.getCoverage().getBranchCounter(), c);
+ }
+
/*
* Predefined assertion methods:
*/