the Compartmented Robust Posix C++ Unit Test system

VERIFY_GT(a, b)

Verify that an expression evaluates to greater than 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 equal 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_GT(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_gt_succeeds)
     {
       a val1(3);
       int val2 = 4;
       VERIFY_GT(val1, val2 - 2);
     }
     
     TEST(verify_gt_fails)
     {
       a val1(3);
       int val2 = 4;
       VERIFY_GT(val1, val2 - 1);
       VERIFY_GT(val1 + 1, val2);
     }
     
     int main(int argc, char *argv[])
     {
       return crpcut::run(argc, argv);
     }

reports one failed test with two failed VERIFY_GT() checks:


     FAILED!: verify_gt_fails
     fail---------------------------------------------------------------------------
     samples/verify_gt_fails.cpp:47
     VERIFY_GT(val1, val2 - 1)
       where val1 = 4-byte object <0300 0000>
             val2 - 1 = 3
     -------------------------------------------------------------------------------
     fail---------------------------------------------------------------------------
     samples/verify_gt_fails.cpp:48
     VERIFY_GT(val1 + 1, val2)
       where val1 + 1 = 4
             val2 = 4
     -------------------------------------------------------------------------------
     phase="running"  --------------------------------------------------------------
     samples/verify_gt_fails.cpp:43
     Earlier VERIFY failed
     -------------------------------------------------------------------------------
     ===============================================================================
     2 test cases selected
     
                    Sum   Critical   Non-critical
     PASSED   :       1          1              0
     FAILED   :       1          1              0