Merge rust-bitcoin/rust-bitcoin#4666: Kill new mutants
f0562504b7
Exclude deprecated fn from mutation testing (Jamil Lambert, PhD)4d31b141a8
Improve is_too_precise test (Jamil Lambert, PhD)a2bae3bb0b
Add test for impl Display for Script (Jamil Lambert, PhD) Pull request description: Weekly mutation testing found new mutants. There are also some untested mutants in match statements that will be included in future mutation testing once #4654 goes in. - Add a regression test for the mutants in the `Display` impl for `Script`. - Improve the existing test for `is_too_precise` to check all four cases. - Exclude the two deprecated functions that have untested mutants. Closes #4646 ACKs for top commit: benalleng: **tACK** no missed mutants onf056250
I ran with63b61e9497
rebased in to make sure the match arm and match guard mutations were included tcharding: ACKf0562504b7
Tree-SHA512: d109e30be91da2ab243a152b9ef17147337328282ac418fa9d2eebd17c2e2d9b6f7ee095d91ccf58e287c9620cb71a090b0d929c9bf35011feb26e6f28457dd3
This commit is contained in:
commit
ca5d136667
|
@ -24,6 +24,8 @@ exclude_re = [
|
|||
"SignedAmount::checked_abs", # Deprecated
|
||||
"NumberOfBlocks::value", # Deprecated
|
||||
"NumberOf512Seconds::to_consensus_u32", # Deprecated
|
||||
"MedianTimePast::to_consensus_u32", # Deprecated
|
||||
"Height::to_consensus_u32", # Deprecated
|
||||
|
||||
# primitives
|
||||
"Sequence::from_512_second_intervals", # Mutant from replacing | with ^, this returns the same value since the XOR is taken against the u16 with an all-zero bitmask
|
||||
|
|
|
@ -802,6 +802,21 @@ mod tests {
|
|||
assert!(!format!("{:?}", script).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn script_display_pushdata() {
|
||||
// OP_PUSHDATA1
|
||||
let script = Script::from_bytes(&[0x4c, 0x02, 0xab, 0xcd]);
|
||||
assert_eq!(format!("{}", script), "OP_PUSHDATA1 abcd");
|
||||
|
||||
// OP_PUSHDATA2
|
||||
let script = Script::from_bytes(&[0x4d, 0x02, 0x00, 0x12, 0x34]);
|
||||
assert_eq!(format!("{}", script), "OP_PUSHDATA2 1234");
|
||||
|
||||
// OP_PUSHDATA4
|
||||
let script = Script::from_bytes(&[0x4e, 0x02, 0x00, 0x00, 0x00, 0x56, 0x78]);
|
||||
assert_eq!(format!("{}", script), "OP_PUSHDATA4 5678");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scriptbuf_display() {
|
||||
let script_buf = ScriptBuf::from(vec![0x00, 0xa1, 0xb2]);
|
||||
|
|
|
@ -52,8 +52,14 @@ fn sanity_check() {
|
|||
|
||||
#[test]
|
||||
fn check_if_num_is_too_precise() {
|
||||
assert_eq!(is_too_precise("1234", 3).unwrap(), 3);
|
||||
assert_eq!(is_too_precise("1234.1234", 3).unwrap(), 3);
|
||||
// Has decimal, not too precise
|
||||
assert_eq!(is_too_precise("1234.5678", 4), Some(0));
|
||||
// Has decimal, is too precise
|
||||
assert_eq!(is_too_precise("1234.5678", 3), Some(3));
|
||||
// No decimal, not too precise
|
||||
assert_eq!(is_too_precise("1234", 4), Some(0));
|
||||
// No decimal, is too precise
|
||||
assert_eq!(is_too_precise("1234", 2), Some(3));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in New Issue