Add toUint, toInt and hexToUint to Strings (#5166)
Co-authored-by: cairo <cairoeth@protonmail.com> Co-authored-by: Ernesto García <ernestognw@gmail.com>
This commit is contained in:
27
test/utils/Strings.t.sol
Normal file
27
test/utils/Strings.t.sol
Normal file
@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {Test} from "forge-std/Test.sol";
|
||||
|
||||
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
|
||||
|
||||
contract StringsTest is Test {
|
||||
using Strings for *;
|
||||
|
||||
function testParse(uint256 value) external {
|
||||
assertEq(value, value.toString().parseUint());
|
||||
}
|
||||
|
||||
function testParseSigned(int256 value) external {
|
||||
assertEq(value, value.toStringSigned().parseInt());
|
||||
}
|
||||
|
||||
function testParseHex(uint256 value) external {
|
||||
assertEq(value, value.toHexString().parseHexUint());
|
||||
}
|
||||
|
||||
function testParseChecksumHex(address value) external {
|
||||
assertEq(value, value.toChecksumHexString().parseAddress());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user