mirror of
https://github.com/yawut/SDL.git
synced 2026-09-07 08:36:19 -05:00
Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
This commit is contained in:
@@ -235,9 +235,6 @@ SDL_Error(SDL_errorcode code)
|
||||
case SDL_UNSUPPORTED:
|
||||
SDL_SetError("That operation is not supported");
|
||||
break;
|
||||
case SDL_INVALIDPARAM:
|
||||
SDL_SetError("Parameter is invalid");
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown SDL error");
|
||||
break;
|
||||
|
||||
@@ -895,17 +895,20 @@ SDL_Scancode SDL_GetScancodeFromName(const char *name)
|
||||
int i;
|
||||
|
||||
if (!name || !*name) {
|
||||
SDL_InvalidParamError("name");
|
||||
return SDL_SCANCODE_UNKNOWN;
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) {
|
||||
if (!SDL_scancode_names[i]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) {
|
||||
return (SDL_Scancode)i;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_InvalidParamError("name");
|
||||
return SDL_SCANCODE_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
@@ -614,25 +614,37 @@ SDLTest_RandomDouble()
|
||||
char *
|
||||
SDLTest_RandomAsciiString()
|
||||
{
|
||||
// note: fuzzerInvocationCounter is increment in the RandomAsciiStringWithMaximumLenght
|
||||
return SDLTest_RandomAsciiStringWithMaximumLength(255);
|
||||
}
|
||||
|
||||
char *
|
||||
SDLTest_RandomAsciiStringWithMaximumLength(int maxSize)
|
||||
SDLTest_RandomAsciiStringWithMaximumLength(int maxLength)
|
||||
{
|
||||
int size;
|
||||
char *string;
|
||||
int counter;
|
||||
|
||||
fuzzerInvocationCounter++;
|
||||
|
||||
if(maxSize < 1) {
|
||||
if(maxLength < 1) {
|
||||
SDL_InvalidParamError("maxLength");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size = (SDLTest_RandomUint32() % (maxSize + 1)) + 1;
|
||||
string = (char *)SDL_malloc(size * sizeof(char));
|
||||
size = (SDLTest_RandomUint32() % (maxLength + 1));
|
||||
|
||||
return SDLTest_RandomAsciiStringOfSize(size);
|
||||
}
|
||||
|
||||
char *
|
||||
SDLTest_RandomAsciiStringOfSize(int size)
|
||||
{
|
||||
char *string;
|
||||
int counter;
|
||||
|
||||
|
||||
if(size < 1) {
|
||||
SDL_InvalidParamError("size");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
string = (char *)SDL_malloc((size + 1) * sizeof(char));
|
||||
if (string==NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -643,5 +655,7 @@ SDLTest_RandomAsciiStringWithMaximumLength(int maxSize)
|
||||
|
||||
string[counter] = '\0';
|
||||
|
||||
fuzzerInvocationCounter++;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ Android_SetTextInputRect(_THIS, SDL_Rect *rect)
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
|
||||
if (!rect) {
|
||||
SDL_InvalidParamError();
|
||||
SDL_InvalidParamError("rect");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -669,7 +669,7 @@ Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (!rect) {
|
||||
SDL_InvalidParamError();
|
||||
SDL_InvalidParamError("rect");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
|
||||
if (!rect) {
|
||||
SDL_InvalidParamError();
|
||||
SDL_InvalidParamError("rect");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user