mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-05-30 11:11:37 +00:00
Implemented assert macros
This commit is contained in:
parent
61afbabfa4
commit
c5ff634cd1
38
src/Common/Assert.h
Normal file
38
src/Common/Assert.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#ifndef ASSERT_H
|
||||||
|
#define ASSERT_H
|
||||||
|
|
||||||
|
#include "TString.h"
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#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
|
Loading…
x
Reference in New Issue
Block a user