diff --git a/test/testautomation_main.c b/test/testautomation_main.c index 01276ac3f8..99d39478d3 100644 --- a/test/testautomation_main.c +++ b/test/testautomation_main.c @@ -93,18 +93,33 @@ static int main_testSetError(void *arg) { size_t i; - char error[1024]; + char error_input[1024]; + int result; + const char *error; - error[0] = '\0'; - SDL_SetError(""); - SDLTest_AssertCheck(SDL_strcmp(error, SDL_GetError()) == 0, "SDL_SetError(\"\")"); + SDLTest_AssertPass("SDL_SetError(NULL)"); + result = SDL_SetError(NULL); + SDLTest_AssertCheck(result == -1, "SDL_SetError(NULL) -> %d (expected %d)", result, -1); + error = SDL_GetError(); + SDLTest_AssertCheck(SDL_strcmp(error, "") == 0, "SDL_GetError() -> \"%s\" (expected \"%s\")", error, ""); - for (i = 0; i < (sizeof(error) - 1); ++i) { - error[i] = 'a' + (i % 26); + SDLTest_AssertPass("SDL_SetError(\"\")"); + result = SDL_SetError(""); + SDLTest_AssertCheck(result == -1, "SDL_SetError(\"\") -> %d (expected %d)", result, -1); + error = SDL_GetError(); + SDLTest_AssertCheck(SDL_strcmp(error, "") == 0, "SDL_GetError() -> \"%s\" (expected \"%s\")", error, ""); + + error_input[0] = '\0'; + for (i = 0; i < (sizeof(error_input) - 1); ++i) { + error_input[i] = 'a' + (i % 26); } - error[i] = '\0'; - SDL_SetError("%s", error); - SDLTest_AssertCheck(SDL_strcmp(error, SDL_GetError()) == 0, "SDL_SetError(\"abc...1023\")"); + error_input[i] = '\0'; + SDLTest_AssertPass("SDL_SetError(\"abc...\")"); + result = SDL_SetError("%s", error_input); + SDLTest_AssertCheck(result == -1, "SDL_SetError(\"abc...\") -> %d (expected %d)", result, -1); + error = SDL_GetError(); + SDLTest_AssertPass("Verify SDL error is identical to the input error"); + SDLTest_CompareMemory(error, SDL_strlen(error), error_input, SDL_strlen(error_input)); return TEST_COMPLETED; }