Skip to content

Commit

Permalink
refactor(test): improve assertEq(bool,bool) error messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverNChalk committed Apr 21, 2022
1 parent 3e0ef00 commit 1f08a76
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ abstract contract Test is DSTest {
}

/*//////////////////////////////////////////////////////////////////////////
APPROX EQUAL
ASSERTIONS
//////////////////////////////////////////////////////////////////////////*/

function assertApproxEqAbs(
Expand Down Expand Up @@ -261,8 +261,22 @@ abstract contract Test is DSTest {
BOOL ASSERTS
//////////////////////////////////////////////////////////////////////////*/

function assertEq(bool a, bool b) internal virtual {
b ? assertTrue(a) : assertFalse(a);
function assertEq(bool a, bool b) internal {
if (a != b) {
emit log_named_string("Error: a == b not satisfied [bool]");
emit log_named_string(" Expected", b ? "true" : "false");
emit log_named_string(" Actual", a ? "true" : "false");
fail();
}
}

function assertEq(bool a, bool b, string memory err) internal {
if (a != b) {
emit log_named_string("Error", err);
emit log_named_string(" Expected", b ? "true" : "false");
emit log_named_string(" Actual", a ? "true" : "false");
fail();
}
}

function assertEq(bool a, bool b, string memory err) internal virtual {
Expand Down

0 comments on commit 1f08a76

Please sign in to comment.