Skip to content

Commit 6df0c82

Browse files
committed
Merge rust-bitcoin#4648: units: Test generic Add and Sub
a520a8a 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 a520a8a; successfully ran local tests Tree-SHA512: 01a10e03f759942910c80d33e0150633415bc678c0ed5a7a403265226418a3594a658dff37ec770de3409a785e4d80213352075f6cca9ccbe3baf827e63b35ad
2 parents ad40e69 + a520a8a commit 6df0c82

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

units/src/amount/tests.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ fn add() {
227227
assert!(ssat(-127) + ssat(179) == ssat(52).into());
228228
assert!(ssat(127) + ssat(-179) == ssat(-52).into());
229229
assert!(ssat(-127) + ssat(-179) == ssat(-306).into());
230+
231+
// Implemented using generic impl.
232+
assert!(res(127) + sat(179) == sat(306).into());
233+
assert!(sres(127) + ssat(179) == ssat(306).into());
230234
}
231235

232236
#[test]
@@ -240,6 +244,10 @@ fn sub() {
240244
assert!(ssat(-127) - ssat(179) == ssat(-306).into());
241245
assert!(ssat(127) - ssat(-179) == ssat(306).into());
242246
assert!(ssat(-127) - ssat(-179) == ssat(52).into());
247+
248+
// Implemented using generic impl.
249+
assert!(res(179) - sat(127) == sat(52).into());
250+
assert!(sres(179) - ssat(127) == ssat(52).into());
243251
}
244252

245253
#[test]

0 commit comments

Comments
 (0)