VirtualBox

Changeset 19882 in vbox for trunk/include/iprt


Ignore:
Timestamp:
May 21, 2009 3:00:41 PM (16 years ago)
Author:
vboxsync
Message:

iprt/test.h: Added RTTEST[I]_CHECK_RC and RTTEST[I]_CHECK_RC_OK.

File:
1 edited

Legend:

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

    r19465 r19882  
    408408    } while (0)
    409409
     410/** @def RTTEST_CHECK_RC
     411 * Check whether an expression returns a specific IPRT style status code.
     412 *
     413 * If a different status code is return, call RTTestFailed giving the line
     414 * number, expression, actual and expected status codes.
     415 *
     416 * @param   hTest           The test handle.
     417 * @param   rcExpr          The expression resulting an IPRT status code.
     418 * @param   rcExpect        The expected return code. This may be referenced
     419 *                          more than once by the macro.
     420 */
     421#define RTTEST_CHECK_RC(rcExpr, rcExpect) \
     422    do { \
     423        int rcCheck = (rcExpr); \
     424        if (rcCheck != (rcExpect)) { \
     425            RTTestFailed((hTest), "line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
     426        } \
     427    } while (0)
     428
     429/** @def RTTEST_CHECK_RC_OK
     430 * Check whether a IPRT style status code indicates success.
     431 *
     432 * If the status indicates failure, call RTTestFailed giving the line number,
     433 * expression and status code.
     434 *
     435 * @param   hTest           The test handle.
     436 * @param   rcExpr          The expression resulting an IPRT status code.
     437 */
     438#define RTTEST_CHECK_RC_OK(hTest, rcExpr) \
     439    do { \
     440        int rcCheck = (rcExpr); \
     441        if (RT_FAILURE(rcCheck)) { \
     442            RTTestFailed((hTest), "line %u: %s: %Rrc", __LINE__, #rcExpr, rc); \
     443        } \
     444    } while (0)
     445
    410446
    411447
     
    603639    } while (0)
    604640
     641/** @def RTTESTI_CHECK_RC
     642 * Check whether an expression returns a specific IPRT style status code.
     643 *
     644 * If a different status code is return, call RTTestIFailed giving the line
     645 * number, expression, actual and expected status codes.
     646 *
     647 * @param   rcExpr          The expression resulting an IPRT status code.
     648 * @param   rcExpect        The expected return code. This may be referenced
     649 *                          more than once by the macro.
     650 */
     651#define RTTESTI_CHECK_RC(rcExpr, rcExpect) \
     652    do { \
     653        int rcCheck = (rcExpr); \
     654        if (rcCheck != (rcExpect)) { \
     655            RTTestIFailed("line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
     656        } \
     657    } while (0)
     658
     659/** @def RTTESTI_CHECK_RC_OK
     660 * Check whether a IPRT style status code indicates success.
     661 *
     662 * If the status indicates failure, call RTTestIFailed giving the line number,
     663 * expression and status code.
     664 *
     665 * @param   rcExpr          The expression resulting an IPRT status code.
     666 */
     667#define RTTESTI_CHECK_RC_OK(rcExpr) \
     668    do { \
     669        int rcCheck = (rcExpr); \
     670        if (RT_FAILURE(rcCheck)) { \
     671            RTTestIFailed("line %u: %s: %Rrc", __LINE__, #rcExpr, rcCheck); \
     672        } \
     673    } while (0)
     674
    605675
    606676/** @} */
Note: See TracChangeset for help on using the changeset viewer.

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