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, fmt::format_string<Args...> msg, Args&& ... args)
|
|
{
|
|
if (value)
|
|
return;
|
|
|
|
Console::Warn("assertion hit - {}#{} ({}). failed expression: {}", file, line, function, expr);
|
|
Console::Warn(msg, 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)
|
|
|