the Compartmented Robust Posix C++ Unit Test system |
|
---|
Verifies that an expression evaluates to greater than or equal to another.
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 (a >= b)
can
be evaluated as a bool.
The check succeeds if, and only if, the expression
bool(a >= b)
evaluates to
true
.
On success the test function 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_GE(a, b)
Example: The test program
#include <crpcut.hpp> struct a { a(int val) : n(val) {} int n; operator int() const { return n; } }; TEST(verify_ge_succeeds) { a val1(3); int val2 = 3; VERIFY_GE(val1, val2); } TEST(assert_ge_fails) { a val1(3); int val2 = 4; VERIFY_GE(val1, val2); VERIFY_GE(val1, val2+1); } int main(int argc, char *argv[]) { return crpcut::run(argc, argv); }
reports one failed test with two failed
VERIFY_GE
() checks:
FAILED!: assert_ge_fails fail--------------------------------------------------------------------------- samples/verify_ge_fails.cpp:47 VERIFY_GE(val1, val2) where val1 = 4-byte object <0300 0000> val2 = 4 ------------------------------------------------------------------------------- fail--------------------------------------------------------------------------- samples/verify_ge_fails.cpp:48 VERIFY_GE(val1, val2+1) where val1 = 4-byte object <0300 0000> val2+1 = 5 ------------------------------------------------------------------------------- phase="running" -------------------------------------------------------------- samples/verify_ge_fails.cpp:43 Earlier VERIFY failed ------------------------------------------------------------------------------- =============================================================================== 2 test cases selected Sum Critical Non-critical PASSED : 1 1 0 FAILED : 1 1 0