Files
Renderive/Kernel/tests/renderive/error/Error_Policy_Test.cpp
T
2026-08-16 18:33:24 +08:00

36 lines
868 B
C++

#include <renderive/error/Error_Policy.hpp>
#include <gtest/gtest.h>
#include <stdexcept>
namespace renderive::error {
namespace {
TEST(ErrorPolicy, ExceptionModePreservesExceptionType) {
set_mode(Mode::exception);
EXPECT_THROW(unexpected<std::invalid_argument>("invalid value"),
std::invalid_argument);
}
TEST(ErrorPolicy, FastFailModeTerminatesAtThePolicyBoundary) {
EXPECT_DEATH(
{
set_mode(Mode::fast_fail);
unexpected<std::logic_error>("broken invariant");
},
"broken invariant");
}
TEST(ErrorPolicy, CaptureUsesTheSameMode) {
set_mode(Mode::exception);
const auto exception = capture<std::logic_error>("async failure");
ASSERT_TRUE(exception);
EXPECT_THROW(std::rethrow_exception(exception), std::logic_error);
}
} // namespace
} // namespace renderive::error