the Compartmented Robust Posix C++ Unit Test system |
|
---|
Verify 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 check 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 marked as failed, but continues execution with an error report. The report includes the exact parameter text for each parameter and, when they are output streamable, a text representation of each expression value, or a byte by byte hex dump otherwise.
See also:
ASSERT_FALSE(expr)
Example: The test program
#include <crpcut.hpp> TEST(verify_false_succeeds) { const char *p = 0; VERIFY_FALSE(p); } TEST(verify_false_fails) { const char *p = "message"; VERIFY_FALSE(p); VERIFY_FALSE(p[1]); } int main(int argc, char *argv[]) { return crpcut::run(argc, argv); }
reports one failed test with two failed
VERIFY_FALSE
() checks:
FAILED!: verify_false_fails fail--------------------------------------------------------------------------- samples/verify_false_fails.cpp:39 VERIFY_FALSE(p) is evaluated as: message ------------------------------------------------------------------------------- fail--------------------------------------------------------------------------- samples/verify_false_fails.cpp:40 VERIFY_FALSE(p[1]) is evaluated as: e ------------------------------------------------------------------------------- phase="running" -------------------------------------------------------------- samples/verify_false_fails.cpp:36 Earlier VERIFY failed ------------------------------------------------------------------------------- =============================================================================== 2 test cases selected Sum Critical Non-critical PASSED : 1 1 0 FAILED : 1 1 0