mirror of
https://github.com/bkaradzic/bx.git
synced 2026-06-08 03:03:48 +00:00
Override BX_ASSERT/BX_ASSERT_LOC in test.h to throw directly.
This commit is contained in:
committed by
Branimir Karadžić
parent
84fd8d86e9
commit
5a43e56c3b
23
tests/test.h
23
tests/test.h
@@ -6,6 +6,29 @@
|
||||
#ifndef BX_TEST_H_HEADER_GUARD
|
||||
#define BX_TEST_H_HEADER_GUARD
|
||||
|
||||
#include <exception>
|
||||
|
||||
// Override bx asserts in test builds: failing asserts throw std::exception so that Catch2's
|
||||
// REQUIRE_ASSERTS (REQUIRE_THROWS) can catch them.
|
||||
#if BX_CONFIG_DEBUG
|
||||
# define BX_ASSERT(_condition, ...) \
|
||||
do { \
|
||||
if (!(_condition) ) \
|
||||
{ \
|
||||
throw ::std::exception(); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
# define BX_ASSERT_LOC(_location, _condition, ...) \
|
||||
do { \
|
||||
(void)(_location); \
|
||||
if (!(_condition) ) \
|
||||
{ \
|
||||
throw ::std::exception(); \
|
||||
} \
|
||||
} while (false)
|
||||
#endif // BX_CONFIG_DEBUG
|
||||
|
||||
#include <bx/bx.h>
|
||||
|
||||
BX_PRAGMA_DIAGNOSTIC_PUSH();
|
||||
|
||||
@@ -247,7 +247,11 @@ TEST_CASE("type-traits isVolatile", "")
|
||||
TEST_CASE("type-traits isSigned", "")
|
||||
{
|
||||
STATIC_REQUIRE(!bx::isSigned<bool >() );
|
||||
#if CHAR_MIN < 0
|
||||
STATIC_REQUIRE( bx::isSigned<char >() );
|
||||
#else
|
||||
STATIC_REQUIRE(!bx::isSigned<char >() );
|
||||
#endif // CHAR_MIN < 0
|
||||
STATIC_REQUIRE( bx::isSigned<signed char >() );
|
||||
STATIC_REQUIRE(!bx::isSigned<unsigned char >() );
|
||||
STATIC_REQUIRE( bx::isSigned<short >() );
|
||||
@@ -283,7 +287,11 @@ TEST_CASE("type-traits isSigned", "")
|
||||
TEST_CASE("type-traits isUnsigned", "")
|
||||
{
|
||||
STATIC_REQUIRE( bx::isUnsigned<bool >() );
|
||||
#if CHAR_MIN < 0
|
||||
STATIC_REQUIRE(!bx::isUnsigned<char >() );
|
||||
#else
|
||||
STATIC_REQUIRE( bx::isUnsigned<char >() );
|
||||
#endif // CHAR_MIN < 0
|
||||
STATIC_REQUIRE(!bx::isUnsigned<signed char >() );
|
||||
STATIC_REQUIRE( bx::isUnsigned<unsigned char >() );
|
||||
STATIC_REQUIRE(!bx::isUnsigned<short >() );
|
||||
|
||||
Reference in New Issue
Block a user