Assertions |
Top Previous Next |
Assert and Verify statements can be added to your code in order to check for conditions that you expect to be true, and which signify a major error if not. The code to perform normal Assert tests is automatically not compiled in when building release versions, to minimize overhead costs for tests that are not expected to be violated in relase code. Verify tests are compiled in even in release code.
JrDebugLogger provides replacement functions for assert and verify which can be used to log violations (or passing tests) before triggering normal assert/verify behavior:
Instead of: assert(condition) verify(condition) use: dbassert(condition) dbverify(condition)
You can enable and disable the logging of passing assertions (disabled by default): JrDebugSetDisplayPassingAsserts(bool val);
JrDebugLog will trigger a messagebox or stderr output (when compiled on *nix) when assert/verify tests fail, and then exit the program immediately.
If debug log compilation is disabled, these calls map to the normal assert/verify macros. BUT if debug logging code is compiled in, assert tests will always be checked, even when building relase mode builds.
There is also a setting in the jrdebug_switch.h file that can be set to have JrDebug compilation redefine the normal ASSERT, VERIFY, and TRACE macros to map to the JrDebug equivelants, which is disabled by default. This might be useful for working with legacy code you dont want to modify: #define JrDebug_TakeoverAssertTrace
|