diff --git a/src/Common/Assert.h b/src/Common/Assert.h new file mode 100644 index 00000000..f0ff7c5e --- /dev/null +++ b/src/Common/Assert.h @@ -0,0 +1,38 @@ +#ifndef ASSERT_H +#define ASSERT_H + +#include "TString.h" +#include +#include + +#define __FILE_SHORT__ strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__ + +#define ASSERT_CHECK_BEGIN(Expression) \ + { \ + if (!(Expression)) \ + { + +#define ASSERT_CHECK_END \ + } \ + } + +#define WRITE_FAILURE_TO_LOG(Expression) \ + Log::Write(TString(__FILE_SHORT__) + "(" + TString::FromInt32(__LINE__, 0, 10) + "): ASSERT FAILED: " + #Expression); + +#define BREAK_ONLY_ASSERT(Expression) \ + ASSERT_CHECK_BEGIN(Expression) \ + __debugbreak(); \ + ASSERT_CHECK_END + +#define LOG_ONLY_ASSERT(Expression) \ + ASSERT_CHECK_BEGIN(Expression) \ + WRITE_FAILURE_TO_LOG(Expression) \ + ASSERT_CHECK_END + +#define ASSERT(Expression) \ + ASSERT_CHECK_BEGIN(Expression) \ + WRITE_FAILURE_TO_LOG(Expression) \ + __debugbreak(); \ + ASSERT_CHECK_END + +#endif // ASSERT_H