From a520a8ab08e66df362db3ec1a9b50b587cf13650 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 30 Jun 2025 08:33:09 +1000 Subject: [PATCH] units: Test generic Add and Sub We have `Add` and `Sub` implemented for `NumOpResult` 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. --- units/src/amount/tests.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/units/src/amount/tests.rs b/units/src/amount/tests.rs index 088497504..74d8fab97 100644 --- a/units/src/amount/tests.rs +++ b/units/src/amount/tests.rs @@ -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(-306).into()); + + // Implemented using generic impl. + assert!(res(127) + sat(179) == sat(306).into()); + assert!(sres(127) + ssat(179) == ssat(306).into()); } #[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(52).into()); + + // Implemented using generic impl. + assert!(res(179) - sat(127) == sat(52).into()); + assert!(sres(179) - ssat(127) == ssat(52).into()); } #[test]