Fix fuzzer random boundary functions; add tests for fuzzer
This commit is contained in:
parent
e34e953eba
commit
ea312e87fa
4 changed files with 1096 additions and 343 deletions
|
@ -158,13 +158,13 @@ double SDLTest_RandomDouble();
|
|||
* RandomUint8BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20
|
||||
* RandomUint8BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21
|
||||
* RandomUint8BoundaryValue(0, 99, SDL_FALSE) returns 100
|
||||
* RandomUint8BoundaryValue(0, 255, SDL_FALSE) returns -1 (== error value)
|
||||
* RandomUint8BoundaryValue(0, 255, SDL_FALSE) returns 0 (error set)
|
||||
*
|
||||
* \param boundary1 Lower boundary limit
|
||||
* \param boundary2 Upper boundary limit
|
||||
* \param validDomain Should the generated boundary be valid or not?
|
||||
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||
*
|
||||
* \returns Boundary value in given range or error value (-1)
|
||||
* \returns Random boundary value for the given range and domain or 0 with error set
|
||||
*/
|
||||
Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain);
|
||||
|
||||
|
@ -179,13 +179,13 @@ Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_boo
|
|||
* RandomUint16BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20
|
||||
* RandomUint16BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21
|
||||
* RandomUint16BoundaryValue(0, 99, SDL_FALSE) returns 100
|
||||
* RandomUint16BoundaryValue(0, 0xFFFF, SDL_FALSE) returns -1 (== error value)
|
||||
* RandomUint16BoundaryValue(0, 0xFFFF, SDL_FALSE) returns 0 (error set)
|
||||
*
|
||||
* \param boundary1 Lower boundary limit
|
||||
* \param boundary2 Upper boundary limit
|
||||
* \param validDomain Should the generated boundary be valid or not?
|
||||
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||
*
|
||||
* \returns Boundary value in given range or error value (-1)
|
||||
* \returns Random boundary value for the given range and domain or 0 with error set
|
||||
*/
|
||||
Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain);
|
||||
|
||||
|
@ -200,13 +200,13 @@ Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL
|
|||
* RandomUint32BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20
|
||||
* RandomUint32BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21
|
||||
* RandomUint32BoundaryValue(0, 99, SDL_FALSE) returns 100
|
||||
* RandomUint32BoundaryValue(0, 0xFFFFFFFF, SDL_FALSE) returns -1 (== error value)
|
||||
* RandomUint32BoundaryValue(0, 0xFFFFFFFF, SDL_FALSE) returns 0 (with error set)
|
||||
*
|
||||
* \param boundary1 Lower boundary limit
|
||||
* \param boundary2 Upper boundary limit
|
||||
* \param validDomain Should the generated boundary be valid or not?
|
||||
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||
*
|
||||
* \returns Boundary value in given range or error value (-1)
|
||||
* \returns Random boundary value for the given range and domain or 0 with error set
|
||||
*/
|
||||
Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain);
|
||||
|
||||
|
@ -221,13 +221,13 @@ Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL
|
|||
* RandomUint64BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20
|
||||
* RandomUint64BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21
|
||||
* RandomUint64BoundaryValue(0, 99, SDL_FALSE) returns 100
|
||||
* RandomUint64BoundaryValue(0, 0xFFFFFFFFFFFFFFFF, SDL_FALSE) returns -1 (== error value)
|
||||
* RandomUint64BoundaryValue(0, 0xFFFFFFFFFFFFFFFF, SDL_FALSE) returns 0 (with error set)
|
||||
*
|
||||
* \param boundary1 Lower boundary limit
|
||||
* \param boundary2 Upper boundary limit
|
||||
* \param validDomain Should the generated boundary be valid or not?
|
||||
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||
*
|
||||
* \returns Boundary value in given range or error value (-1)
|
||||
* \returns Random boundary value for the given range and domain or 0 with error set
|
||||
*/
|
||||
Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain);
|
||||
|
||||
|
@ -241,14 +241,14 @@ Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL
|
|||
* Usage examples:
|
||||
* RandomSint8BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20
|
||||
* RandomSint8BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9
|
||||
* RandomSint8BoundaryValue(-128, 99, SDL_FALSE) returns 100
|
||||
* RandomSint8BoundaryValue(-128, 127, SDL_FALSE) returns SINT8_MIN (== error value)
|
||||
* RandomSint8BoundaryValue(SINT8_MIN, 99, SDL_FALSE) returns 100
|
||||
* RandomSint8BoundaryValue(SINT8_MIN, SINT8_MAX, SDL_FALSE) returns SINT8_MIN (== error value) with error set
|
||||
*
|
||||
* \param boundary1 Lower boundary limit
|
||||
* \param boundary2 Upper boundary limit
|
||||
* \param validDomain Should the generated boundary be valid or not?
|
||||
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||
*
|
||||
* \returns Boundary value in given range or error value (-1)
|
||||
* \returns Random boundary value for the given range and domain or SINT8_MIN with error set
|
||||
*/
|
||||
Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain);
|
||||
|
||||
|
@ -263,14 +263,14 @@ Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_boo
|
|||
* Usage examples:
|
||||
* RandomSint16BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20
|
||||
* RandomSint16BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9
|
||||
* RandomSint16BoundaryValue(SINT8_MIN, 99, SDL_FALSE) returns 100
|
||||
* RandomSint16BoundaryValue(SINT8_MIN, SINT8_MAX, SDL_FALSE) returns SINT16_MIN (== error value)
|
||||
* RandomSint16BoundaryValue(SINT16_MIN, 99, SDL_FALSE) returns 100
|
||||
* RandomSint16BoundaryValue(SINT16_MIN, SINT16_MAX, SDL_FALSE) returns SINT16_MIN (== error value) with error set
|
||||
*
|
||||
* \param boundary1 Lower boundary limit
|
||||
* \param boundary2 Upper boundary limit
|
||||
* \param validDomain Should the generated boundary be valid or not?
|
||||
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||
*
|
||||
* \returns Boundary value in given range or error value (-1)
|
||||
* \returns Random boundary value for the given range and domain or SINT16_MIN with error set
|
||||
*/
|
||||
Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain);
|
||||
|
||||
|
@ -289,9 +289,9 @@ Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL
|
|||
*
|
||||
* \param boundary1 Lower boundary limit
|
||||
* \param boundary2 Upper boundary limit
|
||||
* \param validDomain Should the generated boundary be valid or not?
|
||||
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||
*
|
||||
* \returns Boundary value in given range or error value (-1)
|
||||
* \returns Random boundary value for the given range and domain or SINT32_MIN with error set
|
||||
*/
|
||||
Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain);
|
||||
|
||||
|
@ -306,13 +306,13 @@ Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL
|
|||
* RandomSint64BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20
|
||||
* RandomSint64BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9
|
||||
* RandomSint64BoundaryValue(SINT64_MIN, 99, SDL_FALSE) returns 100
|
||||
* RandomSint64BoundaryValue(SINT64_MIN, SINT32_MAX, SDL_FALSE) returns SINT64_MIN (== error value)
|
||||
* RandomSint64BoundaryValue(SINT64_MIN, SINT64_MAX, SDL_FALSE) returns SINT64_MIN (== error value) and error set
|
||||
*
|
||||
* \param boundary1 Lower boundary limit
|
||||
* \param boundary2 Upper boundary limit
|
||||
* \param validDomain Should the generated boundary be valid or not?
|
||||
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||
*
|
||||
* \returns Boundary value in given range or error value (-1)
|
||||
* \returns Random boundary value for the given range and domain or SINT64_MIN with error set
|
||||
*/
|
||||
Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "SDL_test.h"
|
||||
|
||||
/**
|
||||
*Counter for fuzzer invocations
|
||||
* Counter for fuzzer invocations
|
||||
*/
|
||||
static int fuzzerInvocationCounter = 0;
|
||||
|
||||
|
@ -167,414 +167,268 @@ SDLTest_RandomIntegerInRange(Sint32 pMin, Sint32 pMax)
|
|||
return (Sint32)min;
|
||||
}
|
||||
|
||||
number = SDLTest_RandomUint32(); // invocation count increment in there
|
||||
number = SDLTest_RandomUint32();
|
||||
/* invocation count increment in preceeding call */
|
||||
|
||||
return (Sint32)((number % ((max + 1) - min)) + min);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Generates boundary values between the given boundaries.
|
||||
* Generates a unsigned boundary value between the given boundaries.
|
||||
* Boundary values are inclusive. See the examples below.
|
||||
* If boundary2 < boundary1, the values are swapped.
|
||||
* If boundary1 == boundary2, value of boundary1 will be returned
|
||||
*
|
||||
* Generating boundary values for Uint8:
|
||||
* BoundaryValues(sizeof(Uint8), 10, 20, True) -> [10,11,19,20]
|
||||
* BoundaryValues(sizeof(Uint8), 10, 20, False) -> [9,21]
|
||||
* BoundaryValues(sizeof(Uint8), 0, 15, True) -> [0, 1, 14, 15]
|
||||
* BoundaryValues(sizeof(Uint8), 0, 15, False) -> [16]
|
||||
* BoundaryValues(sizeof(Uint8), 0, 255, False) -> NULL
|
||||
* BoundaryValues(UINT8_MAX, 10, 20, True) -> [10,11,19,20]
|
||||
* BoundaryValues(UINT8_MAX, 10, 20, False) -> [9,21]
|
||||
* BoundaryValues(UINT8_MAX, 0, 15, True) -> [0, 1, 14, 15]
|
||||
* BoundaryValues(UINT8_MAX, 0, 15, False) -> [16]
|
||||
* BoundaryValues(UINT8_MAX, 0, 0xFF, False) -> [0], error set
|
||||
*
|
||||
* Generator works the same for other types of unsigned integers.
|
||||
*
|
||||
* Note: outBuffer will be allocated and needs to be freed later.
|
||||
* If outbuffer != NULL, it'll be freed.
|
||||
*
|
||||
* \param maxValue The biggest value that is acceptable for this data type.
|
||||
* For instance, for Uint8 -> 255, Uint16 -> 65536 etc.
|
||||
* \param pBoundary1 defines lower boundary
|
||||
* \param pBoundary2 defines upper boundary
|
||||
* \param boundary1 defines lower boundary
|
||||
* \param boundary2 defines upper boundary
|
||||
* \param validDomain Generate only for valid domain (for the data type)
|
||||
*
|
||||
* \param outBuffer The generated boundary values are put here
|
||||
*
|
||||
* \returns Returns the number of elements in outBuffer or -1 in case of error
|
||||
* \returns Returns a random boundary value for the domain or 0 in case of error
|
||||
*/
|
||||
Uint32
|
||||
SDLTest_GenerateUnsignedBoundaryValues(const Uint64 maxValue,
|
||||
Uint64 pBoundary1, Uint64 pBoundary2, SDL_bool validDomain,
|
||||
Uint64 *outBuffer)
|
||||
Uint64
|
||||
SDLTest_GenerateUnsignedBoundaryValues(const Uint64 maxValue, Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain)
|
||||
{
|
||||
Uint64 boundary1 = pBoundary1, boundary2 = pBoundary2;
|
||||
Uint64 temp;
|
||||
Uint64 b1, b2;
|
||||
Uint64 delta;
|
||||
Uint64 tempBuf[4];
|
||||
int index;
|
||||
|
||||
if(outBuffer != NULL) {
|
||||
SDL_free(outBuffer);
|
||||
}
|
||||
|
||||
if(boundary1 > boundary2) {
|
||||
temp = boundary1;
|
||||
boundary1 = boundary2;
|
||||
boundary2 = temp;
|
||||
}
|
||||
Uint8 index;
|
||||
|
||||
/* Maybe swap */
|
||||
if (boundary1 > boundary2) {
|
||||
b1 = boundary2;
|
||||
b2 = boundary1;
|
||||
} else {
|
||||
b1 = boundary1;
|
||||
b2 = boundary2;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
if(boundary1 == boundary2) {
|
||||
tempBuf[index++] = boundary1;
|
||||
}
|
||||
else if(validDomain) {
|
||||
tempBuf[index++] = boundary1;
|
||||
|
||||
if(boundary1 < UINT64_MAX)
|
||||
tempBuf[index++] = boundary1 + 1;
|
||||
|
||||
tempBuf[index++] = boundary2 - 1;
|
||||
tempBuf[index++] = boundary2;
|
||||
}
|
||||
else {
|
||||
if(boundary1 > 0) {
|
||||
tempBuf[index++] = boundary1 - 1;
|
||||
if (validDomain == SDL_TRUE) {
|
||||
if (b1 == b2) {
|
||||
return b1;
|
||||
}
|
||||
|
||||
/* Generate up to 4 values within bounds */
|
||||
delta = b2 - b1;
|
||||
if (delta < 4) {
|
||||
do {
|
||||
tempBuf[index] = b1 + index;
|
||||
index++;
|
||||
} while (index < delta);
|
||||
} else {
|
||||
tempBuf[index] = b1;
|
||||
index++;
|
||||
tempBuf[index] = b1 + 1;
|
||||
index++;
|
||||
tempBuf[index] = b2 - 1;
|
||||
index++;
|
||||
tempBuf[index] = b2;
|
||||
index++;
|
||||
}
|
||||
} else {
|
||||
/* Generate up to 2 values outside of bounds */
|
||||
if (b1 > 0) {
|
||||
tempBuf[index] = b1 - 1;
|
||||
index++;
|
||||
}
|
||||
|
||||
if(boundary2 < maxValue && boundary2 < UINT64_MAX) {
|
||||
tempBuf[index++] = boundary2 + 1;
|
||||
if (b2 < maxValue) {
|
||||
tempBuf[index] = b2 + 1;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
if(index == 0) {
|
||||
// There are no valid boundaries
|
||||
if (index == 0) {
|
||||
/* There are no valid boundaries */
|
||||
SDL_Error(SDL_UNSUPPORTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create the return buffer
|
||||
outBuffer = (Uint64 *)SDL_malloc(index * sizeof(Uint64));
|
||||
if(outBuffer == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_memcpy(outBuffer, tempBuf, index * sizeof(Uint64));
|
||||
|
||||
return index;
|
||||
return tempBuf[SDLTest_RandomUint8() % index];
|
||||
}
|
||||
|
||||
|
||||
Uint8
|
||||
SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain)
|
||||
{
|
||||
Uint64 *buffer = NULL;
|
||||
Uint32 size;
|
||||
Uint32 index;
|
||||
Uint8 retVal;
|
||||
|
||||
// max value for Uint8
|
||||
const Uint64 maxValue = UINT8_MAX;
|
||||
|
||||
size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
|
||||
/* max value for Uint8 */
|
||||
const Uint64 maxValue = UCHAR_MAX;
|
||||
return (Uint8)SDLTest_GenerateUnsignedBoundaryValues(maxValue,
|
||||
(Uint64) boundary1, (Uint64) boundary2,
|
||||
validDomain, buffer);
|
||||
if (buffer == NULL || size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
index = SDLTest_RandomSint32() % size;
|
||||
retVal = (Uint8)buffer[index];
|
||||
|
||||
SDL_free(buffer);
|
||||
|
||||
fuzzerInvocationCounter++;
|
||||
|
||||
return retVal;
|
||||
validDomain);
|
||||
}
|
||||
|
||||
Uint16
|
||||
SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain)
|
||||
{
|
||||
Uint64 *buffer = NULL;
|
||||
Uint32 size;
|
||||
Uint32 index;
|
||||
Uint16 retVal;
|
||||
|
||||
// max value for Uint16
|
||||
const Uint64 maxValue = UINT16_MAX;
|
||||
|
||||
size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
|
||||
/* max value for Uint16 */
|
||||
const Uint64 maxValue = USHRT_MAX;
|
||||
return (Uint16)SDLTest_GenerateUnsignedBoundaryValues(maxValue,
|
||||
(Uint64) boundary1, (Uint64) boundary2,
|
||||
validDomain, buffer);
|
||||
if (buffer == NULL || size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
index = SDLTest_RandomSint32() % size;
|
||||
retVal = (Uint16) buffer[index];
|
||||
|
||||
SDL_free(buffer);
|
||||
|
||||
fuzzerInvocationCounter++;
|
||||
|
||||
return retVal;
|
||||
validDomain);
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain)
|
||||
{
|
||||
Uint64 *buffer = NULL;
|
||||
Uint32 size;
|
||||
Uint32 index;
|
||||
Uint32 retVal;
|
||||
|
||||
// max value for Uint32
|
||||
const Uint64 maxValue = UINT32_MAX;
|
||||
|
||||
size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
|
||||
/* max value for Uint32 */
|
||||
const Uint64 maxValue = ULONG_MAX;
|
||||
return (Uint32)SDLTest_GenerateUnsignedBoundaryValues(maxValue,
|
||||
(Uint64) boundary1, (Uint64) boundary2,
|
||||
validDomain, buffer);
|
||||
if (buffer == NULL || size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
index = SDLTest_RandomSint32() % size;
|
||||
retVal = (Uint32) buffer[index];
|
||||
|
||||
SDL_free(buffer);
|
||||
|
||||
fuzzerInvocationCounter++;
|
||||
|
||||
return retVal;
|
||||
validDomain);
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain)
|
||||
{
|
||||
Uint64 *buffer = NULL;
|
||||
Uint32 size;
|
||||
Uint32 index;
|
||||
Uint64 retVal;
|
||||
|
||||
// max value for Uint64
|
||||
const Uint64 maxValue = UINT64_MAX;
|
||||
|
||||
size = SDLTest_GenerateUnsignedBoundaryValues(maxValue,
|
||||
/* max value for Uint64 */
|
||||
const Uint64 maxValue = ULLONG_MAX;
|
||||
return SDLTest_GenerateUnsignedBoundaryValues(maxValue,
|
||||
(Uint64) boundary1, (Uint64) boundary2,
|
||||
validDomain, buffer);
|
||||
if (buffer == NULL || size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
index = SDLTest_RandomSint32() % size;
|
||||
retVal = (Uint64) buffer[index];
|
||||
|
||||
SDL_free(buffer);
|
||||
|
||||
fuzzerInvocationCounter++;
|
||||
|
||||
return retVal;
|
||||
validDomain);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Generates boundary values between the given boundaries.
|
||||
* Generates a signed boundary value between the given boundaries.
|
||||
* Boundary values are inclusive. See the examples below.
|
||||
* If boundary2 < boundary1, the values are swapped.
|
||||
* If boundary1 == boundary2, value of boundary1 will be returned
|
||||
*
|
||||
* Generating boundary values for Sint8:
|
||||
* SignedBoundaryValues(sizeof(Sint8), -10, 20, True) -> [-11,-10,19,20]
|
||||
* SignedBoundaryValues(sizeof(Sint8), -10, 20, False) -> [-11,21]
|
||||
* SignedBoundaryValues(sizeof(Sint8), -30, -15, True) -> [-30, -29, -16, -15]
|
||||
* SignedBoundaryValues(sizeof(Sint8), -128, 15, False) -> [16]
|
||||
* SignedBoundaryValues(sizeof(Sint8), -128, 127, False) -> NULL
|
||||
* SignedBoundaryValues(SCHAR_MIN, SCHAR_MAX, -10, 20, True) -> [-10,-9,19,20]
|
||||
* SignedBoundaryValues(SCHAR_MIN, SCHAR_MAX, -10, 20, False) -> [-11,21]
|
||||
* SignedBoundaryValues(SCHAR_MIN, SCHAR_MAX, -30, -15, True) -> [-30, -29, -16, -15]
|
||||
* SignedBoundaryValues(SCHAR_MIN, SCHAR_MAX, -127, 15, False) -> [16]
|
||||
* SignedBoundaryValues(SCHAR_MIN, SCHAR_MAX, -127, 127, False) -> [0], error set
|
||||
*
|
||||
* Generator works the same for other types of signed integers.
|
||||
*
|
||||
* Note: outBuffer will be allocated and needs to be freed later.
|
||||
* If outbuffer != NULL, it'll be freed.
|
||||
*
|
||||
*
|
||||
* \param minValue The smallest value that is acceptable for this data type.
|
||||
* For instance, for Uint8 -> -128, Uint16 -> -32,768 etc.
|
||||
* \param minValue The smallest value that is acceptable for this data type.
|
||||
* For instance, for Uint8 -> -127, etc.
|
||||
* \param maxValue The biggest value that is acceptable for this data type.
|
||||
* For instance, for Uint8 -> 127, Uint16 -> 32767 etc.
|
||||
* \param pBoundary1 defines lower boundary
|
||||
* \param pBoundary2 defines upper boundary
|
||||
* For instance, for Uint8 -> 127, etc.
|
||||
* \param boundary1 defines lower boundary
|
||||
* \param boundary2 defines upper boundary
|
||||
* \param validDomain Generate only for valid domain (for the data type)
|
||||
*
|
||||
* \param outBuffer The generated boundary values are put here
|
||||
*
|
||||
* \returns Returns the number of elements in outBuffer or -1 in case of error
|
||||
* \returns Returns a random boundary value for the domain or 0 in case of error
|
||||
*/
|
||||
Uint32
|
||||
SDLTest_GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue,
|
||||
Sint64 pBoundary1, Sint64 pBoundary2, SDL_bool validDomain,
|
||||
Sint64 *outBuffer)
|
||||
Sint64
|
||||
SDLTest_GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue, Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain)
|
||||
{
|
||||
int index;
|
||||
Sint64 b1, b2;
|
||||
Sint64 delta;
|
||||
Sint64 tempBuf[4];
|
||||
Sint64 boundary1 = pBoundary1, boundary2 = pBoundary2;
|
||||
|
||||
if(outBuffer != NULL) {
|
||||
SDL_free(outBuffer);
|
||||
}
|
||||
|
||||
if(boundary1 > boundary2) {
|
||||
Sint64 temp = boundary1;
|
||||
boundary1 = boundary2;
|
||||
boundary2 = temp;
|
||||
}
|
||||
Uint8 index;
|
||||
|
||||
/* Maybe swap */
|
||||
if (boundary1 > boundary2) {
|
||||
b1 = boundary2;
|
||||
b2 = boundary1;
|
||||
} else {
|
||||
b1 = boundary1;
|
||||
b2 = boundary2;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
if(boundary1 == boundary2) {
|
||||
tempBuf[index++] = boundary1;
|
||||
}
|
||||
else if(validDomain) {
|
||||
tempBuf[index++] = boundary1;
|
||||
|
||||
if(boundary1 < LLONG_MAX)
|
||||
tempBuf[index++] = boundary1 + 1;
|
||||
|
||||
if(boundary2 > LLONG_MIN)
|
||||
tempBuf[index++] = boundary2 - 1;
|
||||
|
||||
tempBuf[index++] = boundary2;
|
||||
}
|
||||
else {
|
||||
if(boundary1 > minValue && boundary1 > LLONG_MIN) {
|
||||
tempBuf[index++] = boundary1 - 1;
|
||||
if (validDomain == SDL_TRUE) {
|
||||
if (b1 == b2) {
|
||||
return b1;
|
||||
}
|
||||
|
||||
/* Generate up to 4 values within bounds */
|
||||
delta = b2 - b1;
|
||||
if (delta < 4) {
|
||||
do {
|
||||
tempBuf[index] = b1 + index;
|
||||
index++;
|
||||
} while (index < delta);
|
||||
} else {
|
||||
tempBuf[index] = b1;
|
||||
index++;
|
||||
tempBuf[index] = b1 + 1;
|
||||
index++;
|
||||
tempBuf[index] = b2 - 1;
|
||||
index++;
|
||||
tempBuf[index] = b2;
|
||||
index++;
|
||||
}
|
||||
} else {
|
||||
/* Generate up to 2 values outside of bounds */
|
||||
if (b1 > minValue) {
|
||||
tempBuf[index] = b1 - 1;
|
||||
index++;
|
||||
}
|
||||
|
||||
if(boundary2 < maxValue && boundary2 < UINT64_MAX) {
|
||||
tempBuf[index++] = boundary2 + 1;
|
||||
if (b2 < maxValue) {
|
||||
tempBuf[index] = b2 + 1;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
if(index == 0) {
|
||||
// There are no valid boundaries
|
||||
return 0;
|
||||
if (index == 0) {
|
||||
/* There are no valid boundaries */
|
||||
SDL_Error(SDL_UNSUPPORTED);
|
||||
return minValue;
|
||||
}
|
||||
|
||||
// Create the return buffer
|
||||
outBuffer = (Sint64 *)SDL_malloc(index * sizeof(Sint64));
|
||||
if(outBuffer == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_memcpy((void *)outBuffer, (void *)tempBuf, index * sizeof(Sint64));
|
||||
|
||||
return (Uint32)index;
|
||||
return tempBuf[SDLTest_RandomUint8() % index];
|
||||
}
|
||||
|
||||
|
||||
Sint8
|
||||
SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain)
|
||||
{
|
||||
// min & max values for Sint8
|
||||
const Sint64 maxValue = CHAR_MAX;
|
||||
const Sint64 minValue = CHAR_MIN;
|
||||
|
||||
Sint64 *buffer = NULL;
|
||||
Uint32 size;
|
||||
Uint32 index;
|
||||
Sint8 retVal;
|
||||
|
||||
size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
|
||||
/* min & max values for Sint8 */
|
||||
const Sint64 maxValue = SCHAR_MAX;
|
||||
const Sint64 minValue = SCHAR_MIN;
|
||||
return (Sint8)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
|
||||
(Sint64) boundary1, (Sint64) boundary2,
|
||||
validDomain, buffer);
|
||||
if (buffer == NULL || size == 0) {
|
||||
return CHAR_MIN;
|
||||
}
|
||||
|
||||
index = SDLTest_RandomSint32() % size;
|
||||
retVal = (Sint8) buffer[index];
|
||||
|
||||
SDL_free(buffer);
|
||||
|
||||
fuzzerInvocationCounter++;
|
||||
|
||||
return retVal;
|
||||
validDomain);
|
||||
}
|
||||
|
||||
Sint16
|
||||
SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain)
|
||||
{
|
||||
// min & max values for Sint16
|
||||
/* min & max values for Sint16 */
|
||||
const Sint64 maxValue = SHRT_MAX;
|
||||
const Sint64 minValue = SHRT_MIN;
|
||||
Sint64 *buffer = NULL;
|
||||
Uint32 size;
|
||||
Uint32 index;
|
||||
Sint16 retVal;
|
||||
|
||||
size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
|
||||
(Sint64) boundary1, (Sint64) boundary2,
|
||||
validDomain, buffer);
|
||||
if (buffer == NULL || size == 0) {
|
||||
return SHRT_MIN;
|
||||
}
|
||||
|
||||
index = SDLTest_RandomSint32() % size;
|
||||
retVal = (Sint16) buffer[index];
|
||||
|
||||
SDL_free(buffer);
|
||||
|
||||
fuzzerInvocationCounter++;
|
||||
|
||||
return retVal;
|
||||
return (Sint16)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
|
||||
(Sint64) boundary1, (Sint64) boundary2,
|
||||
validDomain);
|
||||
}
|
||||
|
||||
Sint32
|
||||
SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain)
|
||||
{
|
||||
// min & max values for Sint32
|
||||
const Sint64 maxValue = INT_MAX;
|
||||
const Sint64 minValue = INT_MIN;
|
||||
|
||||
Sint64 *buffer = NULL;
|
||||
Uint32 size;
|
||||
Uint32 index;
|
||||
Sint32 retVal;
|
||||
|
||||
size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
|
||||
/* min & max values for Sint32 */
|
||||
const Sint64 maxValue = LONG_MAX;
|
||||
const Sint64 minValue = LONG_MIN;
|
||||
return (Sint32)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
|
||||
(Sint64) boundary1, (Sint64) boundary2,
|
||||
validDomain, buffer);
|
||||
if (buffer == NULL || size == 0) {
|
||||
return INT_MIN;
|
||||
}
|
||||
|
||||
index = SDLTest_RandomSint32() % size;
|
||||
retVal = (Sint32) buffer[index];
|
||||
|
||||
SDL_free(buffer);
|
||||
|
||||
fuzzerInvocationCounter++;
|
||||
|
||||
return retVal;
|
||||
validDomain);
|
||||
}
|
||||
|
||||
Sint64
|
||||
SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain)
|
||||
{
|
||||
Sint64 *buffer = NULL;
|
||||
Uint32 size;
|
||||
Uint32 index;
|
||||
Sint64 retVal;
|
||||
|
||||
// min & max values for Sint64
|
||||
/* min & max values for Sint64 */
|
||||
const Sint64 maxValue = LLONG_MAX;
|
||||
const Sint64 minValue = LLONG_MIN;
|
||||
|
||||
size = SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
|
||||
(Sint64) boundary1, (Sint64) boundary2,
|
||||
validDomain, buffer);
|
||||
if (buffer == NULL || size == 0) {
|
||||
return LLONG_MIN;
|
||||
}
|
||||
|
||||
index = SDLTest_RandomSint32() % size;
|
||||
retVal = (Sint64) buffer[index];
|
||||
|
||||
SDL_free(buffer);
|
||||
|
||||
fuzzerInvocationCounter++;
|
||||
|
||||
return retVal;
|
||||
return SDLTest_GenerateSignedBoundaryValues(minValue, maxValue,
|
||||
boundary1, boundary2,
|
||||
validDomain);
|
||||
}
|
||||
|
||||
float
|
||||
|
|
|
@ -81,6 +81,8 @@ static int main_testImpliedJoystickInit (void *arg)
|
|||
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||
initialized_system = SDL_WasInit(joy_and_controller);
|
||||
SDLTest_AssertCheck( (initialized_system & joy_and_controller) == 0, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system );
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
static int main_testImpliedJoystickQuit (void *arg)
|
||||
|
@ -103,6 +105,8 @@ static int main_testImpliedJoystickQuit (void *arg)
|
|||
SDLTest_AssertCheck( (initialized_system & joy_and_controller) == SDL_INIT_JOYSTICK, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system );
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
static const SDLTest_TestCaseReference mainTest1 =
|
||||
|
|
|
@ -50,7 +50,7 @@ sdltest_randomNumber(void *arg)
|
|||
result = (Sint64)SDLTest_RandomUint8();
|
||||
umax = (1 << 8) - 1;
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8");
|
||||
SDLTest_AssertCheck(result >= 0 && result <= umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
|
||||
SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
|
||||
|
||||
result = (Sint64)SDLTest_RandomSint8();
|
||||
min = 1 - (1 << 7);
|
||||
|
@ -61,7 +61,7 @@ sdltest_randomNumber(void *arg)
|
|||
result = (Sint64)SDLTest_RandomUint16();
|
||||
umax = (1 << 16) - 1;
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16");
|
||||
SDLTest_AssertCheck(result >= 0 && result <= umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
|
||||
SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
|
||||
|
||||
result = (Sint64)SDLTest_RandomSint16();
|
||||
min = 1 - (1 << 15);
|
||||
|
@ -72,18 +72,7 @@ sdltest_randomNumber(void *arg)
|
|||
result = (Sint64)SDLTest_RandomUint32();
|
||||
umax = ((Uint64)1 << 32) - 1;
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32");
|
||||
SDLTest_AssertCheck(result >= 0 && result <= umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
|
||||
|
||||
result = (Sint64)SDLTest_RandomSint32();
|
||||
min = 1 - ((Sint64)1 << 31);
|
||||
max = ((Sint64)1 << 31) - 1;
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32");
|
||||
SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
|
||||
|
||||
result = (Sint64)SDLTest_RandomUint32();
|
||||
umax = ((Uint64)1 << 32) - 1;
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32");
|
||||
SDLTest_AssertCheck(result >= 0 && result <= umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
|
||||
SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
|
||||
|
||||
result = (Sint64)SDLTest_RandomSint32();
|
||||
min = 1 - ((Sint64)1 << 31);
|
||||
|
@ -115,6 +104,887 @@ sdltest_randomNumber(void *arg)
|
|||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Calls to random boundary number generators for Uint8
|
||||
*/
|
||||
int
|
||||
sdltest_randomBoundaryNumberUint8(void *arg)
|
||||
{
|
||||
const char *expectedError = "That operation is not supported";
|
||||
char *lastError;
|
||||
Uint64 uresult;
|
||||
|
||||
/* Clean error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
|
||||
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10,
|
||||
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
|
||||
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 11, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11,
|
||||
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
|
||||
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 12, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 12,
|
||||
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
|
||||
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 13, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
|
||||
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 20, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
|
||||
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(20, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
|
||||
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
|
||||
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 20, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0 || uresult == 21,
|
||||
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
|
||||
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 99, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 100,
|
||||
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(1, 0xff, SDL_FALSE) returns 0 (no error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 255, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0,
|
||||
"Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 0xfe, SDL_FALSE) returns 0xff (no error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 254, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0xff,
|
||||
"Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 0xff, SDL_FALSE) returns 0 (sets error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 255, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0,
|
||||
"Validate result value for parameters(0,255,SDL_FALSE); expected: 0, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
expectedError,
|
||||
lastError);
|
||||
|
||||
/* Clear error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Calls to random boundary number generators for Uint16
|
||||
*/
|
||||
int
|
||||
sdltest_randomBoundaryNumberUint16(void *arg)
|
||||
{
|
||||
const char *expectedError = "That operation is not supported";
|
||||
char *lastError;
|
||||
Uint64 uresult;
|
||||
|
||||
/* Clean error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
|
||||
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10,
|
||||
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
|
||||
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 11, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11,
|
||||
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
|
||||
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 12, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 12,
|
||||
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
|
||||
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 13, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
|
||||
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 20, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
|
||||
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(20, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
|
||||
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
|
||||
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 20, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0 || uresult == 21,
|
||||
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
|
||||
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 99, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 100,
|
||||
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(1, 0xffff, SDL_FALSE) returns 0 (no error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 0xffff, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0,
|
||||
"Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 0xfffe, SDL_FALSE) returns 0xffff (no error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xfffe, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0xffff,
|
||||
"Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 0xffff, SDL_FALSE) returns 0 (sets error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xffff, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0,
|
||||
"Validate result value for parameters(0,0xffff,SDL_FALSE); expected: 0, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
expectedError,
|
||||
lastError);
|
||||
|
||||
/* Clear error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Calls to random boundary number generators for Uint32
|
||||
*/
|
||||
int
|
||||
sdltest_randomBoundaryNumberUint32(void *arg)
|
||||
{
|
||||
const char *expectedError = "That operation is not supported";
|
||||
char *lastError;
|
||||
Uint64 uresult;
|
||||
|
||||
/* Clean error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
|
||||
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10,
|
||||
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
|
||||
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 11, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11,
|
||||
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
|
||||
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 12, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 12,
|
||||
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
|
||||
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 13, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
|
||||
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 20, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
|
||||
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(20, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
|
||||
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
|
||||
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 20, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0 || uresult == 21,
|
||||
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
|
||||
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 99, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 100,
|
||||
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(1, 0xffffffff, SDL_FALSE) returns 0 (no error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 0xffffffff, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0,
|
||||
"Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 0xfffffffe, SDL_FALSE) returns 0xffffffff (no error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xfffffffe, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0xffffffff,
|
||||
"Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 0xffffffff, SDL_FALSE) returns 0 (sets error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xffffffff, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0,
|
||||
"Validate result value for parameters(0,0xffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
expectedError,
|
||||
lastError);
|
||||
|
||||
/* Clear error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Calls to random boundary number generators for Uint64
|
||||
*/
|
||||
int
|
||||
sdltest_randomBoundaryNumberUint64(void *arg)
|
||||
{
|
||||
const char *expectedError = "That operation is not supported";
|
||||
char *lastError;
|
||||
Uint64 uresult;
|
||||
|
||||
/* Clean error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10,
|
||||
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11,
|
||||
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 12,
|
||||
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
|
||||
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
|
||||
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
|
||||
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0 || uresult == 21,
|
||||
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 100,
|
||||
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0,
|
||||
"Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 0xfffffffffffffffe, SDL_FALSE) returns 0xffffffffffffffff (no error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xfffffffffffffffeULL, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == (Uint64)0xffffffffffffffffULL,
|
||||
"Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 0xffffffffffffffff, SDL_FALSE) returns 0 (sets error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0,
|
||||
"Validate result value for parameters(0,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
expectedError,
|
||||
lastError);
|
||||
|
||||
/* Clear error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Calls to random boundary number generators for Sint8
|
||||
*/
|
||||
int
|
||||
sdltest_randomBoundaryNumberSint8(void *arg)
|
||||
{
|
||||
const char *expectedError = "That operation is not supported";
|
||||
char *lastError;
|
||||
Sint64 sresult;
|
||||
|
||||
/* Clean error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
|
||||
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10,
|
||||
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
|
||||
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 11, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11,
|
||||
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
|
||||
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 12, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 12,
|
||||
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
|
||||
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 13, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
|
||||
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 20, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
|
||||
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(20, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
|
||||
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
|
||||
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(1, 20, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 0 || sresult == 21,
|
||||
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(SCHAR_MIN, 99, SDL_FALSE) returns 100 */
|
||||
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, 99, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 100,
|
||||
"Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (no error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == SCHAR_MIN,
|
||||
"Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %lld", SCHAR_MIN, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX - 1, SDL_FALSE) returns SCHAR_MAX (no error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX -1, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == SCHAR_MAX,
|
||||
"Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SCHAR_MAX, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (sets error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == SCHAR_MIN,
|
||||
"Validate result value for parameters(SCHAR_MIN,SCHAR_MAX,SDL_FALSE); expected: %d, got: %lld", SCHAR_MIN, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
expectedError,
|
||||
lastError);
|
||||
|
||||
/* Clear error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Calls to random boundary number generators for Sint16
|
||||
*/
|
||||
int
|
||||
sdltest_randomBoundaryNumberSint16(void *arg)
|
||||
{
|
||||
const char *expectedError = "That operation is not supported";
|
||||
char *lastError;
|
||||
Sint64 sresult;
|
||||
|
||||
/* Clean error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
|
||||
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10,
|
||||
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
|
||||
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 11, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11,
|
||||
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
|
||||
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 12, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 12,
|
||||
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
|
||||
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 13, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
|
||||
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 20, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
|
||||
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(20, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
|
||||
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
|
||||
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(1, 20, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 0 || sresult == 21,
|
||||
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(SHRT_MIN, 99, SDL_FALSE) returns 100 */
|
||||
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, 99, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 100,
|
||||
"Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE) returns SHRT_MIN (no error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == SHRT_MIN,
|
||||
"Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %lld", SHRT_MIN, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE) returns SHRT_MAX (no error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == SHRT_MAX,
|
||||
"Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SHRT_MAX, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE) returns 0 (sets error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == SHRT_MIN,
|
||||
"Validate result value for parameters(SHRT_MIN,SHRT_MAX,SDL_FALSE); expected: %d, got: %lld", SHRT_MIN, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
expectedError,
|
||||
lastError);
|
||||
|
||||
/* Clear error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Calls to random boundary number generators for Sint32
|
||||
*/
|
||||
int
|
||||
sdltest_randomBoundaryNumberSint32(void *arg)
|
||||
{
|
||||
const char *expectedError = "That operation is not supported";
|
||||
char *lastError;
|
||||
Sint64 sresult;
|
||||
|
||||
/* Clean error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
|
||||
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10,
|
||||
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
|
||||
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 11, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11,
|
||||
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
|
||||
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 12, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 12,
|
||||
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
|
||||
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 13, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
|
||||
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 20, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
|
||||
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(20, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
|
||||
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
|
||||
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(1, 20, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 0 || sresult == 21,
|
||||
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */
|
||||
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(LONG_MIN, 99, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 100,
|
||||
"Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == LONG_MIN,
|
||||
"Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", LONG_MIN, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE) returns LONG_MAX (no error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == LONG_MAX,
|
||||
"Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %lld", LONG_MAX, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE) returns 0 (sets error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == LONG_MIN,
|
||||
"Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", LONG_MIN, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
expectedError,
|
||||
lastError);
|
||||
|
||||
/* Clear error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Calls to random boundary number generators for Sint64
|
||||
*/
|
||||
int
|
||||
sdltest_randomBoundaryNumberSint64(void *arg)
|
||||
{
|
||||
const char *expectedError = "That operation is not supported";
|
||||
char *lastError;
|
||||
Sint64 sresult;
|
||||
|
||||
/* Clean error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10,
|
||||
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11,
|
||||
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 12,
|
||||
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
|
||||
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
|
||||
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
|
||||
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 0 || sresult == 21,
|
||||
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, 99, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 100,
|
||||
"Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == LLONG_MIN,
|
||||
"Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %lld, got: %lld", LLONG_MIN, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == LLONG_MAX,
|
||||
"Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %lld, got: %lld", LLONG_MAX, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
|
||||
|
||||
/* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == LLONG_MIN,
|
||||
"Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %lld, got: %lld", LLONG_MIN, sresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
|
||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||
expectedError,
|
||||
lastError);
|
||||
|
||||
/* Clear error messages */
|
||||
SDL_ClearError();
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* SDL_test test cases */
|
||||
|
@ -124,9 +994,34 @@ static const SDLTest_TestCaseReference sdltestTest1 =
|
|||
static const SDLTest_TestCaseReference sdltestTest2 =
|
||||
{ (SDLTest_TestCaseFp)sdltest_randomNumber, "sdltest_randomNumber", "Calls to random number generators", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference sdltestTest3 =
|
||||
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint8, "sdltest_randomBoundaryNumberUint8", "Calls to random boundary number generators for Uint8", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference sdltestTest4 =
|
||||
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint16, "sdltest_randomBoundaryNumberUint16", "Calls to random boundary number generators for Uint16", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference sdltestTest5 =
|
||||
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint32, "sdltest_randomBoundaryNumberUint32", "Calls to random boundary number generators for Uint32", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference sdltestTest6 =
|
||||
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint64, "sdltest_randomBoundaryNumberUint64", "Calls to random boundary number generators for Uint64", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference sdltestTest7 =
|
||||
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint8, "sdltest_randomBoundaryNumberSint8", "Calls to random boundary number generators for Sint8", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference sdltestTest8 =
|
||||
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint16, "sdltest_randomBoundaryNumberSint16", "Calls to random boundary number generators for Sint16", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference sdltestTest9 =
|
||||
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint32, "sdltest_randomBoundaryNumberSint32", "Calls to random boundary number generators for Sint32", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference sdltestTest10 =
|
||||
{ (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint64, "sdltest_randomBoundaryNumberSint64", "Calls to random boundary number generators for Sint64", TEST_ENABLED };
|
||||
|
||||
/* Sequence of SDL_test test cases */
|
||||
static const SDLTest_TestCaseReference *sdltestTests[] = {
|
||||
&sdltestTest1, &sdltestTest2, NULL
|
||||
&sdltestTest1, &sdltestTest2, &sdltestTest3, &sdltestTest4, &sdltestTest5, &sdltestTest6,
|
||||
&sdltestTest7, &sdltestTest8, &sdltestTest9, &sdltestTest10, NULL
|
||||
};
|
||||
|
||||
/* SDL_test test suite (global) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue