diff --git a/test/utils/math/Math.t.sol b/test/utils/math/Math.t.sol index 6c122d66c3f..b4856f7850f 100644 --- a/test/utils/math/Math.t.sol +++ b/test/utils/math/Math.t.sol @@ -11,6 +11,29 @@ contract MathTest is Test { assertEq(Math.ternary(f, a, b), f ? a : b); } + // ADD512 & MUL512 + function testAdd512(uint256 a, uint256 b) public pure { + (uint256 high, uint256 low) = Math.add512(a, b); + (bool success, uint256 result) = Math.tryAdd(a, b); + if (success) { + assertEq(high, 0); + assertEq(low, result); + } else { + assertEq(high, 1); + } + } + + function testMul512(uint256 a, uint256 b) public pure { + (uint256 high, uint256 low) = Math.mul512(a, b); + (bool success, uint256 result) = Math.tryMul(a, b); + if (success) { + assertEq(high, 0); + assertEq(low, result); + } else { + assertGt(high, 0); + } + } + // MIN & MAX function testSymbolicMinMax(uint256 a, uint256 b) public pure { assertEq(Math.min(a, b), a < b ? a : b);