From 30aa85c5b1e8e0d9dea69e84c40e23958b4df0a9 Mon Sep 17 00:00:00 2001 From: Antonio Gabriel Date: Mon, 8 Jul 2024 15:15:16 -0300 Subject: [PATCH] int256 tests --- test/Assert.t.sol | 54 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/test/Assert.t.sol b/test/Assert.t.sol index 53bdfc9..5caf1cb 100644 --- a/test/Assert.t.sol +++ b/test/Assert.t.sol @@ -119,5 +119,57 @@ contract TestAsserts is Test, HelperAssert { vm.expectRevert(PlatformTest.TestAssertFail.selector); eq(x, y, reason); - } + } + + /// @notice int256 version of eq test + function test_eq_int_x_x() public { + int256 x = 2; + eq(x, x, "example message"); + } + + function testFuzz_eq_int_x_x(int256 x) public { + eq(x, x, "example message"); + } + + function test_eq_int_x_y() public { + int256 x = 2; + int256 y = 4; + + string memory reason = "example message"; + string memory failReason = createAssertFailMessage( + FuzzLibString.toString(x), + FuzzLibString.toString(y), + "!=", + reason + ); + vm.expectEmit(true, false, false, true); + emit AssertEqFail(failReason); + + vm.expectRevert(PlatformTest.TestAssertFail.selector); + + eq(x, y, reason); + } + + function testFuzz_eq_int_x_y(int256 x, int256 y) public { + vm.assume(x > type(int256).min / 2 && x < type(int256).max / 2); + vm.assume(y > type(int256).min / 2 && y < type(int256).max / 2); + vm.assume(x != y); + + string memory reason = "example message"; + + vm.expectEmit(true, false, false, false); + string memory failReason = createAssertFailMessage( + FuzzLibString.toString(x), + FuzzLibString.toString(y), + "!=", + reason + ); + + emit AssertEqFail(failReason); + + vm.expectRevert(PlatformTest.TestAssertFail.selector); + + eq(x, y, reason); + } + } \ No newline at end of file