feat(data_types): PartialEq for SequenceNumberSet

Derive + test partial equality matching for SequenceNumberSet.
pull/24376/head
Dom Dwyer 2023-03-03 17:06:00 +01:00
parent c15d789613
commit 043f3421ba
No known key found for this signature in database
GPG Key ID: E4C40DBD9157879A
1 changed files with 21 additions and 1 deletions

View File

@ -3,7 +3,7 @@
use crate::SequenceNumber;
/// A space-efficient encoded set of [`SequenceNumber`].
#[derive(Debug, Default, Clone)]
#[derive(Debug, Default, Clone, PartialEq)]
pub struct SequenceNumberSet(croaring::Bitmap);
impl SequenceNumberSet {
@ -155,4 +155,24 @@ mod tests {
assert!(a.contains(SequenceNumber::new(4)));
assert!(a.contains(SequenceNumber::new(2)));
}
#[test]
fn test_partial_eq() {
let mut a = SequenceNumberSet::default();
let mut b = SequenceNumberSet::default();
assert_eq!(a, b);
a.add(SequenceNumber::new(42));
assert_ne!(a, b);
b.add(SequenceNumber::new(42));
assert_eq!(a, b);
b.add(SequenceNumber::new(24));
assert_ne!(a, b);
a.add(SequenceNumber::new(24));
assert_eq!(a, b);
}
}