Merge rust-bitcoin/rust-bitcoin#4648: units: Test generic `Add` and `Sub`
a520a8ab08
units: Test generic Add and Sub (Tobin C. Harding)
Pull request description:
We have `Add` and `Sub` implemented for `NumOpResult<T>` but because the impls are generic they are not grouped in the file with the other add/sub impls. This makes it hard to see if they are supported.
Add to the `add` and `sub` unit tests to verify support is implemented.
ACKs for top commit:
apoelstra:
ACK a520a8ab08e66df362db3ec1a9b50b587cf13650; successfully ran local tests
Tree-SHA512: 01a10e03f759942910c80d33e0150633415bc678c0ed5a7a403265226418a3594a658dff37ec770de3409a785e4d80213352075f6cca9ccbe3baf827e63b35ad
This commit is contained in:
commit
6df0c82afa
|
@ -227,6 +227,10 @@ fn add() {
|
||||||
assert!(ssat(-127) + ssat(179) == ssat(52).into());
|
assert!(ssat(-127) + ssat(179) == ssat(52).into());
|
||||||
assert!(ssat(127) + ssat(-179) == ssat(-52).into());
|
assert!(ssat(127) + ssat(-179) == ssat(-52).into());
|
||||||
assert!(ssat(-127) + ssat(-179) == ssat(-306).into());
|
assert!(ssat(-127) + ssat(-179) == ssat(-306).into());
|
||||||
|
|
||||||
|
// Implemented using generic impl.
|
||||||
|
assert!(res(127) + sat(179) == sat(306).into());
|
||||||
|
assert!(sres(127) + ssat(179) == ssat(306).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -240,6 +244,10 @@ fn sub() {
|
||||||
assert!(ssat(-127) - ssat(179) == ssat(-306).into());
|
assert!(ssat(-127) - ssat(179) == ssat(-306).into());
|
||||||
assert!(ssat(127) - ssat(-179) == ssat(306).into());
|
assert!(ssat(127) - ssat(-179) == ssat(306).into());
|
||||||
assert!(ssat(-127) - ssat(-179) == ssat(52).into());
|
assert!(ssat(-127) - ssat(-179) == ssat(52).into());
|
||||||
|
|
||||||
|
// Implemented using generic impl.
|
||||||
|
assert!(res(179) - sat(127) == sat(52).into());
|
||||||
|
assert!(sres(179) - ssat(127) == ssat(52).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue