sol2/examples/include/assert.hpp
ThePhD 486086ffe0
fix up CMake files once more, and hopefully prepare for a new test coverage paradigm
notably, test normal + single + generated + Lua 5.3.5 only once,
then only run the runtime_test and compile_test for normal for all other permutations to help increase text matrix throughput
2018-12-27 02:17:25 -05:00

42 lines
1.1 KiB
C++

#ifndef EXAMPLES_ASSERT_HPP
#define EXAMPLES_ASSERT_HPP
#ifdef SOL2_CI
struct pre_main {
pre_main() {
#ifdef _MSC_VER
_set_abort_behavior(0, _WRITE_ABORT_MSG);
#endif
}
} pm;
#endif // Prevent lockup when doing Continuous Integration
#ifndef NDEBUG
#include <exception>
#include <iostream>
#include <cstdlib>
# define m_assert(condition, message) \
do { \
if (! (condition)) { \
std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
<< " line " << __LINE__ << ": " << message << std::endl; \
std::terminate(); \
} \
} while (false)
# define c_assert(condition) \
do { \
if (! (condition)) { \
std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
<< " line " << __LINE__ << std::endl; \
std::terminate(); \
} \
} while (false)
#else
# define m_assert(condition, message) do { if (false) { (void)(condition); (void)sizeof(message); } } while (false)
# define c_assert(condition) do { if (false) { (void)(condition); } } while (false)
#endif
#endif // EXAMPLES_ASSERT_HPP