Add tests to CompactTarget

Add tests to pow.rs to kill the mutants found in CompactTarget.
This commit is contained in:
Jamil Lambert, PhD 2025-02-06 17:05:06 +00:00
parent a380d4b9de
commit b2d0737acc
No known key found for this signature in database
GPG Key ID: 54DC29234AB5D2C0
1 changed files with 23 additions and 0 deletions

View File

@ -43,3 +43,26 @@ impl fmt::UpperHex for CompactTarget {
#[inline] #[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperHex::fmt(&self.0, f) } fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperHex::fmt(&self.0, f) }
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn compact_target_ordering() {
let lower = CompactTarget::from_consensus(0x1d00fffe);
let lower_copy = CompactTarget::from_consensus(0x1d00fffe);
let higher = CompactTarget::from_consensus(0x1d00ffff);
assert!(lower < higher);
assert!(lower == lower_copy);
}
#[test]
fn compact_target_formatting() {
let compact_target = CompactTarget::from_consensus(0x1d00ffff);
assert_eq!(format!("{:x}", compact_target), "1d00ffff");
assert_eq!(format!("{:X}", compact_target), "1D00FFFF");
assert_eq!(compact_target.to_consensus(), 0x1d00ffff);
}
}