载入中...
搜索中...
未找到
Result.cpp
浏览该文件的文档.
1#include "common/Result.h"
2#include "common/Assert.h"
3
4namespace eve::detail {
5
6void checkResultInvariant(bool condition, const char* expression, const char* file, unsigned line,
7 const char* message) {
8 if (condition) return;
9 zeroerr::assert_info info{zeroerr::assert_level::ZEROERR_FATAL_l, zeroerr::assert_throw::no_throw, false};
10 zeroerr::AssertionData assertion_data(file, line, expression, info);
11 try {
12 assertion_data.setResult(zeroerr::ExpressionDecomposer() << condition);
13 } catch (const std::exception& e) {
14 assertion_data.setException(e);
15 }
16 ZEROERR_PRINT_ASSERT(assertion_data.passed == false, ZEROERR_FATAL, "{}", message);
17 assertion_data();
18}
19
20void failResultExpectation(const Status& status, std::string_view message, const char* file, unsigned line,
21 bool assertionsEnabled) {
22 if (assertionsEnabled) {
23 const std::string context(message);
24 const std::string description = status.describe();
25 const std::string text = context + ": " + description;
26 checkResultInvariant(false, "false", file, line, text.c_str());
27 }
28 std::terminate();
29}
30
31} // namespace eve::detail
EVEngine assertion entry point, backed by zeroerr.
eve::Value condition
std::string message
wgpu::PopErrorScopeStatus status
const char * description
std::string file
Move-only, checked operation results for the common layer.
unsigned line
std::string text
const VegetationPresetContext & context
Structured status and zero or more diagnostics for an operation.
Definition Status.h:70
void failResultExpectation(const Status &status, std::string_view message, const char *file, unsigned line, bool assertionsEnabled)
Report a failed expect operation with its Status and caller context.
Definition Result.cpp:20
void checkResultInvariant(bool condition, const char *expression, const char *file, unsigned line, const char *message)
Check one Result invariant without instantiating the assertion backend in its caller.
Definition Result.cpp:6
glm::uvec4 info