diff options
Diffstat (limited to 'test/test_directory.cpp')
-rw-r--r-- | test/test_directory.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/test/test_directory.cpp b/test/test_directory.cpp index ff10c2d..6597195 100644 --- a/test/test_directory.cpp +++ b/test/test_directory.cpp @@ -51,7 +51,7 @@ FudStatus removeRecursive(const String& path) if (path.length() < 5) { return FudStatus::InvalidInput; } - const String prefix{"/tmp/"}; + auto prefix{String::makeFromCString("/tmp/").takeOkay()}; auto diffResult = compareMem(path.data(), path.length(), prefix.data(), prefix.length()); if (diffResult.isError()) { return FudStatus::InvalidInput; @@ -75,13 +75,12 @@ FudStatus removeRecursive(const String& path) TEST(FudDirectory, Basic) { - const String testDirName{"/tmp/fud_directory_test"}; + const auto testDirName{String::makeFromCString("/tmp/fud_directory_test").takeOkay()}; ASSERT_TRUE(testDirName.utf8Valid()); constexpr mode_t pathMode = 0777; const Array<String, 2> files{ - String{"file1"}, - String{"file2"}, - }; + String::makeFromCString("file1").takeOkay(), + String::makeFromCString("file2").takeOkay()}; ASSERT_TRUE(files[0].utf8Valid()); ASSERT_TRUE(files[1].utf8Valid()); @@ -94,12 +93,14 @@ TEST(FudDirectory, Basic) return; } - const String testDirNamePrefix = testDirName.catenate("/"); + const String testDirNamePrefix{testDirName.catenate("/").takeOkay()}; ASSERT_TRUE(testDirNamePrefix.utf8Valid()); for (const auto& fnameBase : files) { - const auto fname = testDirNamePrefix.catenate(fnameBase); + const auto fname{testDirNamePrefix.catenate(fnameBase).takeOkay()}; ASSERT_TRUE(fname.utf8Valid()); - CBinaryFile file{fname, CFileMode::ReadWriteTruncate}; + auto fileResult{CBinaryFile::make(fname, CFileMode::ReadWriteTruncate)}; + ASSERT_TRUE(fileResult.isOkay()); + CBinaryFile file{std::move(fileResult).takeOkay()}; ASSERT_EQ(file.open(), FudStatus::Success); Array<utf8, 5> data{"test"}; WriteResult expected{data.size(), FudStatus::Success}; @@ -113,8 +114,8 @@ TEST(FudDirectory, Basic) ASSERT_EQ(directory.errorCode(), 0); const Array<DirectoryEntry, 4> expectedFiles{ - DirectoryEntry{String{"."}, 0, 0, 2, 0, DirectoryEntryType::Directory}, - DirectoryEntry{String{".."}, 0, 0, 1, 0, DirectoryEntryType::Directory}, + DirectoryEntry{String::makeFromCString(".").takeOkay(), 0, 0, 2, 0, DirectoryEntryType::Directory}, + DirectoryEntry{String::makeFromCString("..").takeOkay(), 0, 0, 1, 0, DirectoryEntryType::Directory}, DirectoryEntry{files[0], 0, files[0].size(), 1, 0, DirectoryEntryType::RegularFile}, DirectoryEntry{files[1], 0, files[1].size(), 1, 0, DirectoryEntryType::RegularFile}, }; @@ -131,7 +132,9 @@ TEST(FudDirectory, Basic) const auto* expected = std::find_if( expectedFiles.begin(), expectedFiles.end(), - [&dirEntry](const DirectoryEntry& entry) { return entry.name.compare(dirEntry.name) && entry.entryType == dirEntry.entryType; }); + [&dirEntry](const DirectoryEntry& entry) { + return entry.name.compare(dirEntry.name) && entry.entryType == dirEntry.entryType; + }); EXPECT_NE(expected, nullptr); EXPECT_NE(expected, expectedFiles.end()); } |