summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-16 22:25:08 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-16 22:25:08 -0500
commit53c4dcf374c66f1e9190f5a62a52d02fe11a69e6 (patch)
treeee40277c36fdba58fb06aca87b8ffa67ab5f8558 /test
parentf3ac764684c64fbdd2094853a80b23e570cd5d9c (diff)
First crack at allocators.
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt6
-rw-r--r--test/test_common.cpp2
-rw-r--r--test/test_directory.cpp13
-rw-r--r--test/test_string.cpp8
4 files changed, 17 insertions, 12 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index a79bc40..a20e991 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,11 +1,15 @@
include(FetchContent)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
- set(CVG_FLAGS -Wno-long-long -fsanitize=address -fsanitize=undefined -fprofile-arcs -ftest-coverage)
+ set(CVG_FLAGS -Wno-long-long -fprofile-arcs -ftest-coverage)
else()
endif()
+if(FUD_SAN)
+set(CVG_FLAGS ${CVG_FLAGS} -fsanitize=address -fsanitize=undefined)
+endif()
+
set(gtest_URL https://github.com/google/googletest.git)
set(gtest_TAG v1.14.0)
diff --git a/test/test_common.cpp b/test/test_common.cpp
index fc37566..5a26e09 100644
--- a/test/test_common.cpp
+++ b/test/test_common.cpp
@@ -16,7 +16,7 @@
*/
#include "test_common.hpp"
-#include "fud_memory.hpp"
+#include "fud_allocator.hpp"
#include <cstdlib>
namespace fud {
diff --git a/test/test_directory.cpp b/test/test_directory.cpp
index 6597195..c2af281 100644
--- a/test/test_directory.cpp
+++ b/test/test_directory.cpp
@@ -109,26 +109,27 @@ TEST(FudDirectory, Basic)
ASSERT_EQ(writeResult.status, expected.status);
}
- Directory directory{testDirName};
- ASSERT_EQ(directory.status(), FudStatus::Success);
+ auto directoryResult{Directory::make(testDirName)};
+ ASSERT_TRUE(directoryResult.isOkay());
+ Directory directory{directoryResult.takeOkay()};
ASSERT_EQ(directory.errorCode(), 0);
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},
- DirectoryEntry{files[0], 0, files[0].size(), 1, 0, DirectoryEntryType::RegularFile},
- DirectoryEntry{files[1], 0, files[1].size(), 1, 0, DirectoryEntryType::RegularFile},
+ DirectoryEntry{String::from(files[0]).takeOkay(), 0, files[0].size(), 1, 0, DirectoryEntryType::RegularFile},
+ DirectoryEntry{String::from(files[1]).takeOkay(), 0, files[1].size(), 1, 0, DirectoryEntryType::RegularFile},
};
ASSERT_TRUE(expectedFiles[0].name.compare(expectedFiles[0].name));
for (auto idx = 0; idx < expectedFiles.size(); ++idx) {
auto dirEntryResult = directory.getNextEntry();
EXPECT_TRUE(dirEntryResult.isOkay());
- const auto dirEntryOpt = dirEntryResult.getOkay();
+ auto dirEntryOpt = dirEntryResult.takeOkay();
if (dirEntryOpt == std::nullopt) {
break;
}
- const auto dirEntry = *dirEntryOpt;
+ auto dirEntry{std::move(dirEntryOpt.value())};
const auto* expected = std::find_if(
expectedFiles.begin(),
expectedFiles.end(),
diff --git a/test/test_string.cpp b/test/test_string.cpp
index 6d963c4..61052ef 100644
--- a/test/test_string.cpp
+++ b/test/test_string.cpp
@@ -38,10 +38,10 @@ TEST(FudString, BasicStringOps)
ASSERT_FALSE(Ascii::valid(invalid[0]));
const Array<utf8, 2> invalid2{0xFF, 0x00};
- auto stringResult = String::makeFromCString(invalid2.data());
+ auto stringResult = String::makeFromCString(reinterpret_cast<const char*>(invalid2.data()));
ASSERT_TRUE(stringResult.isOkay());
- String fudString{stringResult.getOkay()};
+ String fudString{stringResult.takeOkay()};
ASSERT_EQ(fudString.length(), 1);
ASSERT_EQ(fudString.data()[0], invalid[0]);
ASSERT_FALSE(Ascii::valid(fudString.data()[0]));
@@ -49,7 +49,7 @@ TEST(FudString, BasicStringOps)
stringResult = String::makeFromCString("TEST");
ASSERT_TRUE(stringResult.isOkay());
- fudString = stringResult.getOkay();
+ fudString = stringResult.takeOkay();
ASSERT_TRUE(fudString.utf8Valid());
@@ -65,7 +65,7 @@ TEST(FudString, HeapAlloc)
constexpr const char filenameLiteral[] = "Amazing Saga Volume 01/000.jpg";
auto filenameResult{String::makeFromCString(filenameLiteral)};
ASSERT_TRUE(filenameResult.isOkay());
- auto filename{filenameResult.getOkay()};
+ auto filename{filenameResult.takeOkay()};
ASSERT_EQ(filename.length(), sizeof(filenameLiteral) - 1);
}