1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:07:44 +00:00

Tests: Use FileSystem instead of DeprecatedFile

This commit is contained in:
Cameron Youell 2023-03-27 00:37:51 +00:00 committed by Andrew Kaster
parent 1c54c8a01c
commit 03008ec4e0
6 changed files with 615 additions and 565 deletions

View file

@ -7,7 +7,7 @@
#include <AK/Assertions.h>
#include <AK/Types.h>
#include <LibCore/DeprecatedFile.h>
#include <LibFileSystem/FileSystem.h>
#include <LibTest/TestCase.h>
#include <fcntl.h>
#include <stdio.h>
@ -217,11 +217,11 @@ TEST_CASE(unlink_symlink)
perror("symlink");
}
auto target_or_error = Core::DeprecatedFile::read_link("/tmp/linky");
auto target_or_error = FileSystem::read_link("/tmp/linky"sv);
EXPECT(!target_or_error.is_error());
auto target = target_or_error.release_value();
EXPECT_EQ(target, "/proc/2/foo");
EXPECT_EQ(target.bytes_as_string_view(), "/proc/2/foo"sv);
rc = unlink("/tmp/linky");
EXPECT(rc >= 0);

View file

@ -6,7 +6,7 @@
*/
#include <AK/DeprecatedString.h>
#include <LibCore/DeprecatedFile.h>
#include <LibFileSystem/FileSystem.h>
#include <LibTest/TestCase.h>
#include <fcntl.h>
#include <stdio.h>
@ -86,10 +86,10 @@ TEST_CASE(test_mkstemp_unique_filename)
auto fd = mkstemp(path);
EXPECT_NE(fd, -1);
auto temp_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
auto temp_path_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!temp_path_or_error.is_error());
auto temp_path = temp_path_or_error.release_value();
auto temp_path = temp_path_or_error.release_value().to_deprecated_string();
EXPECT(temp_path.characters());
close(fd);
@ -107,10 +107,10 @@ TEST_CASE(test_mkstemp_unique_filename)
auto fd = mkstemp(path);
EXPECT(fd != -1);
auto path2_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
auto path2_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!path2_or_error.is_error());
auto path2 = path2_or_error.release_value();
auto path2 = path2_or_error.release_value().to_deprecated_string();
EXPECT(path2.characters());
close(fd);
@ -132,10 +132,10 @@ TEST_CASE(test_mkstemps_unique_filename)
auto fd = mkstemps(path, 6);
EXPECT_NE(fd, -1);
auto temp_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
auto temp_path_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!temp_path_or_error.is_error());
auto temp_path = temp_path_or_error.release_value();
auto temp_path = temp_path_or_error.release_value().to_deprecated_string();
EXPECT(temp_path.characters());
close(fd);
@ -157,10 +157,10 @@ TEST_CASE(test_mkstemps_unique_filename)
auto fd = mkstemps(path, 6);
EXPECT(fd != -1);
auto path2_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
auto path2_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!path2_or_error.is_error());
auto path2 = path2_or_error.release_value();
auto path2 = path2_or_error.release_value().to_deprecated_string();
EXPECT(path2.characters());
close(fd);