|
@@ -93,18 +93,33 @@ static int
|
|
|
main_testSetError(void *arg)
|
|
|
{
|
|
|
size_t i;
|
|
|
- char error[1024];
|
|
|
-
|
|
|
- error[0] = '\0';
|
|
|
- SDL_SetError("");
|
|
|
- SDLTest_AssertCheck(SDL_strcmp(error, SDL_GetError()) == 0, "SDL_SetError(\"\")");
|
|
|
-
|
|
|
- for (i = 0; i < (sizeof(error) - 1); ++i) {
|
|
|
- error[i] = 'a' + (i % 26);
|
|
|
+ char error_input[1024];
|
|
|
+ int result;
|
|
|
+ const char *error;
|
|
|
+
|
|
|
+ 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, "");
|
|
|
+
|
|
|
+ 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;
|
|
|
}
|