Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

int256 tests #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion test/Assert.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}