public void putLineTouchPoint(int classLine, int counterId, String methodName, String methodDescription) { updateLine(classLine); LineData ld = classData.addLine(classLine, methodName, methodDescription); ld.touch(res[counterId]); }
public void putSwitchTouchPoint(int classLine, int maxBranches, int... counterIds) { updateLine(classLine); LineData ld = getOrCreateLine(classLine); int switchId = switchesInLine++; classData.addLineSwitch(classLine, switchId, 0, counterIds.length - 2, maxBranches); for (int i = 0; i < counterIds.length; i++) { ld.touchSwitch(switchId, i - 1, res[counterIds[i]]); } }
public void putJumpTouchPoint(int classLine, int trueCounterId, int falseCounterId) { updateLine(classLine); LineData ld = getOrCreateLine(classLine); int branchId = jumpsInLine++; classData.addLineJump(classLine, branchId); ld.touchJump(branchId, true, res[trueCounterId]); ld.touchJump(branchId, false, res[falseCounterId]); }
private LineData getOrCreateLine(int classLine) { LineData ld = classData.getLineData(classLine); if (ld == null) { ld = classData.addLine(classLine, null, null); } return ld; } }
public String getConditionCoverage(int index) { Object branchData = getConditionData(index); if (branchData == null) { return StringUtil.getPercentValue(1.0); } else if (branchData instanceof JumpData) { JumpData jumpData = (JumpData) branchData; return StringUtil.getPercentValue(jumpData.getBranchCoverageRate()); } else { SwitchData switchData = (SwitchData) branchData; return StringUtil.getPercentValue(switchData .getBranchCoverageRate()); } }
void addSwitch(int switchNumber, int min, int max, int maxBranches) { SwitchData sd = getSwitchData(switchNumber, new SwitchData( switchNumber, min, max, maxBranches)); if (sd.getMaxBranches() > maxBranches) { sd.setMaxBranches(maxBranches); } }
public int getNumberOfValidBranches() { int ret = 0; if (jumps != null) for (int i = jumps.size() - 1; i >= 0; i--) ret += ((JumpData) jumps.get(i)).getNumberOfValidBranches(); if (switches != null) for (int i = switches.size() - 1; i >= 0; i--) ret += ((SwitchData) switches.get(i)) .getNumberOfValidBranches(); return ret; }
void touchJump(int jumpNumber, boolean branch, int hits) { getJumpData(jumpNumber).touchBranch(branch, hits); }
void addSwitch(int switchNumber, int[] keys) { getSwitchData(switchNumber, new SwitchData(switchNumber, keys)); }
public double getBranchCoverageRate() { if (getNumberOfValidBranches() == 0) return 1d; return ((double) getNumberOfCoveredBranches()) / getNumberOfValidBranches(); }
void touchSwitch(int switchNumber, int branch) { getSwitchData(switchNumber, null).touchBranch(branch); }
public int getNumberOfCoveredBranches() { int ret = 0; if (jumps != null) for (int i = jumps.size() - 1; i >= 0; i--) ret += ((JumpData) jumps.get(i)).getNumberOfCoveredBranches(); if (switches != null) for (int i = switches.size() - 1; i >= 0; i--) ret += ((SwitchData) switches.get(i)) .getNumberOfCoveredBranches(); return ret; }
@Override public int getNumberOfCoveredLines() { int result = 0; for ( CoverageData cd : lines ) { result += cd.getNumberOfCoveredLines(); } return result; }
LineData(int lineNumber, String methodName, String methodDescriptor) { this.hits = 0; this.jumps = null; this.lineNumber = lineNumber; this.methodName = methodName; this.methodDescriptor = methodDescriptor; initLock(); }
public void putLineTouchPoint(int classLine, int counterId, String methodName, String methodDescription) { updateLine(classLine); LineData ld = classData.addLine(classLine, methodName, methodDescription); ld.touch(res[counterId]); }
public void putSwitchTouchPoint(int classLine, int maxBranches, int... counterIds) { updateLine(classLine); LineData ld = getOrCreateLine(classLine); int switchId = switchesInLine++; classData.addLineSwitch(classLine, switchId, 0, counterIds.length - 2, maxBranches); for (int i = 0; i < counterIds.length; i++) { ld.touchSwitch(switchId, i - 1, res[counterIds[i]]); } }
public void putJumpTouchPoint(int classLine, int trueCounterId, int falseCounterId) { updateLine(classLine); LineData ld = getOrCreateLine(classLine); int branchId = jumpsInLine++; classData.addLineJump(classLine, branchId); ld.touchJump(branchId, true, res[trueCounterId]); ld.touchJump(branchId, false, res[falseCounterId]); }
void addSwitch(int switchNumber, int min, int max, int maxBranches) { SwitchData sd = getSwitchData(switchNumber, new SwitchData( switchNumber, min, max, maxBranches)); if (sd.getMaxBranches() > maxBranches) { sd.setMaxBranches(maxBranches); } }
void touchJump(int jumpNumber, boolean branch) { getJumpData(jumpNumber).touchBranch(branch); }
void addSwitch(int switchNumber, int min, int max) { getSwitchData(switchNumber, new SwitchData(switchNumber, min, max)); }