Skip to content

Commit 0cf73c4

Browse files
authored
Add tests for MostSeen decrement bug
This bug requires a specific set of circumstances to trigger and become visible: 1. decrement a label that is non-zero but not first 2. repeat the decrement at least best_count()/2 times 3. increment that label 4. check the best count
1 parent 79d2e93 commit 0cf73c4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

backend/common/src/most_seen.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,5 +248,11 @@ mod test {
248248
assert!(res.has_changed());
249249
assert_eq!(a.best_count(), 2);
250250
assert_eq!(*a.best(), "First"); // First is now ahead
251+
252+
a.remove(&"Third"); // 0, or 2 with bug #595
253+
a.remove(&"Third"); // 0, or 4 with bug #595
254+
a.insert(&"Third"); // 1, or 5 with bug #595
255+
assert_eq!(a.best_count(), 2);
256+
assert_eq!(*a.best(), "First"); // First is still ahead
251257
}
252258
}

0 commit comments

Comments
 (0)