It evaluates to ((void)0) when not compiling in debug mode. That's great because the program won't lose any performance because of assert when not in debug mode.
In debug mode the conditions tested with assert are checked every time. That means all "units" are automatically tested when the program is compiled and used in debug mode.
I want to add more assertions to test as many expected conditions as possible, so that when I run the program compiled in debug mode, it will automatically find more errors and so that I can be 100% sure that if it works, the assertions hold.
People talk about the idea of unit tests. I think something similar can be achieved by using assert. assert is defined as:
in assert.h.
It evaluates to ((void)0) when not compiling in debug mode. That's great because the program won't lose any performance because of assert when not in debug mode.
In debug mode the conditions tested with assert are checked every time. That means all "units" are automatically tested when the program is compiled and used in debug mode.
I want to add more assertions to test as many expected conditions as possible, so that when I run the program compiled in debug mode, it will automatically find more errors and so that I can be 100% sure that if it works, the assertions hold.