Asserts - Steelhead-Games/CharmQuarkEngine-wiki GitHub Wiki

To use the asserts, include the corresponding header

#include <Debug/Assert.h>

The assertion system works only with the non-optimized builds (debug, dev).

CQE_BREAK

Use CQE_BREAK() to create a breakpoint.

CQE_ASSERT

The Windows build creates a window with the failed condition message. Ignore button just ignores the assert, Retry button hits the breakpoint, Abort button terminates the application. Otherwise, it just logs the message, hits the breakpoint and terminates the application altogether.

CQE_ASSERT(condition) checks the condition and creates a message with the line of code where it failed.

CQE_ASSERT_FORMAT(condition, msg, ...) does the same, but also allows you to create a custom message and pass custom parameters to the message.

CQE_ENSURE

This method just logs the failed condition and hits the breakpoint. It can also be used with the if-conditions because CQE_ENSURE returns the condition back. In the optimized builds, it is just implemented as !!(condition).

CQE_ENSURE(condition) is a default implementation.

CQE_ENSURE_FORMAT(condition, msg, ...) allows you to pass a custom message and parameters to it.

Example of using

if (CQE_ENSURE(IsOdd(number)))
{
...
}

will turn into

if (IsOdd(number))
{
...
}

in the optimized build.

ASSERT_NOT_IMPLEMENTED

Just use it to mark a place in the code that is not yet implemented. E.g. the ConvertToDXGIFormat function has this assert to mark that not all the formats are yet supported there, just because there are too many formats that we probably don't need right now to integrate in the engine.