src/test/SDL_test_assert.c
changeset 8830 2d74f0c59cc7
parent 8820 0e935d5b193a
child 9619 b94b6d0bff0f
equal deleted inserted replaced
8829:6ed74a27066a 8830:2d74f0c59cc7
    44 /*
    44 /*
    45  *  Assert that logs and break execution flow on failures (i.e. for harness errors).
    45  *  Assert that logs and break execution flow on failures (i.e. for harness errors).
    46  */
    46  */
    47 void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...)
    47 void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...)
    48 {
    48 {
    49         va_list list;
    49     va_list list;
    50     char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
    50     char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
    51 
    51 
    52     /* Print assert description into a buffer */
    52     /* Print assert description into a buffer */
    53     SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
    53     SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
    54     va_start(list, assertDescription);
    54     va_start(list, assertDescription);
    55     SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
    55     SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
    56     va_end(list);
    56     va_end(list);
    57 
    57 
    58     /* Log, then assert and break on failure */
    58     /* Log, then assert and break on failure */
    59     SDL_assert((SDLTest_AssertCheck(assertCondition, logMessage)));
    59     SDL_assert((SDLTest_AssertCheck(assertCondition, "%s", logMessage)));
    60 }
    60 }
    61 
    61 
    62 /*
    62 /*
    63  * Assert that logs but does not break execution flow on failures (i.e. for test cases).
    63  * Assert that logs but does not break execution flow on failures (i.e. for test cases).
    64  */
    64  */