-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
native string utils cheatcodes (#6891)
* string utils cheatcodes created * fmt: run rustfmt * tests: solidity tests added * cargo cheats * update * update * chore: update defs --------- Co-authored-by: Matthias Seitz <[email protected]> Co-authored-by: Enrique Ortiz <[email protected]>
- Loading branch information
1 parent
3cc7bda
commit c61dc80
Showing
5 changed files
with
208 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity 0.8.18; | ||
|
||
import "ds-test/test.sol"; | ||
import "./Vm.sol"; | ||
|
||
contract StringManipulationTest is DSTest { | ||
Vm constant vm = Vm(HEVM_ADDRESS); | ||
|
||
function testToLowercase() public { | ||
string memory original = "Hello World"; | ||
string memory lowercased = vm.toLowercase(original); | ||
assertEq("hello world", lowercased); | ||
} | ||
|
||
function testToUppercase() public { | ||
string memory original = "Hello World"; | ||
string memory uppercased = vm.toUppercase(original); | ||
assertEq("HELLO WORLD", uppercased); | ||
} | ||
|
||
function testTrim() public { | ||
string memory original = " Hello World "; | ||
string memory trimmed = vm.trim(original); | ||
assertEq("Hello World", trimmed); | ||
} | ||
|
||
function testReplace() public { | ||
string memory original = "Hello World"; | ||
string memory replaced = vm.replace(original, "World", "Reth"); | ||
assertEq("Hello Reth", replaced); | ||
} | ||
|
||
function testSplit() public { | ||
string memory original = "Hello,World,Reth"; | ||
string[] memory splitResult = vm.split(original, ","); | ||
assertEq(3, splitResult.length); | ||
assertEq("Hello", splitResult[0]); | ||
assertEq("World", splitResult[1]); | ||
assertEq("Reth", splitResult[2]); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.