Skip to content

Commit

Permalink
add invariant test
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakocsis committed Apr 25, 2024
1 parent 4c7dafc commit bc5f8c0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/libraries/UnsafeMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ contract UnsafeMathTest is Test {
}

function test_fuzz_divRoundingUp(uint256 x, uint256 y) public {
vm.assume(y != 0);
uint256 result = x.divRoundingUp(y);
assertTrue(result == x / y || result == x / y + 1);
}

function test_invariant_divRoundingUp(uint256 x, uint256 y) public {
vm.assume(y != 0);
uint256 z = x.divRoundingUp(y);
uint256 diff = z - (x / y);
Expand Down

0 comments on commit bc5f8c0

Please sign in to comment.