summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-29 21:02:25 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-29 21:02:25 -0500
commit8ce397e8c0a83e49e390de9deb73d588e4931ecf (patch)
tree31f4f4facf0cb75535aaec130d606c54fe97b2d8 /test
parentf281050ddb3b9d658cff67a254eedc3b79de5c5d (diff)
Reworking of Result.
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/test_file.cpp2
-rw-r--r--test/test_fud.cpp2
-rw-r--r--test/test_result.cpp7
-rw-r--r--test/test_utf8.cpp5
-rw-r--r--test/test_vector.cpp3
6 files changed, 14 insertions, 7 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index aef8052..1ceca71 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -7,7 +7,7 @@ else()
endif()
if(FUD_SAN)
-set(CVG_FLAGS ${CVG_FLAGS} -fsanitize=address -fsanitize=undefined)
+set(CVG_FLAGS ${CVG_FLAGS} -fsanitize=address -fsanitize=undefined -fno-sanitize=vptr)
endif()
set(gtest_URL https://github.com/google/googletest.git)
diff --git a/test/test_file.cpp b/test/test_file.cpp
index 06e6bcc..27844d8 100644
--- a/test/test_file.cpp
+++ b/test/test_file.cpp
@@ -75,7 +75,7 @@ TEST(FudFile, Basic)
};
ASSERT_GE(createFile(testName1), 0);
- fileResult = RegularFile::open(testName1.asView(), FileAccessMode::Read, OpenFlags{}, NullOpt);
+ fileResult = std::move(RegularFile::open(testName1.asView(), FileAccessMode::Read, OpenFlags{}, NullOpt));
ASSERT_TRUE(fileResult.isOkay());
auto file{fileResult.takeOkay()};
ASSERT_EQ(file.close(), FudStatus::Success);
diff --git a/test/test_fud.cpp b/test/test_fud.cpp
index 72d569a..f84ad20 100644
--- a/test/test_fud.cpp
+++ b/test/test_fud.cpp
@@ -51,7 +51,7 @@ TEST(FudTest, GetEnv)
ASSERT_TRUE(fudVarResult.isError());
ASSERT_EQ(fudVarResult.getError(), FudStatus::NullPointer);
- fudVarResult = getEnv(testVarName);
+ fudVarResult = std::move(getEnv(testVarName));
ASSERT_TRUE(fudVarResult.isError());
ASSERT_EQ(fudVarResult.getError(), FudStatus::NotFound);
diff --git a/test/test_result.cpp b/test/test_result.cpp
index 5eadd8c..414941a 100644
--- a/test/test_result.cpp
+++ b/test/test_result.cpp
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-#include "fud_status.hpp"
#include "fud_result.hpp"
+#include "fud_status.hpp"
#include "gtest/gtest.h"
@@ -49,4 +49,9 @@ TEST(ResultTest, ErrResult)
ASSERT_EQ(err2.getError(), FudStatus::ArgumentInvalid);
}
+TEST(ResultTest, ImplicitConversion)
+{
+ // Result<int, int16_t> foo = Result<int, int16_t>::okay(-1);
+}
+
} // namespace fud
diff --git a/test/test_utf8.cpp b/test/test_utf8.cpp
index 5447954..8c3cad2 100644
--- a/test/test_utf8.cpp
+++ b/test/test_utf8.cpp
@@ -137,13 +137,14 @@ TEST(Utf8Test, Utf8MultiByte)
virtual Result<void*, FudStatus> allocate(size_t bytes, size_t alignment) override final
{
+ using RetType = Result<void*, FudStatus>;
static_cast<void>(alignment);
if (bytes > m_memory.size() - m_allocated) {
- return FudStatus::AllocFailure;
+ return RetType::error(FudStatus::AllocFailure);
}
auto* data = m_memory.data() + m_allocated;
m_allocated += bytes;
- return data;
+ return RetType::okay(data);
}
virtual FudStatus deallocate(void* pointer, size_t bytes) override final
diff --git a/test/test_vector.cpp b/test/test_vector.cpp
index b4fd83c..cadeaa6 100644
--- a/test/test_vector.cpp
+++ b/test/test_vector.cpp
@@ -98,7 +98,8 @@ TEST(VectorTest, NonTrivialVector)
ASSERT_GE(nonTrivialVector.capacity(), 11);
ASSERT_EQ(counter, 11);
auto capacity = nonTrivialVector.capacity();
- ASSERT_EQ(nonTrivialVector.reserve(SIZE_MAX / sizeof(NonTrivial)), FudStatus::AllocFailure);
+ constexpr auto FAIL_RESERVE_SIZE = 0x10000000000 / sizeof(NonTrivial);
+ ASSERT_EQ(nonTrivialVector.reserve(FAIL_RESERVE_SIZE), FudStatus::AllocFailure);
ASSERT_EQ(nonTrivialVector.capacity(), capacity);
{