fixed bug in SequenceNumberStats and its unit test; test passes now

This commit is contained in:
wangyix 2014-07-03 10:37:09 -07:00
parent ab503583dd
commit 059628c26a
2 changed files with 14 additions and 2 deletions

View file

@ -94,6 +94,7 @@ void SequenceNumberStats::sequenceNumberReceived(quint16 incoming, QUuid senderU
_numEarly++; _numEarly++;
_numLost += (incomingInt - expectedInt); _numLost += (incomingInt - expectedInt);
_lastReceived = incoming;
// add all sequence numbers that were skipped to the missing sequence numbers list // add all sequence numbers that were skipped to the missing sequence numbers list
for (int missingInt = expectedInt; missingInt < incomingInt; missingInt++) { for (int missingInt = expectedInt; missingInt < incomingInt; missingInt++) {
@ -105,8 +106,6 @@ void SequenceNumberStats::sequenceNumberReceived(quint16 incoming, QUuid senderU
if (_missingSet.size() > MAX_REASONABLE_SEQUENCE_GAP) { if (_missingSet.size() > MAX_REASONABLE_SEQUENCE_GAP) {
pruneMissingSet(wantExtraDebugging); pruneMissingSet(wantExtraDebugging);
} }
_lastReceived = incoming;
} else { // late } else { // late
if (wantExtraDebugging) { if (wantExtraDebugging) {
qDebug() << "this packet is later than expected..."; qDebug() << "this packet is later than expected...";

View file

@ -115,6 +115,11 @@ void SequenceNumberStatsTests::earlyLateTest() {
} }
} }
stats.reset(); stats.reset();
numSent = 0;
numEarly = 0;
numLate = 0;
numLost = 0;
numRecovered = 0;
} }
} }
@ -203,6 +208,11 @@ void SequenceNumberStatsTests::duplicateTest() {
} }
} }
stats.reset(); stats.reset();
numSent = 0;
numDuplicate = 0;
numEarly = 0;
numLate = 0;
numLost = 0;
} }
} }
@ -263,5 +273,8 @@ void SequenceNumberStatsTests::pruneTest() {
} }
} }
stats.reset(); stats.reset();
numSent = 0;
numEarly = 0;
numLost = 0;
} }
} }