Assertions 🔗
Verify the expected behavior of a system.
Categories 🔗
- Value Assertions
Compare integers, floating-point numbers, pointers, and booleans.
- String Assertions
Compare strings.
- Memory Assertions
Compare memory blobs.
Macros 🔗
-
#define ABORT(...)
Aborts the test case with an error message.
-
#define FAIL(...)
Fails the test case with an error message.
Discussion 🔗
Assertions are statements that check whether a particular condition holds true during the execution of tests. They are used to verify that the software behaves as expected by comparing the expected results to the actual results. If an assertion fails, it indicates that there is a discrepancy between the expected and actual behavior, typically signifying a defect or issue in the code.
In Audition assertions are defined as type-generic macros. They are organized by their prefix: those prefixed with ASSERT and those prefixed with EXPECT. Those prefixed with ASSERT will abort the test case if their condition fails and those prefixed with EXPECT with not.
Assertion macros can accept an optional failure message to associate with the assertion. If no message is provided, then Audition will generate one.