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

Removing toUint224 functions #436

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions contracts/src/libraries/SafeCast.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,4 @@ library SafeCast {

y = uint128(x);
}

function toUint224(uint256 x) internal pure returns (uint224 y) {
require(x < 1 << 224);

y = uint224(x);
}
}
4 changes: 0 additions & 4 deletions contracts/test/MockSafeCast.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ contract MockSafeCast {
function toUint128(uint256 x) external pure returns (uint128 y) {
y = SafeCast.toUint128(x);
}

function toUint224(uint256 x) external pure returns (uint224 y) {
y = SafeCast.toUint224(x);
}
}
23 changes: 0 additions & 23 deletions test/units/libraries/SafeCast.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,4 @@ contract SafeCastTest is BaseTest {
vm.expectRevert();
mock.toUint128(2 ** 255);
}

function test_toUint224() public {
MockSafeCast mock = new MockSafeCast();

uint224 cast_num = mock.toUint224(0);
assertEq(cast_num, uint224(0));
cast_num = mock.toUint224(1);
assertEq(cast_num, uint224(1));
cast_num = mock.toUint224(2 ** 224 - 1);
assertEq(cast_num, uint224(2 ** 224 - 1));

vm.expectRevert();
mock.toUint224(2 ** 224);

vm.expectRevert();
mock.toUint224(2 ** 256 - 1);

vm.expectRevert();
mock.toUint224(2 ** 240);

vm.expectRevert();
mock.toUint224(2 ** 255);
}
}