From 0b400af9519444deef4cc6ad2c43c30e2092ab4f Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Sat, 4 Jan 2025 09:56:12 -0600 Subject: Fix bug related to string copying. --- test/test_directory.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'test/test_directory.cpp') diff --git a/test/test_directory.cpp b/test/test_directory.cpp index 0f7dc8d..7a420ca 100644 --- a/test/test_directory.cpp +++ b/test/test_directory.cpp @@ -20,13 +20,14 @@ #include "fud_directory.hpp" #include "fud_string.hpp" #include "test_common.hpp" +#include "fud_print.hpp" #include "gtest/gtest.h" #include #include #include #include -#include +#include // IWYU pragma: keep - this warning is WRONG namespace fud { @@ -59,6 +60,7 @@ TEST(FudDirectory, Basic) ASSERT_TRUE(fileResult.isOkay()); CBinaryFile file{std::move(fileResult).takeOkay()}; ASSERT_EQ(file.open(), FudStatus::Success); + // NOLINTNEXTLINE(readability-magic-numbers) Array data{u8"test"}; DrainResult expected{data.size(), FudStatus::Success}; auto writeResult = file.write(data); @@ -71,6 +73,8 @@ TEST(FudDirectory, Basic) Directory directory{directoryResult.takeOkay()}; ASSERT_EQ(directory.errorCode(), 0); + debugPrint(u8"What? Filename = '{}', expected '{}' \n'", String::from(files[0]).takeOkay().asView(), files[0].asView()); + debugPrint(u8"What? Filename = '{}', expected '{}' \n'", String::from(files[1]).takeOkay().asView(), files[1].asView()); const Array expectedFiles{ DirectoryEntry{String::makeFromCString(".").takeOkay(), 0, 0, 2, 0, DirectoryEntryType::Directory}, DirectoryEntry{String::makeFromCString("..").takeOkay(), 0, 0, 1, 0, DirectoryEntryType::Directory}, @@ -80,6 +84,7 @@ TEST(FudDirectory, Basic) ASSERT_TRUE(expectedFiles[0].name.compare(expectedFiles[0].name)); for (auto idx = 0; idx < expectedFiles.size(); ++idx) { + debugPrint(u8"On iteration {} - '{}' \n", idx, expectedFiles[idx].name.asView()); auto dirEntryResult = directory.getNextEntry(); EXPECT_TRUE(dirEntryResult.isOkay()); auto dirEntryOpt = dirEntryResult.takeOkay(); @@ -87,9 +92,8 @@ TEST(FudDirectory, Basic) break; } auto dirEntry{std::move(dirEntryOpt.value())}; - const auto* expected = std::find_if( - expectedFiles.begin(), - expectedFiles.end(), + const auto* expected = std::ranges::find_if( + expectedFiles, [&dirEntry](const DirectoryEntry& entry) { return entry.name.compare(dirEntry.name) && entry.entryType == dirEntry.entryType; }); -- cgit v1.2.3