|
JASSv2
|
replacement for the C runtime library assert that also works in release. More...
#include <stdlib.h>

Go to the source code of this file.
Macros | |
| #define | JASS_assert(expression) ((expression) ? ((void)0) : JASS::fail(__func__, __FILE__, __LINE__, #expression)) |
| Drop in replacement for assert() that aborts in Release as well as Debug. More... | |
Functions | |
| void | JASS::fail (const char *function, const char *file, size_t line, const char *expression) |
| Helper function to JASS_assert(). Prints a message and calls abort(). More... | |
replacement for the C runtime library assert that also works in release.
| #define JASS_assert | ( | expression | ) | ((expression) ? ((void)0) : JASS::fail(__func__, __FILE__, __LINE__, #expression)) |
Drop in replacement for assert() that aborts in Release as well as Debug.
Each of the JASS classes has a unit test function with the signature static void unittest(void). These unit tests call assert() if something isn't as expected. However, as assert compiles to an empty function on release, there is no obvious way to make the unit tests also work in release. To get around this, call JASS_assert() rather than assert() and the assert will also work in release.
If you want a genuine assert() that goes away in release, then call assert(). If you want an assert() for unittests call JASS_assert().
| expression | [in] The expression to check. |
| void JASS::fail | ( | const char * | function, |
| const char * | file, | ||
| size_t | line, | ||
| const char * | expression | ||
| ) |
Helper function to JASS_assert(). Prints a message and calls abort().
| function | [in] The name of the function in which the JASS assert triggered. |
| file | [in] The name of the file in which the JASS assert triggered. |
| line | [in] The line number of the file in which the JASS assert triggered. |
| expression | [in] The expression that caused assert to trigger. |
1.8.13