mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:48:11 +00:00
LibCore+Tests: Add SeekableStream::truncate()
This commit is contained in:
parent
d9fb1b8c2e
commit
4d5080388a
4 changed files with 27 additions and 0 deletions
|
@ -135,6 +135,18 @@ TEST_CASE(file_adopt_invalid_fd)
|
|||
EXPECT_EQ(maybe_file.error().code(), EBADF);
|
||||
}
|
||||
|
||||
TEST_CASE(file_truncate)
|
||||
{
|
||||
auto maybe_file = Core::Stream::File::open("/tmp/file-truncate-test.txt", Core::Stream::OpenMode::Write);
|
||||
auto file = maybe_file.release_value();
|
||||
|
||||
EXPECT(!file->truncate(999).is_error());
|
||||
EXPECT_EQ(file->size().release_value(), 999);
|
||||
|
||||
EXPECT(!file->truncate(42).is_error());
|
||||
EXPECT_EQ(file->size().release_value(), 42);
|
||||
}
|
||||
|
||||
// TCPSocket tests
|
||||
|
||||
TEST_CASE(should_error_when_connection_fails)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue