Skip to content

Commit

Permalink
Fixed issues identified in review. Abstracted some common code in NEN…
Browse files Browse the repository at this point in the history
…/NEB Assertion Tests.
  • Loading branch information
michelleblom committed Jun 23, 2024
1 parent 4da18fa commit 9f97b82
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 399 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ prefix, contestName, auditStatus(), auditReason(), diluted_margin, assertions.si
@Override
protected void recalculateSamplesToAudit() {
if(assertions == null){
// We have not associated assertions with this audit yet. When an IRVComparisonAudit
// We have not associated assertions with this audit yet. When an IRVComparisonAudit is
// constructed, we call the base class constructor first. The ComparisonAudit constructor
// calls sample size computation methods. So, this method may end up being called before
// the IRVComparisonAudit constructor has completed its setup (retrieving assertions from
Expand Down Expand Up @@ -530,7 +530,7 @@ public void recordDiscrepancy(final CVRAuditInfo theRecord, final int theType) {
// and the flag for indicating that a sample size recalculation is needed, *if* we did
// record a discrepancy against at least one of this audit's assertions.
if(recorded) {
super.removeDiscrepancy(theRecord, theType);
super.recordDiscrepancy(theRecord, theType);
}
LOGGER.debug(String.format("%s total number of overstatements (%f), optimistic sample " +
"recalculate needed (%s), estimated sample recalculate needed (%s),", prefix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,4 +483,28 @@ public static void checkComputeDiscrepancy(CastVoteRecord cvr, CastVoteRecord au
assertEquals(cvrDiscrepancies, a.cvrDiscrepancy);
}
}


/**
* Checks that the discrepancy counts in the given assertion 'a' are equal to the given
* parameters.
* @param a Assertion to check.
* @param oneOver Expected number of one vote overstatements.
* @param oneUnder Expected number of one vote understatements.
* @param twoOver Expected number of two vote overstatements.
* @param twoUnder Expected number of two vote understatements.
* @param other Expected number of other discrepancies.
* @param cvrDiscrepancy Expected internal map of CVR ID to discrepancy type.
*/
public static void checkCountsDiscrepancyMap(final Assertion a, int oneOver, int oneUnder,
int twoOver, int twoUnder, int other, final Map<Long,Integer> cvrDiscrepancy){

assertEquals(a.oneVoteOverCount.intValue(), oneOver);
assertEquals(a.oneVoteUnderCount.intValue(), oneUnder);
assertEquals(a.twoVoteOverCount.intValue(), twoOver);
assertEquals(a.twoVoteUnderCount.intValue(), twoUnder);
assertEquals(a.otherCount.intValue(), other);

assertEquals(a.cvrDiscrepancy, cvrDiscrepancy);
}
}
Loading

0 comments on commit 9f97b82

Please sign in to comment.