test/testautomation_sdltest.c
author Jørgen P. Tjernø <jorgen@valvesoftware.com>
Wed, 05 Jun 2013 12:48:44 -0700
changeset 7277 1290cd7f34af
parent 7191 75360622e65f
child 7614 af0bd07212bd
permissions -rw-r--r--
Mac: Fix invalid PS3 controller mapping.

PS3 controller had swapped D-Pad down & left buttons, as well as X & Y buttons.
Thanks to Alex Szpakowski for the bug report and fix.

Fixes http://bugzilla.libsdl.org/show_bug.cgi?id=1891
     1 /**
     2  * SDL_test test suite
     3  */
     4 
     5 /* Visual Studio 2008 doesn't have stdint.h */
     6 #if defined(_MSC_VER) && _MSC_VER <= 1500
     7 #define UINT8_MAX   ~(Uint8)0
     8 #define UINT16_MAX  ~(Uint16)0
     9 #define UINT32_MAX  ~(Uint32)0
    10 #define UINT64_MAX  ~(Uint64)0
    11 #else
    12 #include <stdint.h>
    13 #endif
    14 #include <stdio.h>
    15 #include <limits.h>
    16 #include <float.h>
    17 #include <ctype.h>
    18 
    19 #include "SDL.h"
    20 #include "SDL_test.h"
    21 
    22 /* Test case functions */
    23 
    24 /**
    25  * @brief Calls to SDLTest_GetFuzzerInvocationCount()
    26  */
    27 int
    28 sdltest_getFuzzerInvocationCount(void *arg)
    29 {
    30   Uint8 result;
    31   int fuzzerCount1, fuzzerCount2;
    32 
    33   fuzzerCount1 = SDLTest_GetFuzzerInvocationCount();
    34   SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()");
    35   SDLTest_AssertCheck(fuzzerCount1 >= 0, "Verify returned value, expected: >=0, got: %d", fuzzerCount1);
    36 
    37   result = SDLTest_RandomUint8();
    38   SDLTest_AssertPass("Call to SDLTest_RandomUint8(), returned %d", result);
    39 
    40   fuzzerCount2 = SDLTest_GetFuzzerInvocationCount();
    41   SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()");
    42   SDLTest_AssertCheck(fuzzerCount2 > fuzzerCount1, "Verify returned value, expected: >%d, got: %d", fuzzerCount1, fuzzerCount2);
    43 
    44   return TEST_COMPLETED;
    45 }
    46 
    47 
    48 /**
    49  * @brief Calls to random number generators
    50  */
    51 int
    52 sdltest_randomNumber(void *arg)
    53 {
    54   Sint64 result;
    55   Uint64 uresult;
    56   double dresult;
    57   Uint64 umax;
    58   Sint64 min, max;
    59 
    60   result = (Sint64)SDLTest_RandomUint8();
    61   umax = (1 << 8) - 1;
    62   SDLTest_AssertPass("Call to SDLTest_RandomUint8");
    63   SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
    64 
    65   result = (Sint64)SDLTest_RandomSint8();
    66   min = 1 - (1 << 7);
    67   max =     (1 << 7) - 1;
    68   SDLTest_AssertPass("Call to SDLTest_RandomSint8");
    69   SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
    70 
    71   result = (Sint64)SDLTest_RandomUint16();
    72   umax = (1 << 16) - 1;
    73   SDLTest_AssertPass("Call to SDLTest_RandomUint16");
    74   SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
    75 
    76   result = (Sint64)SDLTest_RandomSint16();
    77   min = 1 - (1 << 15);
    78   max =     (1 << 15) - 1;
    79   SDLTest_AssertPass("Call to SDLTest_RandomSint16");
    80   SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
    81 
    82   result = (Sint64)SDLTest_RandomUint32();
    83   umax = ((Uint64)1 << 32) - 1;
    84   SDLTest_AssertPass("Call to SDLTest_RandomUint32");
    85   SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
    86 
    87   result = (Sint64)SDLTest_RandomSint32();
    88   min = 1 - ((Sint64)1 << 31);
    89   max =     ((Sint64)1 << 31) - 1;
    90   SDLTest_AssertPass("Call to SDLTest_RandomSint32");
    91   SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
    92 
    93   uresult = SDLTest_RandomUint64();
    94   SDLTest_AssertPass("Call to SDLTest_RandomUint64");
    95 
    96   result = SDLTest_RandomSint64();
    97   SDLTest_AssertPass("Call to SDLTest_RandomSint64");
    98 
    99   dresult = (double)SDLTest_RandomUnitFloat();
   100   SDLTest_AssertPass("Call to SDLTest_RandomUnitFloat");
   101   SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult);
   102 
   103   dresult = (double)SDLTest_RandomFloat();
   104   SDLTest_AssertPass("Call to SDLTest_RandomFloat");
   105   SDLTest_AssertCheck(dresult >= (double)(-FLT_MAX) && dresult <= (double)FLT_MAX, "Verify result value, expected: [%e,%e], got: %e", (double)(-FLT_MAX), (double)FLT_MAX, dresult);
   106 
   107   dresult = (double)SDLTest_RandomUnitDouble();
   108   SDLTest_AssertPass("Call to SDLTest_RandomUnitDouble");
   109   SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult);
   110 
   111   dresult = SDLTest_RandomDouble();
   112   SDLTest_AssertPass("Call to SDLTest_RandomDouble");
   113 
   114   return TEST_COMPLETED;
   115 }
   116 
   117 /*
   118  * @brief Calls to random boundary number generators for Uint8
   119  */
   120 int
   121 sdltest_randomBoundaryNumberUint8(void *arg)
   122 {
   123   const char *expectedError = "That operation is not supported";
   124   char *lastError;
   125   Uint64 uresult;
   126 
   127   /* Clean error messages */
   128   SDL_ClearError();
   129   SDLTest_AssertPass("SDL_ClearError()");
   130 
   131   /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
   132   uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 10, SDL_TRUE);
   133   SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
   134   SDLTest_AssertCheck(
   135     uresult == 10,
   136     "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
   137 
   138   /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
   139   uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 11, SDL_TRUE);
   140   SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
   141   SDLTest_AssertCheck(
   142     uresult == 10 || uresult == 11,
   143     "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
   144 
   145   /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
   146   uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 12, SDL_TRUE);
   147   SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
   148   SDLTest_AssertCheck(
   149     uresult == 10 || uresult == 11 || uresult == 12,
   150     "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
   151 
   152   /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
   153   uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 13, SDL_TRUE);
   154   SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
   155   SDLTest_AssertCheck(
   156     uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
   157     "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
   158 
   159   /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
   160   uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 20, SDL_TRUE);
   161   SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
   162   SDLTest_AssertCheck(
   163     uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
   164     "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
   165 
   166   /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
   167   uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(20, 10, SDL_TRUE);
   168   SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
   169   SDLTest_AssertCheck(
   170     uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
   171     "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
   172 
   173   /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
   174   uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 20, SDL_FALSE);
   175   SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
   176   SDLTest_AssertCheck(
   177     uresult == 0 || uresult == 21,
   178     "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
   179 
   180   /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
   181   uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 99, SDL_FALSE);
   182   SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
   183   SDLTest_AssertCheck(
   184     uresult == 100,
   185     "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
   186 
   187   /* RandomUintXBoundaryValue(1, 0xff, SDL_FALSE) returns 0 (no error) */
   188   uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 255, SDL_FALSE);
   189   SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
   190   SDLTest_AssertCheck(
   191     uresult == 0,
   192     "Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %lld", uresult);
   193   lastError = (char *)SDL_GetError();
   194   SDLTest_AssertPass("SDL_GetError()");
   195   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   196 
   197   /* RandomUintXBoundaryValue(0, 0xfe, SDL_FALSE) returns 0xff (no error) */
   198   uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 254, SDL_FALSE);
   199   SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
   200   SDLTest_AssertCheck(
   201     uresult == 0xff,
   202     "Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %lld", uresult);
   203   lastError = (char *)SDL_GetError();
   204   SDLTest_AssertPass("SDL_GetError()");
   205   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   206 
   207   /* RandomUintXBoundaryValue(0, 0xff, SDL_FALSE) returns 0 (sets error) */
   208   uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 255, SDL_FALSE);
   209   SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
   210   SDLTest_AssertCheck(
   211     uresult == 0,
   212     "Validate result value for parameters(0,255,SDL_FALSE); expected: 0, got: %lld", uresult);
   213   lastError = (char *)SDL_GetError();
   214   SDLTest_AssertPass("SDL_GetError()");
   215   SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
   216              "SDL_GetError(): expected message '%s', was message: '%s'",
   217              expectedError,
   218              lastError);
   219 
   220   /* Clear error messages */
   221   SDL_ClearError();
   222   SDLTest_AssertPass("SDL_ClearError()");
   223 
   224   return TEST_COMPLETED;
   225 }
   226 
   227 /*
   228  * @brief Calls to random boundary number generators for Uint16
   229  */
   230 int
   231 sdltest_randomBoundaryNumberUint16(void *arg)
   232 {
   233   const char *expectedError = "That operation is not supported";
   234   char *lastError;
   235   Uint64 uresult;
   236 
   237   /* Clean error messages */
   238   SDL_ClearError();
   239   SDLTest_AssertPass("SDL_ClearError()");
   240 
   241   /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
   242   uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 10, SDL_TRUE);
   243   SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
   244   SDLTest_AssertCheck(
   245     uresult == 10,
   246     "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
   247 
   248   /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
   249   uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 11, SDL_TRUE);
   250   SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
   251   SDLTest_AssertCheck(
   252     uresult == 10 || uresult == 11,
   253     "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
   254 
   255   /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
   256   uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 12, SDL_TRUE);
   257   SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
   258   SDLTest_AssertCheck(
   259     uresult == 10 || uresult == 11 || uresult == 12,
   260     "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
   261 
   262   /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
   263   uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 13, SDL_TRUE);
   264   SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
   265   SDLTest_AssertCheck(
   266     uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
   267     "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
   268 
   269   /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
   270   uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 20, SDL_TRUE);
   271   SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
   272   SDLTest_AssertCheck(
   273     uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
   274     "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
   275 
   276   /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
   277   uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(20, 10, SDL_TRUE);
   278   SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
   279   SDLTest_AssertCheck(
   280     uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
   281     "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
   282 
   283   /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
   284   uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 20, SDL_FALSE);
   285   SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
   286   SDLTest_AssertCheck(
   287     uresult == 0 || uresult == 21,
   288     "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
   289 
   290   /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
   291   uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 99, SDL_FALSE);
   292   SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
   293   SDLTest_AssertCheck(
   294     uresult == 100,
   295     "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
   296 
   297   /* RandomUintXBoundaryValue(1, 0xffff, SDL_FALSE) returns 0 (no error) */
   298   uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 0xffff, SDL_FALSE);
   299   SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
   300   SDLTest_AssertCheck(
   301     uresult == 0,
   302     "Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %lld", uresult);
   303   lastError = (char *)SDL_GetError();
   304   SDLTest_AssertPass("SDL_GetError()");
   305   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   306 
   307   /* RandomUintXBoundaryValue(0, 0xfffe, SDL_FALSE) returns 0xffff (no error) */
   308   uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xfffe, SDL_FALSE);
   309   SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
   310   SDLTest_AssertCheck(
   311     uresult == 0xffff,
   312     "Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %lld", uresult);
   313   lastError = (char *)SDL_GetError();
   314   SDLTest_AssertPass("SDL_GetError()");
   315   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   316 
   317   /* RandomUintXBoundaryValue(0, 0xffff, SDL_FALSE) returns 0 (sets error) */
   318   uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xffff, SDL_FALSE);
   319   SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
   320   SDLTest_AssertCheck(
   321     uresult == 0,
   322     "Validate result value for parameters(0,0xffff,SDL_FALSE); expected: 0, got: %lld", uresult);
   323   lastError = (char *)SDL_GetError();
   324   SDLTest_AssertPass("SDL_GetError()");
   325   SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
   326              "SDL_GetError(): expected message '%s', was message: '%s'",
   327              expectedError,
   328              lastError);
   329 
   330   /* Clear error messages */
   331   SDL_ClearError();
   332   SDLTest_AssertPass("SDL_ClearError()");
   333 
   334   return TEST_COMPLETED;
   335 }
   336 
   337 /*
   338  * @brief Calls to random boundary number generators for Uint32
   339  */
   340 int
   341 sdltest_randomBoundaryNumberUint32(void *arg)
   342 {
   343   const char *expectedError = "That operation is not supported";
   344   char *lastError;
   345   Uint64 uresult;
   346 
   347   /* Clean error messages */
   348   SDL_ClearError();
   349   SDLTest_AssertPass("SDL_ClearError()");
   350 
   351   /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
   352   uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 10, SDL_TRUE);
   353   SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
   354   SDLTest_AssertCheck(
   355     uresult == 10,
   356     "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
   357 
   358   /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
   359   uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 11, SDL_TRUE);
   360   SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
   361   SDLTest_AssertCheck(
   362     uresult == 10 || uresult == 11,
   363     "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
   364 
   365   /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
   366   uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 12, SDL_TRUE);
   367   SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
   368   SDLTest_AssertCheck(
   369     uresult == 10 || uresult == 11 || uresult == 12,
   370     "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
   371 
   372   /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
   373   uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 13, SDL_TRUE);
   374   SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
   375   SDLTest_AssertCheck(
   376     uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
   377     "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
   378 
   379   /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
   380   uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 20, SDL_TRUE);
   381   SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
   382   SDLTest_AssertCheck(
   383     uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
   384     "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
   385 
   386   /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
   387   uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(20, 10, SDL_TRUE);
   388   SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
   389   SDLTest_AssertCheck(
   390     uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
   391     "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
   392 
   393   /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
   394   uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 20, SDL_FALSE);
   395   SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
   396   SDLTest_AssertCheck(
   397     uresult == 0 || uresult == 21,
   398     "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
   399 
   400   /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
   401   uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 99, SDL_FALSE);
   402   SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
   403   SDLTest_AssertCheck(
   404     uresult == 100,
   405     "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
   406 
   407   /* RandomUintXBoundaryValue(1, 0xffffffff, SDL_FALSE) returns 0 (no error) */
   408   uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 0xffffffff, SDL_FALSE);
   409   SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
   410   SDLTest_AssertCheck(
   411     uresult == 0,
   412     "Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
   413   lastError = (char *)SDL_GetError();
   414   SDLTest_AssertPass("SDL_GetError()");
   415   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   416 
   417   /* RandomUintXBoundaryValue(0, 0xfffffffe, SDL_FALSE) returns 0xffffffff (no error) */
   418   uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xfffffffe, SDL_FALSE);
   419   SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
   420   SDLTest_AssertCheck(
   421     uresult == 0xffffffff,
   422     "Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %lld", uresult);
   423   lastError = (char *)SDL_GetError();
   424   SDLTest_AssertPass("SDL_GetError()");
   425   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   426 
   427   /* RandomUintXBoundaryValue(0, 0xffffffff, SDL_FALSE) returns 0 (sets error) */
   428   uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xffffffff, SDL_FALSE);
   429   SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
   430   SDLTest_AssertCheck(
   431     uresult == 0,
   432     "Validate result value for parameters(0,0xffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
   433   lastError = (char *)SDL_GetError();
   434   SDLTest_AssertPass("SDL_GetError()");
   435   SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
   436              "SDL_GetError(): expected message '%s', was message: '%s'",
   437              expectedError,
   438              lastError);
   439 
   440   /* Clear error messages */
   441   SDL_ClearError();
   442   SDLTest_AssertPass("SDL_ClearError()");
   443 
   444   return TEST_COMPLETED;
   445 }
   446 
   447 /*
   448  * @brief Calls to random boundary number generators for Uint64
   449  */
   450 int
   451 sdltest_randomBoundaryNumberUint64(void *arg)
   452 {
   453   const char *expectedError = "That operation is not supported";
   454   char *lastError;
   455   Uint64 uresult;
   456 
   457   /* Clean error messages */
   458   SDL_ClearError();
   459   SDLTest_AssertPass("SDL_ClearError()");
   460 
   461   /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
   462   uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 10, SDL_TRUE);
   463   SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
   464   SDLTest_AssertCheck(
   465     uresult == 10,
   466     "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
   467 
   468   /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
   469   uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE);
   470   SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
   471   SDLTest_AssertCheck(
   472     uresult == 10 || uresult == 11,
   473     "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
   474 
   475   /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
   476   uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE);
   477   SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
   478   SDLTest_AssertCheck(
   479     uresult == 10 || uresult == 11 || uresult == 12,
   480     "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
   481 
   482   /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
   483   uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE);
   484   SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
   485   SDLTest_AssertCheck(
   486     uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
   487     "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
   488 
   489   /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
   490   uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE);
   491   SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
   492   SDLTest_AssertCheck(
   493     uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
   494     "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
   495 
   496   /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
   497   uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE);
   498   SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
   499   SDLTest_AssertCheck(
   500     uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
   501     "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
   502 
   503   /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
   504   uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE);
   505   SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
   506   SDLTest_AssertCheck(
   507     uresult == 0 || uresult == 21,
   508     "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
   509 
   510   /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
   511   uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE);
   512   SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
   513   SDLTest_AssertCheck(
   514     uresult == 100,
   515     "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
   516 
   517   /* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */
   518   uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
   519   SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
   520   SDLTest_AssertCheck(
   521     uresult == 0,
   522     "Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
   523   lastError = (char *)SDL_GetError();
   524   SDLTest_AssertPass("SDL_GetError()");
   525   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   526 
   527   /* RandomUintXBoundaryValue(0, 0xfffffffffffffffe, SDL_FALSE) returns 0xffffffffffffffff (no error) */
   528   uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xfffffffffffffffeULL, SDL_FALSE);
   529   SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
   530   SDLTest_AssertCheck(
   531     uresult == (Uint64)0xffffffffffffffffULL,
   532     "Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %lld", uresult);
   533   lastError = (char *)SDL_GetError();
   534   SDLTest_AssertPass("SDL_GetError()");
   535   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   536 
   537   /* RandomUintXBoundaryValue(0, 0xffffffffffffffff, SDL_FALSE) returns 0 (sets error) */
   538   uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
   539   SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
   540   SDLTest_AssertCheck(
   541     uresult == 0,
   542     "Validate result value for parameters(0,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
   543   lastError = (char *)SDL_GetError();
   544   SDLTest_AssertPass("SDL_GetError()");
   545   SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
   546              "SDL_GetError(): expected message '%s', was message: '%s'",
   547              expectedError,
   548              lastError);
   549 
   550   /* Clear error messages */
   551   SDL_ClearError();
   552   SDLTest_AssertPass("SDL_ClearError()");
   553 
   554   return TEST_COMPLETED;
   555 }
   556 
   557 /*
   558  * @brief Calls to random boundary number generators for Sint8
   559  */
   560 int
   561 sdltest_randomBoundaryNumberSint8(void *arg)
   562 {
   563   const char *expectedError = "That operation is not supported";
   564   char *lastError;
   565   Sint64 sresult;
   566 
   567   /* Clean error messages */
   568   SDL_ClearError();
   569   SDLTest_AssertPass("SDL_ClearError()");
   570 
   571   /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
   572   sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 10, SDL_TRUE);
   573   SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
   574   SDLTest_AssertCheck(
   575     sresult == 10,
   576     "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
   577 
   578   /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
   579   sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 11, SDL_TRUE);
   580   SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
   581   SDLTest_AssertCheck(
   582     sresult == 10 || sresult == 11,
   583     "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
   584 
   585   /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
   586   sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 12, SDL_TRUE);
   587   SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
   588   SDLTest_AssertCheck(
   589     sresult == 10 || sresult == 11 || sresult == 12,
   590     "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
   591 
   592   /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
   593   sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 13, SDL_TRUE);
   594   SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
   595   SDLTest_AssertCheck(
   596     sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
   597     "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
   598 
   599   /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
   600   sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 20, SDL_TRUE);
   601   SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
   602   SDLTest_AssertCheck(
   603     sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
   604     "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
   605 
   606   /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
   607   sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(20, 10, SDL_TRUE);
   608   SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
   609   SDLTest_AssertCheck(
   610     sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
   611     "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
   612 
   613   /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
   614   sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(1, 20, SDL_FALSE);
   615   SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
   616   SDLTest_AssertCheck(
   617     sresult == 0 || sresult == 21,
   618     "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
   619 
   620   /* RandomSintXBoundaryValue(SCHAR_MIN, 99, SDL_FALSE) returns 100 */
   621   sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, 99, SDL_FALSE);
   622   SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
   623   SDLTest_AssertCheck(
   624     sresult == 100,
   625     "Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
   626 
   627   /* RandomSintXBoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (no error) */
   628   sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE);
   629   SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
   630   SDLTest_AssertCheck(
   631     sresult == SCHAR_MIN,
   632     "Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %lld", SCHAR_MIN, sresult);
   633   lastError = (char *)SDL_GetError();
   634   SDLTest_AssertPass("SDL_GetError()");
   635   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   636 
   637   /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX - 1, SDL_FALSE) returns SCHAR_MAX (no error) */
   638   sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX -1, SDL_FALSE);
   639   SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
   640   SDLTest_AssertCheck(
   641     sresult == SCHAR_MAX,
   642     "Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SCHAR_MAX, sresult);
   643   lastError = (char *)SDL_GetError();
   644   SDLTest_AssertPass("SDL_GetError()");
   645   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   646 
   647   /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (sets error) */
   648   sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE);
   649   SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
   650   SDLTest_AssertCheck(
   651     sresult == SCHAR_MIN,
   652     "Validate result value for parameters(SCHAR_MIN,SCHAR_MAX,SDL_FALSE); expected: %d, got: %lld", SCHAR_MIN, sresult);
   653   lastError = (char *)SDL_GetError();
   654   SDLTest_AssertPass("SDL_GetError()");
   655   SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
   656              "SDL_GetError(): expected message '%s', was message: '%s'",
   657              expectedError,
   658              lastError);
   659 
   660   /* Clear error messages */
   661   SDL_ClearError();
   662   SDLTest_AssertPass("SDL_ClearError()");
   663 
   664   return TEST_COMPLETED;
   665 }
   666 
   667 /*
   668  * @brief Calls to random boundary number generators for Sint16
   669  */
   670 int
   671 sdltest_randomBoundaryNumberSint16(void *arg)
   672 {
   673   const char *expectedError = "That operation is not supported";
   674   char *lastError;
   675   Sint64 sresult;
   676 
   677   /* Clean error messages */
   678   SDL_ClearError();
   679   SDLTest_AssertPass("SDL_ClearError()");
   680 
   681   /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
   682   sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 10, SDL_TRUE);
   683   SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
   684   SDLTest_AssertCheck(
   685     sresult == 10,
   686     "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
   687 
   688   /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
   689   sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 11, SDL_TRUE);
   690   SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
   691   SDLTest_AssertCheck(
   692     sresult == 10 || sresult == 11,
   693     "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
   694 
   695   /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
   696   sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 12, SDL_TRUE);
   697   SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
   698   SDLTest_AssertCheck(
   699     sresult == 10 || sresult == 11 || sresult == 12,
   700     "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
   701 
   702   /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
   703   sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 13, SDL_TRUE);
   704   SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
   705   SDLTest_AssertCheck(
   706     sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
   707     "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
   708 
   709   /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
   710   sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 20, SDL_TRUE);
   711   SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
   712   SDLTest_AssertCheck(
   713     sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
   714     "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
   715 
   716   /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
   717   sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(20, 10, SDL_TRUE);
   718   SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
   719   SDLTest_AssertCheck(
   720     sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
   721     "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
   722 
   723   /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
   724   sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(1, 20, SDL_FALSE);
   725   SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
   726   SDLTest_AssertCheck(
   727     sresult == 0 || sresult == 21,
   728     "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
   729 
   730   /* RandomSintXBoundaryValue(SHRT_MIN, 99, SDL_FALSE) returns 100 */
   731   sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, 99, SDL_FALSE);
   732   SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
   733   SDLTest_AssertCheck(
   734     sresult == 100,
   735     "Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
   736 
   737   /* RandomSintXBoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE) returns SHRT_MIN (no error) */
   738   sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE);
   739   SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
   740   SDLTest_AssertCheck(
   741     sresult == SHRT_MIN,
   742     "Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %lld", SHRT_MIN, sresult);
   743   lastError = (char *)SDL_GetError();
   744   SDLTest_AssertPass("SDL_GetError()");
   745   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   746 
   747   /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE) returns SHRT_MAX (no error) */
   748   sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE);
   749   SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
   750   SDLTest_AssertCheck(
   751     sresult == SHRT_MAX,
   752     "Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SHRT_MAX, sresult);
   753   lastError = (char *)SDL_GetError();
   754   SDLTest_AssertPass("SDL_GetError()");
   755   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   756 
   757   /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE) returns 0 (sets error) */
   758   sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE);
   759   SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
   760   SDLTest_AssertCheck(
   761     sresult == SHRT_MIN,
   762     "Validate result value for parameters(SHRT_MIN,SHRT_MAX,SDL_FALSE); expected: %d, got: %lld", SHRT_MIN, sresult);
   763   lastError = (char *)SDL_GetError();
   764   SDLTest_AssertPass("SDL_GetError()");
   765   SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
   766              "SDL_GetError(): expected message '%s', was message: '%s'",
   767              expectedError,
   768              lastError);
   769 
   770   /* Clear error messages */
   771   SDL_ClearError();
   772   SDLTest_AssertPass("SDL_ClearError()");
   773 
   774   return TEST_COMPLETED;
   775 }
   776 
   777 /*
   778  * @brief Calls to random boundary number generators for Sint32
   779  */
   780 int
   781 sdltest_randomBoundaryNumberSint32(void *arg)
   782 {
   783   const char *expectedError = "That operation is not supported";
   784   char *lastError;
   785   Sint64 sresult;
   786 #if ((ULONG_MAX) == (UINT_MAX))
   787   Sint32 long_min = LONG_MIN;
   788   Sint32 long_max = LONG_MAX;
   789 #else
   790   Sint32 long_min = INT_MIN;
   791   Sint32 long_max = INT_MAX;
   792 #endif
   793 
   794   /* Clean error messages */
   795   SDL_ClearError();
   796   SDLTest_AssertPass("SDL_ClearError()");
   797 
   798   /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
   799   sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 10, SDL_TRUE);
   800   SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
   801   SDLTest_AssertCheck(
   802     sresult == 10,
   803     "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
   804 
   805   /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
   806   sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 11, SDL_TRUE);
   807   SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
   808   SDLTest_AssertCheck(
   809     sresult == 10 || sresult == 11,
   810     "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
   811 
   812   /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
   813   sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 12, SDL_TRUE);
   814   SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
   815   SDLTest_AssertCheck(
   816     sresult == 10 || sresult == 11 || sresult == 12,
   817     "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
   818 
   819   /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
   820   sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 13, SDL_TRUE);
   821   SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
   822   SDLTest_AssertCheck(
   823     sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
   824     "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
   825 
   826   /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
   827   sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 20, SDL_TRUE);
   828   SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
   829   SDLTest_AssertCheck(
   830     sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
   831     "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
   832 
   833   /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
   834   sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(20, 10, SDL_TRUE);
   835   SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
   836   SDLTest_AssertCheck(
   837     sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
   838     "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
   839 
   840   /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
   841   sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(1, 20, SDL_FALSE);
   842   SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
   843   SDLTest_AssertCheck(
   844     sresult == 0 || sresult == 21,
   845     "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
   846 
   847   /* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */
   848   sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, 99, SDL_FALSE);
   849   SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
   850   SDLTest_AssertCheck(
   851     sresult == 100,
   852     "Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
   853 
   854   /* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */
   855   sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min + 1, long_max, SDL_FALSE);
   856   SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
   857   SDLTest_AssertCheck(
   858     sresult == long_min,
   859     "Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", long_min, sresult);
   860   lastError = (char *)SDL_GetError();
   861   SDLTest_AssertPass("SDL_GetError()");
   862   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   863 
   864   /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE) returns LONG_MAX (no error) */
   865   sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max - 1, SDL_FALSE);
   866   SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
   867   SDLTest_AssertCheck(
   868     sresult == long_max,
   869     "Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %lld", long_max, sresult);
   870   lastError = (char *)SDL_GetError();
   871   SDLTest_AssertPass("SDL_GetError()");
   872   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   873 
   874   /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE) returns 0 (sets error) */
   875   sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max, SDL_FALSE);
   876   SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
   877   SDLTest_AssertCheck(
   878     sresult == long_min,
   879     "Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", long_min, sresult);
   880   lastError = (char *)SDL_GetError();
   881   SDLTest_AssertPass("SDL_GetError()");
   882   SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
   883              "SDL_GetError(): expected message '%s', was message: '%s'",
   884              expectedError,
   885              lastError);
   886 
   887   /* Clear error messages */
   888   SDL_ClearError();
   889   SDLTest_AssertPass("SDL_ClearError()");
   890 
   891   return TEST_COMPLETED;
   892 }
   893 
   894 /*
   895  * @brief Calls to random boundary number generators for Sint64
   896  */
   897 int
   898 sdltest_randomBoundaryNumberSint64(void *arg)
   899 {
   900   const char *expectedError = "That operation is not supported";
   901   char *lastError;
   902   Sint64 sresult;
   903 
   904   /* Clean error messages */
   905   SDL_ClearError();
   906   SDLTest_AssertPass("SDL_ClearError()");
   907 
   908   /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
   909   sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 10, SDL_TRUE);
   910   SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
   911   SDLTest_AssertCheck(
   912     sresult == 10,
   913     "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
   914 
   915   /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
   916   sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE);
   917   SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
   918   SDLTest_AssertCheck(
   919     sresult == 10 || sresult == 11,
   920     "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
   921 
   922   /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
   923   sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE);
   924   SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
   925   SDLTest_AssertCheck(
   926     sresult == 10 || sresult == 11 || sresult == 12,
   927     "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
   928 
   929   /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
   930   sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE);
   931   SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
   932   SDLTest_AssertCheck(
   933     sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
   934     "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
   935 
   936   /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
   937   sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE);
   938   SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
   939   SDLTest_AssertCheck(
   940     sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
   941     "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
   942 
   943   /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
   944   sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE);
   945   SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
   946   SDLTest_AssertCheck(
   947     sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
   948     "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
   949 
   950   /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
   951   sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE);
   952   SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
   953   SDLTest_AssertCheck(
   954     sresult == 0 || sresult == 21,
   955     "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
   956 
   957   /* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */
   958   sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, 99, SDL_FALSE);
   959   SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
   960   SDLTest_AssertCheck(
   961     sresult == 100,
   962     "Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
   963 
   964   /* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */
   965   sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE);
   966   SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
   967   SDLTest_AssertCheck(
   968     sresult == LLONG_MIN,
   969     "Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %lld, got: %lld", LLONG_MIN, sresult);
   970   lastError = (char *)SDL_GetError();
   971   SDLTest_AssertPass("SDL_GetError()");
   972   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   973 
   974   /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */
   975   sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE);
   976   SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
   977   SDLTest_AssertCheck(
   978     sresult == LLONG_MAX,
   979     "Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %lld, got: %lld", LLONG_MAX, sresult);
   980   lastError = (char *)SDL_GetError();
   981   SDLTest_AssertPass("SDL_GetError()");
   982   SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
   983 
   984   /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */
   985   sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE);
   986   SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
   987   SDLTest_AssertCheck(
   988     sresult == LLONG_MIN,
   989     "Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %lld, got: %lld", LLONG_MIN, sresult);
   990   lastError = (char *)SDL_GetError();
   991   SDLTest_AssertPass("SDL_GetError()");
   992   SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
   993              "SDL_GetError(): expected message '%s', was message: '%s'",
   994              expectedError,
   995              lastError);
   996 
   997   /* Clear error messages */
   998   SDL_ClearError();
   999   SDLTest_AssertPass("SDL_ClearError()");
  1000 
  1001   return TEST_COMPLETED;
  1002 }
  1003 
  1004 /**
  1005  * @brief Calls to SDLTest_RandomIntegerInRange
  1006  */
  1007 int
  1008 sdltest_randomIntegerInRange(void *arg)
  1009 {
  1010   Sint32 min, max;
  1011   Sint32 result;
  1012 #if ((ULONG_MAX) == (UINT_MAX))
  1013   Sint32 long_min = LONG_MIN;
  1014   Sint32 long_max = LONG_MAX;
  1015 #else
  1016   Sint32 long_min = INT_MIN;
  1017   Sint32 long_max = INT_MAX;
  1018 #endif
  1019 
  1020   /* Standard range */
  1021   min = (Sint32)SDLTest_RandomSint16();
  1022   max = min + (Sint32)SDLTest_RandomUint8() + 2;
  1023   result = SDLTest_RandomIntegerInRange(min, max);
  1024   SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,max)");
  1025   SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
  1026 
  1027   /* One Range */
  1028   min = (Sint32)SDLTest_RandomSint16();
  1029   max = min + 1;
  1030   result = SDLTest_RandomIntegerInRange(min, max);
  1031   SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,min+1)");
  1032   SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
  1033 
  1034   /* Zero range */
  1035   min = (Sint32)SDLTest_RandomSint16();
  1036   max = min;
  1037   result = SDLTest_RandomIntegerInRange(min, max);
  1038   SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,min)");
  1039   SDLTest_AssertCheck(min == result, "Validated returned value; expected: %d, got: %d", min, result);
  1040 
  1041   /* Zero range at zero */
  1042   min = 0;
  1043   max = 0;
  1044   result = SDLTest_RandomIntegerInRange(min, max);
  1045   SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(0,0)");
  1046   SDLTest_AssertCheck(result == 0, "Validated returned value; expected: 0, got: %d", min, max, result);
  1047 
  1048   /* Swapped min-max */
  1049   min = (Sint32)SDLTest_RandomSint16();
  1050   max = min + (Sint32)SDLTest_RandomUint8() + 2;
  1051   result = SDLTest_RandomIntegerInRange(max, min);
  1052   SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(max,min)");
  1053   SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
  1054 
  1055   /* Range with min at integer limit */
  1056   min = long_min;
  1057   max = long_max + (Sint32)SDLTest_RandomSint16();
  1058   result = SDLTest_RandomIntegerInRange(min, max);
  1059   SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,...)");
  1060   SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
  1061 
  1062   /* Range with max at integer limit */
  1063   min = long_min - (Sint32)SDLTest_RandomSint16();;
  1064   max = long_max;
  1065   result = SDLTest_RandomIntegerInRange(min, max);
  1066   SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(...,SINT32_MAX)");
  1067   SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
  1068 
  1069   /* Full integer range */
  1070   min = long_min;
  1071   max = long_max;
  1072   result = SDLTest_RandomIntegerInRange(min, max);
  1073   SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,SINT32_MAX)");
  1074   SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
  1075 
  1076   return TEST_COMPLETED;
  1077 }
  1078 
  1079 /**
  1080  * @brief Calls to SDLTest_RandomAsciiString
  1081  */
  1082 int
  1083 sdltest_randomAsciiString(void *arg)
  1084 {
  1085   char* result;
  1086   int len;
  1087   int nonAsciiCharacters;
  1088   int i;
  1089 
  1090   result = SDLTest_RandomAsciiString();
  1091   SDLTest_AssertPass("Call to SDLTest_RandomAsciiString()");
  1092   SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL");
  1093   if (result != NULL) {
  1094      len = SDL_strlen(result);
  1095      SDLTest_AssertCheck(len >= 0 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", len);
  1096      nonAsciiCharacters = 0;
  1097      for (i=0; i<len; i++) {
  1098        if (iscntrl(result[i])) {
  1099          nonAsciiCharacters++;
  1100        }
  1101      }
  1102      SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters);
  1103      if (nonAsciiCharacters) {
  1104         SDLTest_LogError("Invalid result from generator: '%s'", result);
  1105      }
  1106      SDL_free(result);
  1107   }
  1108 
  1109   return TEST_COMPLETED;
  1110 }
  1111 
  1112 
  1113 /**
  1114  * @brief Calls to SDLTest_RandomAsciiStringWithMaximumLength
  1115  */
  1116 int
  1117 sdltest_randomAsciiStringWithMaximumLength(void *arg)
  1118 {
  1119   const char* expectedError = "Parameter 'maxLength' is invalid";
  1120   char* lastError;
  1121   char* result;
  1122   int targetLen;
  1123   int len;
  1124   int nonAsciiCharacters;
  1125   int i;
  1126 
  1127   targetLen = 16 + SDLTest_RandomUint8();
  1128   result = SDLTest_RandomAsciiStringWithMaximumLength(targetLen);
  1129   SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", targetLen);
  1130   SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL");
  1131   if (result != NULL) {
  1132      len = SDL_strlen(result);
  1133      SDLTest_AssertCheck(len >= 0 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", targetLen, len);
  1134      nonAsciiCharacters = 0;
  1135      for (i=0; i<len; i++) {
  1136        if (iscntrl(result[i])) {
  1137          nonAsciiCharacters++;
  1138        }
  1139      }
  1140      SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters);
  1141      if (nonAsciiCharacters) {
  1142         SDLTest_LogError("Invalid result from generator: '%s'", result);
  1143      }
  1144      SDL_free(result);
  1145   }
  1146 
  1147   /* Negative test */
  1148   targetLen = 0;
  1149   result = SDLTest_RandomAsciiStringWithMaximumLength(targetLen);
  1150   SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", targetLen);
  1151   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1152   lastError = (char *)SDL_GetError();
  1153   SDLTest_AssertPass("SDL_GetError()");
  1154   SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
  1155              "SDL_GetError(): expected message '%s', was message: '%s'",
  1156              expectedError,
  1157              lastError);
  1158 
  1159   /* Clear error messages */
  1160   SDL_ClearError();
  1161   SDLTest_AssertPass("SDL_ClearError()");
  1162 
  1163   return TEST_COMPLETED;
  1164 }
  1165 
  1166 /**
  1167  * @brief Calls to SDLTest_RandomAsciiStringOfSize
  1168  */
  1169 int
  1170 sdltest_randomAsciiStringOfSize(void *arg)
  1171 {
  1172   const char* expectedError = "Parameter 'size' is invalid";
  1173   char* lastError;
  1174   char* result;
  1175   int targetLen;
  1176   int len;
  1177   int nonAsciiCharacters;
  1178   int i;
  1179 
  1180   /* Positive test */
  1181   targetLen = 16 + SDLTest_RandomUint8();
  1182   result = SDLTest_RandomAsciiStringOfSize(targetLen);
  1183   SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringOfSize(%d)", targetLen);
  1184   SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL");
  1185   if (result != NULL) {
  1186      len = SDL_strlen(result);
  1187      SDLTest_AssertCheck(len == targetLen, "Validate that result length; expected: len=%d, got: %d", targetLen, len);
  1188      nonAsciiCharacters = 0;
  1189      for (i=0; i<len; i++) {
  1190        if (iscntrl(result[i])) {
  1191          nonAsciiCharacters++;
  1192        }
  1193      }
  1194      SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-ASCII characters, got: %d", nonAsciiCharacters);
  1195      if (nonAsciiCharacters) {
  1196         SDLTest_LogError("Invalid result from generator: '%s'", result);
  1197      }
  1198      SDL_free(result);
  1199   }
  1200 
  1201   /* Negative test */
  1202   targetLen = 0;
  1203   result = SDLTest_RandomAsciiStringOfSize(targetLen);
  1204   SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringOfSize(%d)", targetLen);
  1205   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1206   lastError = (char *)SDL_GetError();
  1207   SDLTest_AssertPass("SDL_GetError()");
  1208   SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
  1209              "SDL_GetError(): expected message '%s', was message: '%s'",
  1210              expectedError,
  1211              lastError);
  1212 
  1213   /* Clear error messages */
  1214   SDL_ClearError();
  1215   SDLTest_AssertPass("SDL_ClearError()");
  1216 
  1217   return TEST_COMPLETED;
  1218 }
  1219 
  1220 
  1221 /* ================= Test References ================== */
  1222 
  1223 /* SDL_test test cases */
  1224 static const SDLTest_TestCaseReference sdltestTest1 =
  1225         { (SDLTest_TestCaseFp)sdltest_getFuzzerInvocationCount, "sdltest_getFuzzerInvocationCount", "Call to sdltest_GetFuzzerInvocationCount", TEST_ENABLED };
  1226 
  1227 static const SDLTest_TestCaseReference sdltestTest2 =
  1228         { (SDLTest_TestCaseFp)sdltest_randomNumber, "sdltest_randomNumber", "Calls to random number generators", TEST_ENABLED };
  1229 
  1230 static const SDLTest_TestCaseReference sdltestTest3 =
  1231         { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint8, "sdltest_randomBoundaryNumberUint8", "Calls to random boundary number generators for Uint8", TEST_ENABLED };
  1232 
  1233 static const SDLTest_TestCaseReference sdltestTest4 =
  1234         { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint16, "sdltest_randomBoundaryNumberUint16", "Calls to random boundary number generators for Uint16", TEST_ENABLED };
  1235 
  1236 static const SDLTest_TestCaseReference sdltestTest5 =
  1237         { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint32, "sdltest_randomBoundaryNumberUint32", "Calls to random boundary number generators for Uint32", TEST_ENABLED };
  1238 
  1239 static const SDLTest_TestCaseReference sdltestTest6 =
  1240         { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint64, "sdltest_randomBoundaryNumberUint64", "Calls to random boundary number generators for Uint64", TEST_ENABLED };
  1241 
  1242 static const SDLTest_TestCaseReference sdltestTest7 =
  1243         { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint8, "sdltest_randomBoundaryNumberSint8", "Calls to random boundary number generators for Sint8", TEST_ENABLED };
  1244 
  1245 static const SDLTest_TestCaseReference sdltestTest8 =
  1246         { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint16, "sdltest_randomBoundaryNumberSint16", "Calls to random boundary number generators for Sint16", TEST_ENABLED };
  1247 
  1248 static const SDLTest_TestCaseReference sdltestTest9 =
  1249         { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint32, "sdltest_randomBoundaryNumberSint32", "Calls to random boundary number generators for Sint32", TEST_ENABLED };
  1250 
  1251 static const SDLTest_TestCaseReference sdltestTest10 =
  1252         { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint64, "sdltest_randomBoundaryNumberSint64", "Calls to random boundary number generators for Sint64", TEST_ENABLED };
  1253 
  1254 static const SDLTest_TestCaseReference sdltestTest11 =
  1255         { (SDLTest_TestCaseFp)sdltest_randomIntegerInRange, "sdltest_randomIntegerInRange", "Calls to ranged random number generator", TEST_ENABLED };
  1256 
  1257 static const SDLTest_TestCaseReference sdltestTest12 =
  1258         { (SDLTest_TestCaseFp)sdltest_randomAsciiString, "sdltest_randomAsciiString", "Calls to default ASCII string generator", TEST_ENABLED };
  1259 
  1260 static const SDLTest_TestCaseReference sdltestTest13 =
  1261         { (SDLTest_TestCaseFp)sdltest_randomAsciiStringWithMaximumLength, "sdltest_randomAsciiStringWithMaximumLength", "Calls to random maximum length ASCII string generator", TEST_ENABLED };
  1262 
  1263 static const SDLTest_TestCaseReference sdltestTest14 =
  1264         { (SDLTest_TestCaseFp)sdltest_randomAsciiStringOfSize, "sdltest_randomAsciiStringOfSize", "Calls to fixed size ASCII string generator", TEST_ENABLED };
  1265 
  1266 /* Sequence of SDL_test test cases */
  1267 static const SDLTest_TestCaseReference *sdltestTests[] =  {
  1268     &sdltestTest1, &sdltestTest2, &sdltestTest3, &sdltestTest4, &sdltestTest5, &sdltestTest6,
  1269     &sdltestTest7, &sdltestTest8, &sdltestTest9, &sdltestTest10, &sdltestTest11, &sdltestTest12,
  1270     &sdltestTest13, &sdltestTest14, NULL
  1271 };
  1272 
  1273 /* SDL_test test suite (global) */
  1274 SDLTest_TestSuiteReference sdltestTestSuite = {
  1275     "SDLtest",
  1276     NULL,
  1277     sdltestTests,
  1278     NULL
  1279 };