⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmtestcommon.h

📁 pxa270平台 windows mobile 5.2 wm9713 触摸屏+音频驱动
💻 H
📖 第 1 页 / 共 2 页
字号:
        if ( !(_comparison) )                                                   \
        {                                                                       \
            WMTEST_TRACE_LINE( _message );                                      \
            WMDebugAssert( NULL, __FILE__, __LINE__, #_comparison );            \
        } } while ( 0 )

#if WM_TESTING_ASSERT
#define WMTEST_BOOLEAN_MSG( _comparison, _message ) WMTEST_BOOLEAN_MSG_ASSERT( _comparison, _message )
#else
#   define WMTEST_BOOLEAN_MSG( _comparison, _message ) do {                     \
        if ( !(_comparison) )                                                   \
        {                                                                       \
            WMTEST_TRACE_LINE( _message );                                      \
            goto _testError;                                                    \
        } } while ( 0 )
#endif	/* WM_TESTING_ASSERT */

/*
 * This handles a comparison and fails with a default message.
 */
#define WMTEST_ASSERT( _cond )                                                  \
            WMTEST_BOOLEAN_MSG_ASSERT( _cond,                                   \
                                       ( "[WMTEST] assert failed: '%s'",                 \
                                          #_cond )                              \
                                     )
#define WMTEST_BOOLEAN( _comparison )                                           \
            WMTEST_BOOLEAN_MSG( _comparison,                                    \
                                ( "comparison '%s' failed",                     \
                                   #_comparison )                               \
                               )
#define WMTEST_TRUE( _comparison )     WMTEST_BOOLEAN( _comparison )
#define WMTEST_FALSE( _comparison )    WMTEST_BOOLEAN( !(_comparison) )

#define WMTEST_NULL( _pointer )        WMTEST_BOOLEAN( NULL == (_pointer) )
#define WMTEST_NOTNULL( _pointer )     WMTEST_BOOLEAN( NULL != (_pointer) )

/*
 * Check a status.
 * _text is explanatory text about the test which generated the status.
 */
#define WMTEST_STATUS( _status, _expectedStatus, _text )                        \
        WMTEST_BOOLEAN_MSG( ( (_expectedStatus) == (_status) ),                 \
                                ( "%s: status %s != %s",                        \
                                   _text,                                       \
                                   WMStatusText( _status ),                     \
                                   WMStatusText( _expectedStatus ),             \
                                )                                               \
                            )

/*
 * Make a function call and check the return value.
 */
#define WMTEST_CALL_CHECK( _func, _type, _comparison ) do {                     \
        _type _retval = (_type) _func;                                          \
        WMTEST_BOOLEAN_MSG( _retval _comparison,                                \
                            ( #_func "' failed: retval 0x%X "                   \
                              "(check was '" #_comparison "')",                 \
                              _retval )                                         \
                           );                                                   \
    } while ( 0 )
#define WMTEST_CALL_CHECK_RETURN( _func, _expectedValue ) do {                  \
        int _retval = (int) _func;                                              \
        WMTEST_BOOLEAN_MSG( ( (int)(_expectedValue) == (_retval) ),             \
                            ( #_func "' failed: retval 0x%X, expected 0x%X",    \
                              _retval,                                          \
                              _expectedValue                                    \
                            )                                                   \
                          );                                                    \
    } while ( 0 )
#define WMTEST_CALL_STATUS( _func, _expectedStatus ) do {                       \
        WMSTATUS _status = _func;                                               \
        WMTEST_BOOLEAN_MSG( ( (_expectedStatus) == (_status) ),                 \
                            ( #_func "' failed: retval %s, expected %s",        \
                              WMStatusText( _status ),                          \
                              WMStatusText( _expectedStatus )                   \
                            )                                                   \
                          );                                                    \
    } while ( 0 )

#define WMTEST_CALL( _func )   WMTEST_CALL_STATUS( _func, WMS_SUCCESS )

/*
 * Run a test.  Note this will always ASSERT, even if WM_TEST_ASSERT is _not_ defined.
 */
#if WM_TESTING_ASSERT
#   define WMTEST_RUN( _test )    WMTEST_CALL_CHECK_RETURN( _test, TRUE )
#else
#   define WMTEST_RUN( _test ) do {                                             \
        WM_BOOL _retval = _test;                                                \
        if ( !_retval )                                                         \
        {                                                                       \
            const char *msg = #_test " failed";                                 \
            WMTEST_TRACE_LINE(( msg ));                                         \
            WMDebugAssert( NULL, __FILE__, __LINE__, msg );                     \
            goto _testError;                                                    \
        }                                                                       \
    } while ( 0 )
#endif	/* WM_TESTING_ASSERT */

/*
 * Comparisons.
 */
#define WMTEST_EQUALS( _value1, _value2 )                                       \
      WMTEST_BOOLEAN_MSG( ( (_value1) == (_value2) ),                           \
                          ( "WMTest: '==' comparison failed: 0x%X != 0x%X",     \
                            _value1,                                            \
                            _value2 ) )
#define WMTEST_EQUALS_RANGE( _value1, _value2, _error )                         \
      WMTEST_BOOLEAN_MSG( ( (int)(_value1) >= (int)(_value2) - (_error) &&      \
                            (int)(_value1) <= (int)(_value2) + (_error) ),      \
                          ( "WMTest: '~=' comparison failed: 0x%X != 0x%X (+/- %d)",\
                            _value1,                                            \
                            _value2,                                            \
                            _error ) )
#define WMTEST_NOTEQUALS( _value1, _value2 )                                    \
      WMTEST_BOOLEAN_MSG( ( (_value1) != (_value2) ),                           \
                          ( "WMTest: '!=' comparison failed: 0x%X == 0x%X",     \
                            _value1,                                            \
                            _value2 ) )
#define WMTEST_GREATER( _value1, _value2 )                                      \
      WMTEST_BOOLEAN_MSG( ( (_value1) > (_value2) ),                            \
                          ( "WMTest: '>' comparison failed: 0x%X <= 0x%X",      \
                            _value1,                                            \
                            _value2 ) )
#define WMTEST_GREATER_EQUAL( _value1, _value2 )                                \
      WMTEST_BOOLEAN_MSG( ( (_value1) >= (_value2) ),                           \
                          ( "WMTest: '>=' comparison failed: 0x%X < 0x%X",      \
                            _value1,                                            \
                            _value2 ) )
#define WMTEST_LESS( _value1, _value2 )                                         \
      WMTEST_BOOLEAN_MSG( ( (_value1) < (_value2) ),                            \
                          ( "WMTest: '<' comparison failed: 0x%X >= 0x%X",      \
                            _value1,                                            \
                            _value2 ) )
#define WMTEST_LESS_EQUAL( _value1, _value2 )                                   \
      WMTEST_BOOLEAN_MSG( ( (_value1) <= (_value2) ),                           \
                          ( "WMTest: '<=' comparison failed: 0x%X > 0x%X",      \
                            _value1,                                            \
                            _value2 ) )

/*
 * String comparisons.
 */
#define WMTEST_EQUALS_STR( _string1, _string2 )                                 \
      WMTEST_BOOLEAN_MSG( ( 0 == strcmp( _string1, _string2 ) ),                \
                          ( "WMTest: '==' comparison failed: '%s' != '%s'",     \
                            _string1,                                           \
                            _string2 ) )
#define WMTEST_NOTEQUALS_STR( _string1, _string2 )                              \
      WMTEST_BOOLEAN_MSG( ( 0 != strcmp( _string1, _string2 ) ),                \
                          ( "WMTest: '!=' comparison failed: '%s' == '%s'",     \
                            _string1,                                           \
                            _string2 ) )
#define WMTEST_GREATER_STR( _string1, _string2 )                                \
      WMTEST_BOOLEAN_MSG( ( strcmp( _string1, _string2 ) > 0 ),                 \
                          ( "WMTest: '>' comparison failed: '%s' <= '%s'",      \
                            _string1,                                           \
                            _string2 ) )
#define WMTEST_GREATER_EQUAL_STR( _string1, _string2 )                          \
      WMTEST_BOOLEAN_MSG( ( strcmp( _string1, _string2 ) >= 0 ),                \
                          ( "WMTest: '>=' comparison failed: '%s' < '%s'",      \
                            _string1,                                           \
                            _string2 ) )
#define WMTEST_LESS_STR( _string1, _string2 )                                   \
      WMTEST_BOOLEAN_MSG( ( strcmp( _string1, _string2 ) < 0 ),                 \
                          ( "WMTest: '<' comparison failed: '%s' >= '%s'",      \
                            _string1,                                           \
                            _string2 ) )
#define WMTEST_LESS_EQUAL_STR( _string1, _string2 )                             \
      WMTEST_BOOLEAN_MSG( ( strcmp( _string1, _string2 ) <= 0 ),                \
                          ( "WMTest: '<=' comparison failed: '%s' > '%s'",      \
                            _string1,                                           \
                            _string2 ) )

/*
 * Bitfield comparisons
 */
#define WMTEST_BITS_SET( _value, _bits )            \
                WMTEST_EQUALS( _bits, (_value) & (_bits) )
#define WMTEST_BITS_CLEAR( _value, _bits )            \
                WMTEST_EQUALS( 0, (_value) & (_bits) )

/*
 * Check a register value.
 */
#define WMTEST_REGFIELD( _hDevice, _reg, _value, _mask ) do {                   \
            WM_REGVAL _regVal;                                                  \
            WMTEST_CALL( WMRead( _hDevice, _reg, &_regVal ) );                  \
            WMTEST_EQUALS( (_regVal & (_mask) ), _value );                      \
        } while (0)

#define WMTEST_REGVAL( _hDevice, _reg, _value )                                 \
            WMTEST_REGFIELD( _hDevice, _reg, _value, 0xFFFF )

#else   /* WM_TESTING */

/*
 * We need to be able to call this macro even if we're not testing.
 */
#define WMTEST_RUN( _test )     TRUE

#endif  /* WM_TESTING */

#if WM_TESTING

/*
 * Private data
 */

/*
 * Function prototypes
 */
#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}   /* extern "C" */
#endif

#endif  /* WM_TESTING */

#endif /* __WMTESTCOMMON_H__ */
/*------------------------------ END OF FILE ---------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -