allow tests in release mode
All checks were successful
Linux arm64 / Build (push) Successful in 6m40s
All checks were successful
Linux arm64 / Build (push) Successful in 6m40s
This commit is contained in:
43
test/test_assert.h
Normal file
43
test/test_assert.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file Test.h
|
||||
* \brief File containing unit testing utilities
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* \def TEST_SUCCESSFUL
|
||||
* \brief Used in tests to indicate that a test was successful
|
||||
*/
|
||||
#define TEST_SUCCESSFUL 0
|
||||
|
||||
/**
|
||||
* \def TEST_FAILED
|
||||
* \brief Used in tests to indicate that a test failed
|
||||
*/
|
||||
#define TEST_FAILED 1
|
||||
|
||||
#ifndef __FUNCTION_NAME__
|
||||
#ifdef _WIN32
|
||||
#define __FUNCTION_NAME__ __FUNCTION__
|
||||
#else
|
||||
#define __FUNCTION_NAME__ __PRETTY_FUNCTION__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def test_assert
|
||||
* \param ... The expression to evaluate
|
||||
* \brief Evaluates the expression and exits the program if not valid.
|
||||
* \note It works like a basic assert() but also in release mode
|
||||
*/
|
||||
#define test_assert(...) \
|
||||
if (!static_cast<bool>(__VA_ARGS__)) { \
|
||||
std::cout << __FILE__ << ":" << __LINE__ << ": " << __FUNCTION_NAME__ << ": Assertion failed !\n"; \
|
||||
std::cout << " " << __LINE__ << " |\t" << #__VA_ARGS__ << std::endl; \
|
||||
std::exit(TEST_FAILED); \
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user