summaryrefslogtreecommitdiff
path: root/test/test_common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_common.cpp')
-rw-r--r--test/test_common.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/test/test_common.cpp b/test/test_common.cpp
index f272dad..03c5dff 100644
--- a/test/test_common.cpp
+++ b/test/test_common.cpp
@@ -27,28 +27,35 @@ namespace fud {
std::byte* MockFudAlloc::operator()(size_t size)
{
+ // NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
return static_cast<std::byte*>(malloc(size));
}
void MockFudDealloc::operator()(std::byte* pointer)
{
+ // NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
free(pointer);
}
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
MockFudAlloc globalDefaultMockAlloc{};
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
MockFudDealloc globalDefaultMockDealloc{};
+// NOLINTNEXTLINE(readability-make-member-function-const)
std::byte* MockFudAllocator::allocate(size_t size)
{
return (*m_allocator)(size);
}
+// NOLINTNEXTLINE(readability-make-member-function-const)
void MockFudAllocator::deallocate(std::byte* pointer)
{
- return (*m_deallocator)(pointer);
+ (*m_deallocator)(pointer);
}
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
MockFudAllocator globalMockFudAlloc{};
std::byte* fudAlloc(size_t size)
@@ -58,7 +65,7 @@ std::byte* fudAlloc(size_t size)
void fudFree(std::byte* ptr)
{
- return globalMockFudAlloc.deallocate(ptr);
+ globalMockFudAlloc.deallocate(ptr);
}
int unlink_cb(const char* fpath, const struct stat* sb_unused, int typeflag, struct FTW* ftwbuf)
@@ -79,7 +86,9 @@ FudStatus removeRecursive(StringView path)
if (!path.utf8Valid()) {
return FudStatus::Utf8Invalid;
}
- if (path.length() < 5) {
+
+ constexpr const size_t minPathLength = 5;
+ if (path.length() < minPathLength) {
return FudStatus::ArgumentInvalid;
}
if (not path.nullTerminated()) {
@@ -96,6 +105,7 @@ FudStatus removeRecursive(StringView path)
}
constexpr int maxOpenFd = 64;
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
auto status = nftw(reinterpret_cast<const char*>(path.data()), unlink_cb, maxOpenFd, FTW_DEPTH | FTW_PHYS);
if (status == 0) {
return FudStatus::Success;