![JAR search and dependency download from the Maven repository](/logo.png)
mockit.coverage.lines.LineSegmentData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmockit-coverage Show documentation
Show all versions of jmockit-coverage Show documentation
JMockit Coverage is a code coverage tool with several metrics (line, path, data) capable of generating HTML
reports. It is designed with ease of use in mind, avoiding the need for complex configuration.
Instead, smart (but overridable) defaults are employed, such as the selection of which classes to consider for
coverage, and where to find sources files for report generation.
/*
* Copyright (c) 2006-2014 Rogério Liesenfeld
* This file is subject to the terms of the MIT license (see LICENSE.txt).
*/
package mockit.coverage.lines;
import java.io.*;
import java.util.*;
import org.jetbrains.annotations.*;
import mockit.coverage.*;
public class LineSegmentData implements Serializable
{
private static final long serialVersionUID = -6233980722802474992L;
private static final int MAX_CALL_POINTS = 10;
// Static data:
boolean unreachable;
// Runtime data:
int executionCount;
@Nullable private List callPoints;
public final void markAsUnreachable() { unreachable = true; }
boolean acceptsAdditionalCallPoints()
{
return callPoints == null || callPoints.size() < MAX_CALL_POINTS;
}
final void registerExecution(@NotNull CallPoint callPoint)
{
addCallPoint(callPoint);
executionCount++;
}
private void addCallPoint(@NotNull CallPoint callPoint)
{
if (callPoints == null) {
callPoints = new ArrayList(MAX_CALL_POINTS);
}
for (int i = callPoints.size() - 1; i >= 0; i--) {
CallPoint previousCallPoint = callPoints.get(i);
if (callPoint.isSameLineInTestCode(previousCallPoint)) {
previousCallPoint.incrementRepetitionCount();
return;
}
}
callPoints.add(callPoint);
}
final void addCallPointIfAny(@Nullable CallPoint callPoint)
{
if (callPoint != null) {
addCallPoint(callPoint);
}
}
public final boolean containsCallPoints() { return callPoints != null; }
@Nullable public final List getCallPoints() { return callPoints; }
public int getExecutionCount() { return executionCount; }
final void setExecutionCount(int executionCount) { this.executionCount = executionCount; }
public boolean isCovered() { return unreachable || executionCount > 0; }
final void addExecutionCountAndCallPointsFromPreviousTestRun(@NotNull LineSegmentData previousData)
{
executionCount += previousData.executionCount;
if (previousData.callPoints != null) {
if (callPoints != null) {
callPoints.addAll(0, previousData.callPoints);
}
else {
callPoints = previousData.callPoints;
}
}
}
void reset() { executionCount = 0; }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy