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