Merge rust-bitcoin/rust-bitcoin#4190: Kill mutants in primitives and units
90d909becc
Kill mutants in primitives and units (Shing Him Ng) Pull request description: This kills 15 mutants found with the mutants workflow. Ran `cargo mutants` locally to confirm Closes #4156 Closes #4106 ACKs for top commit: jamillambert: ACK90d909becc
tcharding: ACK90d909becc
apoelstra: ACK 90d909becc4638c03003845154e9cc1eb5f3ad41; successfully ran local tests Kixunil: ACK90d909becc
Tree-SHA512: e5c95a1c4054cf1c60c940ea605eec84dffcbff292f9c7c4d96813c6389e807c318f6c5f8f69ceeb9ffcab3c3e45aa0d5a8fda7335d540c6f070aab92bae7a0f
This commit is contained in:
commit
9d7190e581
|
@ -645,6 +645,18 @@ impl<'a> Arbitrary<'a> for Txid {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sanity_check() {
|
||||||
|
let version = Version(123);
|
||||||
|
assert_eq!(version.to_u32(), 123);
|
||||||
|
assert_eq!(u32::from(version), 123);
|
||||||
|
|
||||||
|
assert!(!version.is_standard());
|
||||||
|
assert!(Version::ONE.is_standard());
|
||||||
|
assert!(Version::TWO.is_standard());
|
||||||
|
assert!(Version::THREE.is_standard());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn transaction_functions() {
|
fn transaction_functions() {
|
||||||
let txin = TxIn {
|
let txin = TxIn {
|
||||||
|
|
|
@ -37,6 +37,11 @@ fn sanity_check() {
|
||||||
assert_eq!(Amount::from_float_in(2_f64, Denomination::Bitcoin).unwrap(), sat(200_000_000));
|
assert_eq!(Amount::from_float_in(2_f64, Denomination::Bitcoin).unwrap(), sat(200_000_000));
|
||||||
assert!(Amount::from_float_in(-100_f64, Denomination::Bitcoin).is_err());
|
assert!(Amount::from_float_in(-100_f64, Denomination::Bitcoin).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let result = NumOpResult::Valid(sat(123));
|
||||||
|
assert_eq!(Some(sat(123)), result.ok());
|
||||||
|
assert!(result.is_valid());
|
||||||
|
assert!(!result.is_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1010,6 +1015,12 @@ fn sum_amounts() {
|
||||||
assert_eq!([].iter().sum::<NumOpResult<Amount>>(), Amount::ZERO.into());
|
assert_eq!([].iter().sum::<NumOpResult<Amount>>(), Amount::ZERO.into());
|
||||||
assert_eq!([].iter().sum::<NumOpResult<SignedAmount>>(), SignedAmount::ZERO.into());
|
assert_eq!([].iter().sum::<NumOpResult<SignedAmount>>(), SignedAmount::ZERO.into());
|
||||||
|
|
||||||
|
let results = [NumOpResult::Valid(sat(42)), NumOpResult::Valid(sat(1337)), NumOpResult::Valid(sat(21))];
|
||||||
|
assert_eq!(results.iter().sum::<NumOpResult<Amount>>(), NumOpResult::Valid(sat(1400)));
|
||||||
|
|
||||||
|
let signed_results = [NumOpResult::Valid(ssat(42)), NumOpResult::Valid(ssat(1337)), NumOpResult::Valid(ssat(21))];
|
||||||
|
assert_eq!(signed_results.iter().sum::<NumOpResult<SignedAmount>>(), NumOpResult::Valid(ssat(1400)));
|
||||||
|
|
||||||
let amounts = [sat(42), sat(1337), sat(21)];
|
let amounts = [sat(42), sat(1337), sat(21)];
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
amounts.iter().map(|a| NumOpResult::Valid(*a)).sum::<NumOpResult<Amount>>(),
|
amounts.iter().map(|a| NumOpResult::Valid(*a)).sum::<NumOpResult<Amount>>(),
|
||||||
|
|
Loading…
Reference in New Issue