Fixed SDL_SetError() by making NULL fmt a no-op, update test automation
This commit is contained in:
parent
73bd015b16
commit
9db859c159
2 changed files with 44 additions and 2 deletions
|
@ -55,6 +55,9 @@ SDL_SetError(const char *fmt, ...)
|
||||||
va_list ap;
|
va_list ap;
|
||||||
SDL_error *error;
|
SDL_error *error;
|
||||||
|
|
||||||
|
/* Ignore call if invalid format pointer was passed */
|
||||||
|
if (fmt == NULL) return;
|
||||||
|
|
||||||
/* Copy in the key, mark error as valid */
|
/* Copy in the key, mark error as valid */
|
||||||
error = SDL_GetErrBuf();
|
error = SDL_GetErrBuf();
|
||||||
error->error = 1;
|
error->error = 1;
|
||||||
|
|
|
@ -352,13 +352,52 @@ int platform_testSetErrorEmptyInput(void *arg)
|
||||||
int platform_testSetErrorInvalidInput(void *arg)
|
int platform_testSetErrorInvalidInput(void *arg)
|
||||||
{
|
{
|
||||||
const char *testError = NULL;
|
const char *testError = NULL;
|
||||||
|
const char *probeError = "Testing";
|
||||||
char *lastError;
|
char *lastError;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
// Reset
|
||||||
|
SDL_ClearError();
|
||||||
|
|
||||||
|
// Check for no-op
|
||||||
SDL_SetError(testError);
|
SDL_SetError(testError);
|
||||||
AssertPass("SDL_SetError()");
|
AssertPass("SDL_SetError()");
|
||||||
lastError = (char *)SDL_GetError();
|
lastError = (char *)SDL_GetError();
|
||||||
AssertTrue(lastError == NULL,
|
AssertTrue(lastError != NULL,
|
||||||
"SDL_GetError() == NULL");
|
"SDL_GetError() != NULL");
|
||||||
|
if (lastError != NULL)
|
||||||
|
{
|
||||||
|
len = strlen(lastError);
|
||||||
|
AssertTrue(len == 0,
|
||||||
|
"SDL_GetError(): expected message len 0, was len: %i",
|
||||||
|
0,
|
||||||
|
len);
|
||||||
|
AssertTrue(strcmp(lastError, "") == 0,
|
||||||
|
"SDL_GetError(): expected message '', was message: '%s'",
|
||||||
|
lastError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set
|
||||||
|
SDL_SetError(probeError);
|
||||||
|
|
||||||
|
// Check for no-op
|
||||||
|
SDL_SetError(testError);
|
||||||
|
AssertPass("SDL_SetError()");
|
||||||
|
lastError = (char *)SDL_GetError();
|
||||||
|
AssertTrue(lastError != NULL,
|
||||||
|
"SDL_GetError() != NULL");
|
||||||
|
if (lastError != NULL)
|
||||||
|
{
|
||||||
|
len = strlen(lastError);
|
||||||
|
AssertTrue(len == strlen(probeError),
|
||||||
|
"SDL_GetError(): expected message len %i, was len: %i",
|
||||||
|
strlen(probeError),
|
||||||
|
len);
|
||||||
|
AssertTrue(strcmp(lastError, probeError) == 0,
|
||||||
|
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||||
|
probeError,
|
||||||
|
lastError);
|
||||||
|
}
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
SDL_ClearError();
|
SDL_ClearError();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue