assert()
The assert() macro / method is a quick and easy method way to test/debug programs. It is a convenient way to test conditions that should hold true if your code is correct. It permits to debug the program by embedding diagnostics into the code and make debug code disappear from the release version of program.
You can think of putting this as : "I ASSERT (expr) is TRUE" If this is not true then something is wrong and we terminate..
It can be used in code developed using any language. In C the assert() macro is defined as:
#include
void assert(int expr);
The argument, expr, should be an expression which evaluates to true (nonzero) when your program is working as you intended.
When expression evaluates to false (zero), assert calls abort, after first printing a message showing what failed and where, as in the following example.
Assertion failed: expression, file filename, line lineno
Applications:
1. Testing assumptions in code.
2. Checking global initializations.
3. Validating