36 lines
1.0 KiB
C++
36 lines
1.0 KiB
C++
/***
|
|
Copyright (c) 2020 Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: assert.hpp
|
|
Date: 2020-6-9
|
|
Originator: Reece
|
|
Purpose:
|
|
***/
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
namespace Aurora::UnitTesting
|
|
{
|
|
template<typename... Args>
|
|
static void Assert(bool value, const char * function, const char * file, int line, const char * expr, const std::string &fmt, Args... args)
|
|
{
|
|
if (value)
|
|
return;
|
|
|
|
Console::Warn("assertion hit - {}#{} ({}). failed expression: {}", file, line, function, expr);
|
|
Console::Warn(fmt, args...);
|
|
|
|
EndTest(TestResponse::kUnitError);
|
|
}
|
|
}
|
|
|
|
#define STRINGIGY_Z(in) #in
|
|
#define STRINGIGY_X(in) STRINGIGY_Z(in)
|
|
|
|
#define UnitAssert(tru, str, ...) \
|
|
do { \
|
|
Aurora::UnitTesting::Assert(tru, __FUNCTION__, __FILE__, __LINE__, STRINGIGY_X(tru), str, ## __VA_ARGS__); \
|
|
} while (0)
|
|
|