Skip to content

Commit

Permalink
test: add test for empty filename
Browse files Browse the repository at this point in the history
  • Loading branch information
stevennevins committed Nov 29, 2023
1 parent a29ffef commit 7786808
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/interfaces/IFileSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ interface IFileSystem {
*/
error InodeNotFound();

/**
* @notice Error thrown when file name is empty
*/
error InvalidFileName();

/**
Expand Down
6 changes: 6 additions & 0 deletions test/FileSystem/CreateDirectory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ contract CreateDirectory is FileSystemTest {
fileSystem.createDirectory(fileNames, filePointers);
}

function test_RevertsWhen_FileNameEmpty() public {
fileNames[0] = "";
vm.expectRevert(INVALID_FILENAME_ERROR);
fileSystem.createDirectory(fileNames, filePointers);
}

function test_RevertsWhen_InvalidCharacters() public {
fileNames[0] = "/";
vm.expectRevert(INVALID_CHARACTER_ERROR);
Expand Down
1 change: 1 addition & 0 deletions test/FileSystem/FileSystemTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ contract FileSystemTest is Test {
bytes4 internal immutable FILE_NOT_FOUND_ERROR = IFileSystem.FileNotFound.selector;
bytes4 internal immutable INODE_NOT_FOUND_ERROR = IFileSystem.InodeNotFound.selector;
bytes4 internal immutable INVALID_CHARACTER_ERROR = IFileSystem.InvalidCharacter.selector;
bytes4 internal immutable INVALID_FILENAME_ERROR = IFileSystem.InvalidFileName.selector;
bytes4 internal immutable LENGTH_MISMATCH_ERROR = IFileSystem.LengthMismatch.selector;

function setUp() public virtual {
Expand Down

0 comments on commit 7786808

Please sign in to comment.