VirtualBox

Changeset 32795 in vbox


Ignore:
Timestamp:
Sep 28, 2010 2:45:08 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
66244
Message:

iprt/test.h: some more test macros

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/test.h

    r28800 r32795  
    512512 * Check whether a boolean expression holds true, returns on false.
    513513 *
    514  * If the expression is false, call RTTestFailed giving the line number and expression.
     514 * If the expression is false, call RTTestFailed giving the line number and
     515 * expression, then return @a rcRet.
    515516 *
    516517 * @param   hTest       The test handle.
     
    527528 * Check whether a boolean expression holds true, returns void on false.
    528529 *
    529  * If the expression is false, call RTTestFailed giving the line number and expression.
     530 * If the expression is false, call RTTestFailed giving the line number and
     531 * expression, then return void.
    530532 *
    531533 * @param   hTest       The test handle.
     
    538540         } \
    539541    } while (0)
     542/** @def RTTEST_CHECK_BREAK
     543 * Check whether a boolean expression holds true.
     544 *
     545 * If the expression is false, call RTTestFailed giving the line number and
     546 * expression, then break.
     547 *
     548 * @param   hTest       The test handle.
     549 * @param   expr        The expression to evaluate.
     550 */
     551#define RTTEST_CHECK_BREAK(hTest, expr) \
     552    if (!(expr)) { \
     553        RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
     554        break; \
     555    } else do {} while (0)
    540556
    541557
     
    652668        } \
    653669    } while (0)
     670/** @def RTTEST_CHECK_RC_BREAK
     671 * Check whether an expression returns a specific IPRT style status code.
     672 *
     673 * If a different status code is return, call RTTestFailed giving the line
     674 * number, expression, actual and expected status codes, then break.
     675 *
     676 * @param   hTest           The test handle.
     677 * @param   rcExpr          The expression resulting in an IPRT status code.
     678 * @param   rcExpect        The expected return code. This may be referenced
     679 *                          more than once by the macro.
     680 */
     681#define RTTEST_CHECK_RC_BREAK(hTest, rcExpr, rcExpect) \
     682    if (1) { \
     683        int rcCheck = (rcExpr); \
     684        if (rcCheck != (rcExpect)) { \
     685            RTTestFailed((hTest), "line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
     686            break; \
     687        } \
     688    } else do {} while (0)
    654689
    655690
     
    935970 *
    936971 * If the expression is false, call RTTestIFailed giving the line number and
    937  * expression.
     972 * expression, then return @a rcRet.
    938973 *
    939974 * @param   expr        The expression to evaluate.
     
    950985 *
    951986 * If the expression is false, call RTTestIFailed giving the line number and
    952  * expression.
     987 * expression, then return void.
    953988 *
    954989 * @param   expr        The expression to evaluate.
     
    960995         } \
    961996    } while (0)
     997/** @def RTTESTI_CHECK_RETV
     998 * Check whether a boolean expression holds true, returns void on false.
     999 *
     1000 * If the expression is false, call RTTestIFailed giving the line number and
     1001 * expression, then break.
     1002 *
     1003 * @param   expr        The expression to evaluate.
     1004 */
     1005#define RTTESTI_CHECK_BREAK(expr) \
     1006    if (!(expr)) { \
     1007        RTTestIFailed("line %u: %s", __LINE__, #expr); \
     1008        break; \
     1009    } do {} while (0)
    9621010
    9631011
     
    10711119        } \
    10721120    } while (0)
     1121/** @def RTTESTI_CHECK_RC_BREAK
     1122 * Check whether an expression returns a specific IPRT style status code.
     1123 *
     1124 * If a different status code is return, call RTTestIFailed giving the line
     1125 * number, expression, actual and expected status codes, then break.
     1126 *
     1127 * @param   rcExpr          The expression resulting in an IPRT status code.
     1128 * @param   rcExpect        The expected return code. This may be referenced
     1129 *                          more than once by the macro.
     1130 */
     1131#define RTTESTI_CHECK_RC_BREAK(rcExpr, rcExpect) \
     1132    if (1) { \
     1133        int rcCheck = (rcExpr); \
     1134        if (rcCheck != (rcExpect)) { \
     1135            RTTestIFailed("line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
     1136            break; \
     1137        } \
     1138    } else do {} while (0)
    10731139
    10741140
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette