use of org.jacoco.core.analysis.ICounter in project jacoco by jacoco.
the class CounterImplTest method testGetMissedRatio2.
@Test
public void testGetMissedRatio2() {
ICounter c = CounterImpl.getInstance(0, 20);
assertEquals(0.0, c.getMissedRatio(), 0.0);
assertEquals(0.0, c.getValue(CounterValue.MISSEDRATIO), 0.0);
}
use of org.jacoco.core.analysis.ICounter in project jacoco by jacoco.
the class CounterImplTest method testHashCode2.
@Test
public void testHashCode2() {
ICounter c1 = CounterImpl.getInstance(300, 123);
ICounter c2 = CounterImpl.getInstance(400, 123);
assertFalse(c1.hashCode() == c2.hashCode());
}
use of org.jacoco.core.analysis.ICounter in project jacoco by jacoco.
the class MethodAnalyzer method visitEnd.
@Override
public void visitEnd() {
// Wire jumps:
for (final Jump j : jumps) {
LabelInfo.getInstruction(j.target).setPredecessor(j.source, j.branch);
}
// Propagate probe values:
for (final CoveredProbe p : coveredProbes) {
p.instruction.setCovered(p.branch);
}
// Merge:
for (final Instruction i : instructions) {
final AbstractInsnNode m = i.getNode();
final AbstractInsnNode r = findRepresentative(m);
if (r != m) {
ignored.add(m);
nodeToInstruction.get(r).merge(i);
}
}
// Report result:
coverage.ensureCapacity(firstLine, lastLine);
for (final Instruction i : instructions) {
if (ignored.contains(i.getNode())) {
continue;
}
final int total = i.getBranches();
final int covered = i.getCoveredBranches();
final ICounter instrCounter = covered == 0 ? CounterImpl.COUNTER_1_0 : CounterImpl.COUNTER_0_1;
final ICounter branchCounter = total > 1 ? CounterImpl.getInstance(total - covered, covered) : CounterImpl.COUNTER_0_0;
coverage.increment(instrCounter, branchCounter, i.getLine());
}
coverage.incrementMethodCounter();
}
use of org.jacoco.core.analysis.ICounter in project jacoco by jacoco.
the class MethodCoverageImpl method incrementMethodCounter.
/**
* This method must be called exactly once after all instructions and
* branches have been incremented for this method coverage node.
*/
public void incrementMethodCounter() {
final ICounter base = this.instructionCounter.getCoveredCount() == 0 ? CounterImpl.COUNTER_1_0 : CounterImpl.COUNTER_0_1;
this.methodCounter = this.methodCounter.increment(base);
this.complexityCounter = this.complexityCounter.increment(base);
}
use of org.jacoco.core.analysis.ICounter in project jacoco by jacoco.
the class CyclomaticComplexityTest method testTwoIf3.
@Test
public void testTwoIf3() throws Exception {
instrument(TwoIf.class);
target.test(-1);
target.test(0);
final ICounter complexity = analyze();
assertEquals(CounterImpl.getInstance(1, 2), complexity);
}
Aggregations