the Compartmented Robust Posix C++ Unit Test system |
|
---|
Assert that an expression evaluates to
false
.
Used in: A test function body, the constructor or destructor of a
fixture, or a function called from
them.
See TEST(name, ...)
.
Requirement: The expression expr
can be
evaluated as a bool.
The assertion succeeds if, and only if,
bool(expr)
evaluates to equal to false
.
On success the test continues without side effects.
On failure the test is terminated with an error report. The report includes the exact expression text, and if the value is output streamable, a text representation of the expression value, otherwise a byte by byte hex dump is used.
See also:
VERIFY_FALSE(expr)
Example: The test program
#include <crpcut.hpp> TEST(assert_false_succeeds) { const char *p = 0; ASSERT_FALSE(p); } TEST(assert_false_fails) { const char *p = "message"; ASSERT_FALSE(p); } int main(int argc, char *argv[]) { return crpcut::run(argc, argv); }
reports one failed test:
FAILED!: assert_false_fails phase="running" -------------------------------------------------------------- samples/assert_false_fails.cpp:39 ASSERT_FALSE(p) is evaluated as: message ------------------------------------------------------------------------------- =============================================================================== 2 test cases selected Sum Critical Non-critical PASSED : 1 1 0 FAILED : 1 1 0