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:
parent
c1e8384624
commit
b4a190fb6f
10 changed files with 272 additions and 54 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue