Skip to content

Change Assert Logs, to show more information. #4

@babaliaris

Description

@babaliaris

Change the following macro, to accept the function name func as well:

#define VAMP_LOG_FORMAT_TYPE1(COLOR, LOG_TYPE, CALLER, FILE, LINE, FMT, ...)\
vampPrintf("[%s%s%s]\t{%s%s%s} %s:%ld %s" FMT "%s\n", \
COLOR, LOG_TYPE, VAMP_COLOR_DEFAULT, \
VAMP_COLOR_GREEN, CALLER, VAMP_COLOR_DEFAULT, \
FILE, LINE, COLOR, ##__VA_ARGS__, VAMP_COLOR_DEFAULT)

Change the following:

#define VAMP_ASSERT(cond)\
if ( !(cond) )\
{\
VAMP_LOG_FORMAT_ASSERT(#cond);\
vampExit(-1);\
}

to something like:

#define VAMP_ASSERT(cond, fmt, ...)\
    if ( !(cond) )\
    {\
        VAMP_LOG_FORMAT_ASSERT(fmt, ##__VA_ARGS__);\
        vampExit(-1);\
    }

Add more macro assertions here:

#define VAMPTEST_ASSERT(cond)\
if ( !(cond) )\
{\
vampPrintf("[%sFAILED%s] {%s%s%s} %s:%ld:%s%s%s() %sREASON%s: %s%s%s\n",\
VAMP_COLOR_RED, VAMP_COLOR_DEFAULT, VAMP_COLOR_GREEN, pVamptestThis->m_full_name,\
VAMP_COLOR_DEFAULT, __FILE__, __LINE__, VAMP_COLOR_MAGENTA, __func__, VAMP_COLOR_DEFAULT,\
VAMP_COLOR_GREEN, VAMP_COLOR_DEFAULT, VAMP_COLOR_CYAN, #cond, VAMP_COLOR_DEFAULT\
);\
\
pVamptestThis->m_failed = 1;\
return;\
}

like this:

#define VAMPTEST_ASSERT_EQUAL(provided, expected);
#define VAMPTEST_ASSERT_NOT_EQUAL(provided, expected);
#define VAMPTEST_ASSERT_LESS(provided, expected);
#define VAMPTEST_ASSERT_GREATER(provided, expected);
#define VAMPTEST_ASSERT_LESS_EQUAL(provided, expected);
#define VAMPTEST_ASSERT_GREATER_EQUAL(provided, expected);

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions