Version 3 (modified by sam, 7 years ago) (diff)

Add TOC and stuff

Table of Contents

  1. ASSERT()

<lol/base/assert.h>

View this file in the source browser: trunk/src/lol/base/assert.h

ASSERT()

An assertion macro that checks for a condition, displays an error message (optionally user-provided) and aborts the program.

#define ASSERT(...) /* ... */

It can be used in the following three different ways:

ASSERT(K == 0);
ASSERT(K == 0, "K is non-zero!\n");
ASSERT(K == 0, "K is %d at iteration %d\n", K, i);

If the test fails, one of the following messages is printed depending on what macro was used:

Error: assertion failure: K == 0
Error: assertion failure: K is non-zero!
Error: assertion failure: K is 42 at iteration 12