#ifndef __SDK_COMMON_DEBUG_INC_HV_ASSSERT_H_
#define __SDK_COMMON_DEBUG_INC_HV_ASSSERT_H_

#include "Common/hv_comm_DataType.h"
#include "hv_comm_Log.h"
#include "hv_comm_Define.h"
/*如果使用HV_LOG_ASSERT 或者HV_LOG_ERROR打印过多，生成的bin占用近200K，所以使用INFO打印在release版本不打印任何ASSERT断言*/
#define HV_ASSERT_VALID_PTR(ptr)             \
do                                           \
{                                            \
    if (NULL == ptr)                         \
    {                                        \
        HV_LOG_INFO(DEFAULT,"%s == NULL assert failure!!!", #ptr);\
        return HV_FAILURE;                      \
    }                                        \
}while(0)                                    
 
#define HV_ASSERT_VALID_PTR_VOID(ptr)        \
do                                           \
{                                            \
    if (NULL == ptr)                         \
    {                                        \
        HV_LOG_INFO(DEFAULT,"%s == NULL assert failure!!!", #ptr);\
        return;                              \
    }                                        \
}while(0)                                    

#define HV_ASSERT_VALID_PTR_VOID_NO_LOG(ptr) \
do                                           \
{                                            \
    if (NULL == ptr)                         \
    {                                        \
        return;                              \
    }                                        \
}while(0)                                    


#define HV_ASSERT_VALID_PTR_RET(ptr, ret)    \
do                                           \
{                                            \
    if (NULL == ptr)                         \
    {                                        \
        HV_LOG_INFO(DEFAULT,"%s == NULL assert failure!!! return %s!!!", #ptr, #ret);\
        return ret;                          \
    }                                        \
}while(0)                                    

#define HV_ASSERT_VALID_PTR_RET_NO_LOG(ptr, ret)\
do                                           \
{                                            \
    if (NULL == ptr)                         \
    {                                        \
        return ret;                          \
    }                                        \
}while(0)   

#define HV_ASSERT_TRUE(expression)           \
do                                           \
{                                            \
    if (HV_TRUE != (expression))                \
    {                                        \
        HV_LOG_INFO(DEFAULT,"(%s) != HV_TRUE assert failure!!!", #expression);\
        return HV_FAILURE;                      \
    }                                        \
}while(0)

#define HV_ASSERT_PEEK_TRUE(expression)      \
do                                           \
{                                            \
    if (HV_TRUE != (expression))                \
    {                                        \
        HV_LOG_INFO(DEFAULT,"peek HV_TRUE but (%s) != HV_TRUE assert failure!!!", #expression);\
    }                                        \
}while(0)

#define HV_ASSERT_TRUE_VOID(expression)      \
do                                           \
{                                            \
    if (HV_TRUE != (expression))                \
    {                                        \
        HV_LOG_INFO(DEFAULT,"(%s) != HV_TRUE assert failure!!!", #expression);\
        return;                              \
    }                                        \
}while(0)

#define HV_ASSERT_TRUE_RET(expression, ret) \
do                                          \
{                                           \
    if (HV_TRUE != (expression))               \
    {                                       \
        HV_LOG_INFO(DEFAULT,"(%s) != HV_TRUE assert failure!!! return %s!!!", #expression, #ret);\
        return ret;                         \
    }                                       \
}while(0)

#define HV_ASSERT_TRUE_RET_NO_LOG(expression, ret)\
do                                          \
{                                           \
    if (HV_TRUE != (expression))               \
    {                                       \
        return ret;                         \
    }                                       \
}while(0)

#define HV_ASSERT_SUCCESS(expression)       \
do                                          \
{                                           \
    if (HV_SUCCESS != (expression))            \
    {                                       \
        HV_LOG_INFO(DEFAULT,"(%s) != HV_SUCCESS assert failure!!!", #expression);\
        return HV_FAILURE;                     \
    }                                       \
}while(0)

#define HV_ASSERT_PEEK_SUCCESS(expression)  \
do                                          \
{                                           \
    if (HV_SUCCESS != (expression))            \
    {                                       \
        HV_LOG_INFO(DEFAULT,"peek HV_SUCCESS but (%s) != HV_SUCCESS assert failure!!!", #expression);\
    }                                       \
}while(0)

#define HV_ASSERT_SUCCESS_RET(expression, ret) \
do                                             \
{                                              \
    if (HV_SUCCESS != (expression))               \
    {                                          \
        HV_LOG_INFO(DEFAULT,"(%s) != HV_SUCCESS assert failure!!! return %s!!!", #expression, #ret);\
        return ret;                            \
    }                                          \
}while(0)


#define HV_ASSERT_SUCCESS_VOID(expression) \
do                                         \
{                                          \
    if (HV_SUCCESS != (expression))           \
    {                                      \
        HV_LOG_INFO(DEFAULT,"(%s) != HV_SUCCESS assert failure!!!", #expression);\
        return;                            \
    }                                      \
}while(0)

#define HV_ASSERT_PEEK_SUCCESS_VOID(expression) \
do                                         \
{                                          \
    if (HV_SUCCESS != (expression))           \
    {                                      \
        HV_LOG_INFO(DEFAULT,"peek HV_SUCCESS but (%s) != HV_SUCCESS assert failure!!!", #expression);\
    }                                      \
}while(0)

#endif