Add tests to CompactTarget
Add tests to pow.rs to kill the mutants found in CompactTarget.
This commit is contained in:
parent
a380d4b9de
commit
b2d0737acc
|
@ -43,3 +43,26 @@ impl fmt::UpperHex for CompactTarget {
|
|||
#[inline]
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue