Skip to content

Commit

Permalink
fix possible division by zero in object pool test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattelser committed Oct 12, 2023
1 parent 8a803a9 commit e0e3b34
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/src/ObjectPoolTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ void testRandomSequenceOfCmds(MockObjectPool& opl, int numEvents, bool setCap) {

// The percent active is calculated out of the pool's total capacity
// which must be gte our max observed active count
CHECK(opl.computePercentActive() <= (float)numActive / (float)maxActiveCount);
float expectedPercentActive;
if (maxActiveCount != 0) {
expectedPercentActive = (float)numActive / (float)maxActiveCount;
} else {
expectedPercentActive = 0;
}
CHECK(opl.computePercentActive() <= expectedPercentActive);
}

// ---- Begin tests ----
Expand Down

0 comments on commit e0e3b34

Please sign in to comment.