VirtualBox

Changeset 19952 in vbox for trunk/include


Ignore:
Timestamp:
May 23, 2009 11:58:05 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
47654
Message:

RTTest: More macros. Made RTTestFailure check for trailing new line to avoid getting an extra blank line.

File:
1 edited

Legend:

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

    r19944 r19952  
    348348         } \
    349349    } while (0)
     350/** @def RTTEST_CHECK_RET
     351 * Check whether a boolean expression holds true, returns on false.
     352 *
     353 * If the expression is false, call RTTestFailed giving the line number and expression.
     354 *
     355 * @param   hTest       The test handle.
     356 * @param   expr        The expression to evaluate.
     357 * @param   rcRet       What to return on failure.
     358 */
     359#define RTTEST_CHECK_RET(hTest, expr, rcRet) \
     360    do { if (!(expr)) { \
     361            RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
     362            return (rcRet); \
     363         } \
     364    } while (0)
     365/** @def RTTEST_CHECK_RETV
     366 * Check whether a boolean expression holds true, returns void on false.
     367 *
     368 * If the expression is false, call RTTestFailed giving the line number and expression.
     369 *
     370 * @param   hTest       The test handle.
     371 * @param   expr        The expression to evaluate.
     372 */
     373#define RTTEST_CHECK_RETV(hTest, expr) \
     374    do { if (!(expr)) { \
     375            RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
     376            return; \
     377         } \
     378    } while (0)
     379
    350380
    351381/** @def RTTEST_CHECK_MSG
     
    365395         } \
    366396    } while (0)
    367 
    368 /** @def RTTEST_CHECK_RET
    369  * Check whether a boolean expression holds true, returns on false.
    370  *
    371  * If the expression is false, call RTTestFailed giving the line number and expression.
    372  *
    373  * @param   hTest       The test handle.
    374  * @param   expr        The expression to evaluate.
    375  * @param   rcRet       What to return on failure.
    376  */
    377 #define RTTEST_CHECK_RET(hTest, expr, rcRet) \
    378     do { if (!(expr)) { \
    379             RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
    380             return (rcRet); \
    381          } \
    382     } while (0)
    383 
    384397/** @def RTTEST_CHECK_MSG_RET
    385398 * Check whether a boolean expression holds true, returns on false.
     
    400413         } \
    401414    } while (0)
    402 
    403 /** @def RTTEST_CHECK_RETV
    404  * Check whether a boolean expression holds true, returns void on false.
    405  *
    406  * If the expression is false, call RTTestFailed giving the line number and expression.
    407  *
    408  * @param   hTest       The test handle.
    409  * @param   expr        The expression to evaluate.
    410  */
    411 #define RTTEST_CHECK_RETV(hTest, expr) \
    412     do { if (!(expr)) { \
    413             RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
    414             return; \
    415          } \
    416     } while (0)
    417 
    418415/** @def RTTEST_CHECK_MSG_RET
    419416 * Check whether a boolean expression holds true, returns void on false.
     
    434431    } while (0)
    435432
     433
    436434/** @def RTTEST_CHECK_RC
    437435 * Check whether an expression returns a specific IPRT style status code.
     
    445443 *                          more than once by the macro.
    446444 */
    447 #define RTTEST_CHECK_RC(rcExpr, rcExpect) \
     445#define RTTEST_CHECK_RC(hTest, rcExpr, rcExpect) \
    448446    do { \
    449447        int rcCheck = (rcExpr); \
     
    452450        } \
    453451    } while (0)
     452/** @def RTTEST_CHECK_RC_RET
     453 * Check whether an expression returns a specific IPRT style status code.
     454 *
     455 * If a different status code is return, call RTTestFailed giving the line
     456 * number, expression, actual and expected status codes, then return.
     457 *
     458 * @param   hTest           The test handle.
     459 * @param   rcExpr          The expression resulting an IPRT status code.
     460 * @param   rcExpect        The expected return code. This may be referenced
     461 *                          more than once by the macro.
     462 * @param   rcRet           The return code.
     463 */
     464#define RTTEST_CHECK_RC_RET(hTest, rcExpr, rcExpect, rcRet) \
     465    do { \
     466        int rcCheck = (rcExpr); \
     467        if (rcCheck != (rcExpect)) { \
     468            RTTestFailed((hTest), "line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
     469            return (rcRet); \
     470        } \
     471    } while (0)
     472/** @def RTTEST_CHECK_RC_RETV
     473 * Check whether an expression returns a specific IPRT style status code.
     474 *
     475 * If a different status code is return, call RTTestFailed giving the line
     476 * number, expression, actual and expected status codes, then return.
     477 *
     478 * @param   hTest           The test handle.
     479 * @param   rcExpr          The expression resulting an IPRT status code.
     480 * @param   rcExpect        The expected return code. This may be referenced
     481 *                          more than once by the macro.
     482 */
     483#define RTTEST_CHECK_RC_RETV(hTest, rcExpr, rcExpect) \
     484    do { \
     485        int rcCheck = (rcExpr); \
     486        if (rcCheck != (rcExpect)) { \
     487            RTTestFailed((hTest), "line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
     488            return; \
     489        } \
     490    } while (0)
     491
    454492
    455493/** @def RTTEST_CHECK_RC_OK
     
    467505        if (RT_FAILURE(rcCheck)) { \
    468506            RTTestFailed((hTest), "line %u: %s: %Rrc", __LINE__, #rcExpr, rc); \
     507        } \
     508    } while (0)
     509/** @def RTTEST_CHECK_RC_OK_RET
     510 * Check whether a IPRT style status code indicates success.
     511 *
     512 * If the status indicates failure, call RTTestFailed giving the line number,
     513 * expression and status code, then return with the specified value.
     514 *
     515 * @param   hTest           The test handle.
     516 * @param   rcExpr          The expression resulting an IPRT status code.
     517 * @param   rcRet           The return code.
     518 */
     519#define RTTEST_CHECK_RC_OK_RET(hTest, rcExpr, rcRet) \
     520    do { \
     521        int rcCheck = (rcExpr); \
     522        if (RT_FAILURE(rcCheck)) { \
     523            RTTestFailed((hTest), "line %u: %s: %Rrc", __LINE__, #rcExpr, rc); \
     524            return (rcRet); \
     525        } \
     526    } while (0)
     527/** @def RTTEST_CHECK_RC_OK_RETV
     528 * Check whether a IPRT style status code indicates success.
     529 *
     530 * If the status indicates failure, call RTTestFailed giving the line number,
     531 * expression and status code, then return.
     532 *
     533 * @param   hTest           The test handle.
     534 * @param   rcExpr          The expression resulting an IPRT status code.
     535 */
     536#define RTTEST_CHECK_RC_OK_RETV(hTest, rcExpr) \
     537    do { \
     538        int rcCheck = (rcExpr); \
     539        if (RT_FAILURE(rcCheck)) { \
     540            RTTestFailed((hTest), "line %u: %s: %Rrc", __LINE__, #rcExpr, rc); \
     541            return; \
    469542        } \
    470543    } while (0)
     
    619692         } \
    620693    } while (0)
     694/** @def RTTESTI_CHECK_RET
     695 * Check whether a boolean expression holds true, returns on false.
     696 *
     697 * If the expression is false, call RTTestIFailed giving the line number and
     698 * expression.
     699 *
     700 * @param   expr        The expression to evaluate.
     701 * @param   rcRet       What to return on failure.
     702 */
     703#define RTTESTI_CHECK_RET(expr, rcRet) \
     704    do { if (!(expr)) { \
     705            RTTestIFailed("line %u: %s", __LINE__, #expr); \
     706            return (rcRet); \
     707         } \
     708    } while (0)
     709/** @def RTTESTI_CHECK_RETV
     710 * Check whether a boolean expression holds true, returns void on false.
     711 *
     712 * If the expression is false, call RTTestIFailed giving the line number and
     713 * expression.
     714 *
     715 * @param   expr        The expression to evaluate.
     716 */
     717#define RTTESTI_CHECK_RETV(expr) \
     718    do { if (!(expr)) { \
     719            RTTestIFailed("line %u: %s", __LINE__, #expr); \
     720            return; \
     721         } \
     722    } while (0)
     723
    621724
    622725/** @def RTTESTI_CHECK_MSG
     
    636739         } \
    637740    } while (0)
    638 
    639 /** @def RTTESTI_CHECK_RET
    640  * Check whether a boolean expression holds true, returns on false.
    641  *
    642  * If the expression is false, call RTTestIFailed giving the line number and
    643  * expression.
    644  *
    645  * @param   expr        The expression to evaluate.
    646  * @param   rcRet       What to return on failure.
    647  */
    648 #define RTTESTI_CHECK_RET(expr, rcRet) \
    649     do { if (!(expr)) { \
    650             RTTestIFailed("line %u: %s", __LINE__, #expr); \
    651             return (rcRet); \
    652          } \
    653     } while (0)
    654 
    655741/** @def RTTESTI_CHECK_MSG_RET
    656742 * Check whether a boolean expression holds true, returns on false.
     
    671757         } \
    672758    } while (0)
    673 
    674 /** @def RTTESTI_CHECK_RETV
    675  * Check whether a boolean expression holds true, returns void on false.
    676  *
    677  * If the expression is false, call RTTestIFailed giving the line number and
    678  * expression.
    679  *
    680  * @param   expr        The expression to evaluate.
    681  */
    682 #define RTTESTI_CHECK_RETV(expr) \
    683     do { if (!(expr)) { \
    684             RTTestIFailed("line %u: %s", __LINE__, #expr); \
    685             return; \
    686          } \
    687     } while (0)
    688 
    689759/** @def RTTESTI_CHECK_MSG_RET
    690760 * Check whether a boolean expression holds true, returns void on false.
     
    705775    } while (0)
    706776
     777
    707778/** @def RTTESTI_CHECK_RC
    708779 * Check whether an expression returns a specific IPRT style status code.
     
    722793        } \
    723794    } while (0)
     795/** @def RTTESTI_CHECK_RC_RET
     796 * Check whether an expression returns a specific IPRT style status code.
     797 *
     798 * If a different status code is return, call RTTestIFailed giving the line
     799 * number, expression, actual and expected status codes, then return.
     800 *
     801 * @param   rcExpr          The expression resulting an IPRT status code.
     802 * @param   rcExpect        The expected return code. This may be referenced
     803 *                          more than once by the macro.
     804 * @param   rcRet           The return code.
     805 */
     806#define RTTESTI_CHECK_RC_RET(rcExpr, rcExpect, rcRet) \
     807    do { \
     808        int rcCheck = (rcExpr); \
     809        if (rcCheck != (rcExpect)) { \
     810            RTTestIFailed("line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
     811            return (rcRet); \
     812        } \
     813    } while (0)
     814/** @def RTTESTI_CHECK_RC_RETV
     815 * Check whether an expression returns a specific IPRT style status code.
     816 *
     817 * If a different status code is return, call RTTestIFailed giving the line
     818 * number, expression, actual and expected status codes, then return.
     819 *
     820 * @param   rcExpr          The expression resulting an IPRT status code.
     821 * @param   rcExpect        The expected return code. This may be referenced
     822 *                          more than once by the macro.
     823 */
     824#define RTTESTI_CHECK_RC_RETV(rcExpr, rcExpect) \
     825    do { \
     826        int rcCheck = (rcExpr); \
     827        if (rcCheck != (rcExpect)) { \
     828            RTTestIFailed("line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
     829            return; \
     830        } \
     831    } while (0)
     832
    724833
    725834/** @def RTTESTI_CHECK_RC_OK
     
    738847        } \
    739848    } while (0)
    740 
     849/** @def RTTESTI_CHECK_RC_OK_RET
     850 * Check whether a IPRT style status code indicates success.
     851 *
     852 * If the status indicates failure, call RTTestIFailed giving the line number,
     853 * expression and status code, then return with the specified value.
     854 *
     855 * @param   rcExpr          The expression resulting an IPRT status code.
     856 * @param   rcRet           The return code.
     857 */
     858#define RTTESTI_CHECK_RC_OK_RET(rcExpr, rcRet) \
     859    do { \
     860        int rcCheck = (rcExpr); \
     861        if (RT_FAILURE(rcCheck)) { \
     862            RTTestIFailed("line %u: %s: %Rrc", __LINE__, #rcExpr, rcCheck); \
     863            return (rcRet); \
     864        } \
     865    } while (0)
     866/** @def RTTESTI_CHECK_RC_OK_RETV
     867 * Check whether a IPRT style status code indicates success.
     868 *
     869 * If the status indicates failure, call RTTestIFailed giving the line number,
     870 * expression and status code, then return.
     871 *
     872 * @param   rcExpr          The expression resulting an IPRT status code.
     873 */
     874#define RTTESTI_CHECK_RC_OK_RETV(rcExpr) \
     875    do { \
     876        int rcCheck = (rcExpr); \
     877        if (RT_FAILURE(rcCheck)) { \
     878            RTTestIFailed("line %u: %s: %Rrc", __LINE__, #rcExpr, rcCheck); \
     879            return; \
     880        } \
     881    } while (0)
    741882
    742883/** @} */
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