mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 19:19:30 +00:00
LibCore+Tests: Add SeekableStream::truncate()
This commit is contained in:
parent
d9fb1b8c2e
commit
4d5080388a
Notes:
sideshowbarker
2024-07-17 18:39:27 +09:00
Author: https://github.com/AtkinsSJ
Commit: 4d5080388a
Pull-request: https://github.com/SerenityOS/serenity/pull/12317
Reviewed-by: https://github.com/sin-ack ✅
Reviewed-by: https://github.com/trflynn89
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