diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_csv.cpp | 2 | ||||
-rw-r--r-- | test/test_directory.cpp | 12 | ||||
-rw-r--r-- | test/test_fud.cpp | 11 | ||||
-rw-r--r-- | test/test_string.cpp | 15 |
4 files changed, 32 insertions, 8 deletions
diff --git a/test/test_csv.cpp b/test/test_csv.cpp index 65c02ef..83bfe0a 100644 --- a/test/test_csv.cpp +++ b/test/test_csv.cpp @@ -201,7 +201,7 @@ TEST(FudCsv, ParseNuclides) pushExpected(StringView{u8"ENSDFauthors"}); pushExpected(StringView{u8"Extraction_date"}); - StringView nuclidesFilename{u8"test/nuclides.csv"}; + StringView nuclidesFilename{u8"nuclides.csv"}; Csv csv{Csv::makeDefault()}; auto parseStatus = Csv::parseFromFilenameUnbuffered(csv, nuclidesFilename); if (parseStatus != FudStatus::Success) { 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 <algorithm> #include <cerrno> #include <fcntl.h> #include <ftw.h> -#include <ranges> +#include <ranges> // 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<utf8, 5> 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<DirectoryEntry, 4> 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; }); diff --git a/test/test_fud.cpp b/test/test_fud.cpp index f84ad20..8dea206 100644 --- a/test/test_fud.cpp +++ b/test/test_fud.cpp @@ -33,6 +33,7 @@ TEST(FudTest, FudFud) auto compareResult = compareMem( fudInfo.revision.data(), fudInfo.revision.size(), + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) FudGitHash, fudInfo.revision.size() - 1); ASSERT_TRUE(compareResult.isOkay()); @@ -52,14 +53,18 @@ TEST(FudTest, GetEnv) ASSERT_EQ(fudVarResult.getError(), FudStatus::NullPointer); fudVarResult = std::move(getEnv(testVarName)); - ASSERT_TRUE(fudVarResult.isError()); - ASSERT_EQ(fudVarResult.getError(), FudStatus::NotFound); + ASSERT_TRUE(fudVarResult.isOkay()); + ASSERT_TRUE(fudVarResult.getOkay().isNone()); ASSERT_EQ(setenv(testVarName, testVarValue, 1), 0); + ASSERT_NE(getenv(testVarName), nullptr); + ASSERT_STREQ(getenv(testVarName), testVarValue); + fudVarResult = getEnv(testVarName); ASSERT_TRUE(fudVarResult.isOkay()); auto fudVar{fudVarResult.takeOkay()}; - ASSERT_STREQ(fudVar.c_str(), testVarValue); + ASSERT_TRUE(fudVar.hasValue()); + ASSERT_STREQ(fudVar.value().c_str(), testVarValue); } } // namespace fud diff --git a/test/test_string.cpp b/test/test_string.cpp index ba2df6c..39a24cb 100644 --- a/test/test_string.cpp +++ b/test/test_string.cpp @@ -39,6 +39,7 @@ TEST(FudString, BasicStringOps) ASSERT_FALSE(Ascii::valid(invalid[0])); const Array<utf8, 2> invalid2{0xFF, 0x00}; + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) auto stringResult = String::makeFromCString(reinterpret_cast<const char*>(invalid2.data())); ASSERT_TRUE(stringResult.isOkay()); @@ -77,7 +78,9 @@ TEST(FudString, ViewFromCString) TEST(FudString, HeapAlloc) { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays) constexpr const char filenameLiteral[] = "Amazing Saga Volume 01/000.jpg"; + // NOLINTNEXTLINE auto filenameResult{String::makeFromCString(filenameLiteral)}; ASSERT_TRUE(filenameResult.isOkay()); auto filename{filenameResult.takeOkay()}; @@ -92,6 +95,18 @@ TEST(FudString, Reserve) ASSERT_TRUE(testString.utf8Valid()); } +TEST(FudString, Equality) +{ + StringView levo{u8"a"}; + StringView dextro{u8"a"}; + ASSERT_EQ(levo, dextro); + + levo = StringView{u8"z"}; + dextro = StringView{u8"z"}; + ASSERT_EQ(levo, dextro); + ASSERT_EQ(levo.length(), 1); +} + #if 0 TEST(FudString, FindSubstringCxx) { |