6 /* Visual Studio 2008 doesn't have stdint.h */
7 #if defined(_MSC_VER) && _MSC_VER <= 1500
8 #define UINT8_MAX _UI8_MAX
9 #define UINT16_MAX _UI16_MAX
10 #define UINT32_MAX _UI32_MAX
11 #define INT64_MIN _I64_MIN
12 #define INT64_MAX _I64_MAX
13 #define UINT64_MAX _UI64_MAX
25 /* Test case functions */
27 /* Forward declarations for internal harness functions */
28 extern char *SDLTest_GenerateRunSeed(const int length);
31 * @brief Calls to SDLTest_GenerateRunSeed()
34 sdltest_generateRunSeed(void *arg)
40 for (i = 1; i <= 10; i += 3) {
41 result = SDLTest_GenerateRunSeed((const int)i);
42 SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()");
43 SDLTest_AssertCheck(result != NULL, "Verify returned value is not NULL");
45 l = SDL_strlen(result);
46 SDLTest_AssertCheck(l == i, "Verify length of returned value is %d, got: %d", (int) i, (int) l);
52 for (j = -2; j <= 0; j++) {
53 result = SDLTest_GenerateRunSeed((const int)j);
54 SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()");
55 SDLTest_AssertCheck(result == NULL, "Verify returned value is not NULL");
58 return TEST_COMPLETED;
62 * @brief Calls to SDLTest_GetFuzzerInvocationCount()
65 sdltest_getFuzzerInvocationCount(void *arg)
68 int fuzzerCount1, fuzzerCount2;
70 fuzzerCount1 = SDLTest_GetFuzzerInvocationCount();
71 SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()");
72 SDLTest_AssertCheck(fuzzerCount1 >= 0, "Verify returned value, expected: >=0, got: %d", fuzzerCount1);
74 result = SDLTest_RandomUint8();
75 SDLTest_AssertPass("Call to SDLTest_RandomUint8(), returned %d", result);
77 fuzzerCount2 = SDLTest_GetFuzzerInvocationCount();
78 SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()");
79 SDLTest_AssertCheck(fuzzerCount2 > fuzzerCount1, "Verify returned value, expected: >%d, got: %d", fuzzerCount1, fuzzerCount2);
81 return TEST_COMPLETED;
86 * @brief Calls to random number generators
89 sdltest_randomNumber(void *arg)
97 result = (Sint64)SDLTest_RandomUint8();
99 SDLTest_AssertPass("Call to SDLTest_RandomUint8");
100 SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result);
102 result = (Sint64)SDLTest_RandomSint8();
105 SDLTest_AssertPass("Call to SDLTest_RandomSint8");
106 SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result);
108 result = (Sint64)SDLTest_RandomUint16();
109 umax = (1 << 16) - 1;
110 SDLTest_AssertPass("Call to SDLTest_RandomUint16");
111 SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result);
113 result = (Sint64)SDLTest_RandomSint16();
116 SDLTest_AssertPass("Call to SDLTest_RandomSint16");
117 SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result);
119 result = (Sint64)SDLTest_RandomUint32();
120 umax = ((Uint64)1 << 32) - 1;
121 SDLTest_AssertPass("Call to SDLTest_RandomUint32");
122 SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result);
124 result = (Sint64)SDLTest_RandomSint32();
125 min = 0 - ((Sint64)1 << 31);
126 max = ((Sint64)1 << 31) - 1;
127 SDLTest_AssertPass("Call to SDLTest_RandomSint32");
128 SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result);
130 uresult = SDLTest_RandomUint64();
131 SDLTest_AssertPass("Call to SDLTest_RandomUint64");
133 result = SDLTest_RandomSint64();
134 SDLTest_AssertPass("Call to SDLTest_RandomSint64");
136 dresult = (double)SDLTest_RandomUnitFloat();
137 SDLTest_AssertPass("Call to SDLTest_RandomUnitFloat");
138 SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult);
140 dresult = (double)SDLTest_RandomFloat();
141 SDLTest_AssertPass("Call to SDLTest_RandomFloat");
142 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);
144 dresult = (double)SDLTest_RandomUnitDouble();
145 SDLTest_AssertPass("Call to SDLTest_RandomUnitDouble");
146 SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult);
148 dresult = SDLTest_RandomDouble();
149 SDLTest_AssertPass("Call to SDLTest_RandomDouble");
151 return TEST_COMPLETED;
155 * @brief Calls to random boundary number generators for Uint8
158 sdltest_randomBoundaryNumberUint8(void *arg)
160 const char *expectedError = "That operation is not supported";
164 /* Clean error messages */
166 SDLTest_AssertPass("SDL_ClearError()");
168 /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
169 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 10, SDL_TRUE);
170 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
173 "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
175 /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
176 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 11, SDL_TRUE);
177 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
179 uresult == 10 || uresult == 11,
180 "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
182 /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
183 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 12, SDL_TRUE);
184 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
186 uresult == 10 || uresult == 11 || uresult == 12,
187 "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
189 /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
190 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 13, SDL_TRUE);
191 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
193 uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
194 "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
196 /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
197 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 20, SDL_TRUE);
198 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
200 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
201 "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
203 /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
204 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(20, 10, SDL_TRUE);
205 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
207 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
208 "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
210 /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
211 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 20, SDL_FALSE);
212 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
214 uresult == 0 || uresult == 21,
215 "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
217 /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
218 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 99, SDL_FALSE);
219 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
222 "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
224 /* RandomUintXBoundaryValue(1, 0xff, SDL_FALSE) returns 0 (no error) */
225 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 255, SDL_FALSE);
226 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
229 "Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
230 lastError = (char *)SDL_GetError();
231 SDLTest_AssertPass("SDL_GetError()");
232 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
234 /* RandomUintXBoundaryValue(0, 0xfe, SDL_FALSE) returns 0xff (no error) */
235 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 254, SDL_FALSE);
236 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
239 "Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %"SDL_PRIs64, uresult);
240 lastError = (char *)SDL_GetError();
241 SDLTest_AssertPass("SDL_GetError()");
242 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
244 /* RandomUintXBoundaryValue(0, 0xff, SDL_FALSE) returns 0 (sets error) */
245 uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 255, SDL_FALSE);
246 SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
249 "Validate result value for parameters(0,255,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
250 lastError = (char *)SDL_GetError();
251 SDLTest_AssertPass("SDL_GetError()");
252 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
253 "SDL_GetError(): expected message '%s', was message: '%s'",
257 /* Clear error messages */
259 SDLTest_AssertPass("SDL_ClearError()");
261 return TEST_COMPLETED;
265 * @brief Calls to random boundary number generators for Uint16
268 sdltest_randomBoundaryNumberUint16(void *arg)
270 const char *expectedError = "That operation is not supported";
274 /* Clean error messages */
276 SDLTest_AssertPass("SDL_ClearError()");
278 /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
279 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 10, SDL_TRUE);
280 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
283 "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
285 /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
286 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 11, SDL_TRUE);
287 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
289 uresult == 10 || uresult == 11,
290 "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
292 /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
293 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 12, SDL_TRUE);
294 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
296 uresult == 10 || uresult == 11 || uresult == 12,
297 "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
299 /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
300 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 13, SDL_TRUE);
301 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
303 uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
304 "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
306 /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
307 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 20, SDL_TRUE);
308 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
310 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
311 "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
313 /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
314 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(20, 10, SDL_TRUE);
315 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
317 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
318 "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
320 /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
321 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 20, SDL_FALSE);
322 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
324 uresult == 0 || uresult == 21,
325 "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
327 /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
328 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 99, SDL_FALSE);
329 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
332 "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
334 /* RandomUintXBoundaryValue(1, 0xffff, SDL_FALSE) returns 0 (no error) */
335 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 0xffff, SDL_FALSE);
336 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
339 "Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
340 lastError = (char *)SDL_GetError();
341 SDLTest_AssertPass("SDL_GetError()");
342 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
344 /* RandomUintXBoundaryValue(0, 0xfffe, SDL_FALSE) returns 0xffff (no error) */
345 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xfffe, SDL_FALSE);
346 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
349 "Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %"SDL_PRIs64, uresult);
350 lastError = (char *)SDL_GetError();
351 SDLTest_AssertPass("SDL_GetError()");
352 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
354 /* RandomUintXBoundaryValue(0, 0xffff, SDL_FALSE) returns 0 (sets error) */
355 uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xffff, SDL_FALSE);
356 SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
359 "Validate result value for parameters(0,0xffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
360 lastError = (char *)SDL_GetError();
361 SDLTest_AssertPass("SDL_GetError()");
362 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
363 "SDL_GetError(): expected message '%s', was message: '%s'",
367 /* Clear error messages */
369 SDLTest_AssertPass("SDL_ClearError()");
371 return TEST_COMPLETED;
375 * @brief Calls to random boundary number generators for Uint32
378 sdltest_randomBoundaryNumberUint32(void *arg)
380 const char *expectedError = "That operation is not supported";
384 /* Clean error messages */
386 SDLTest_AssertPass("SDL_ClearError()");
388 /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
389 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 10, SDL_TRUE);
390 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
393 "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
395 /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
396 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 11, SDL_TRUE);
397 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
399 uresult == 10 || uresult == 11,
400 "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
402 /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
403 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 12, SDL_TRUE);
404 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
406 uresult == 10 || uresult == 11 || uresult == 12,
407 "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
409 /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
410 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 13, SDL_TRUE);
411 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
413 uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
414 "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
416 /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
417 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 20, SDL_TRUE);
418 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
420 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
421 "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
423 /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
424 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(20, 10, SDL_TRUE);
425 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
427 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
428 "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
430 /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
431 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 20, SDL_FALSE);
432 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
434 uresult == 0 || uresult == 21,
435 "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
437 /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
438 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 99, SDL_FALSE);
439 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
442 "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
444 /* RandomUintXBoundaryValue(1, 0xffffffff, SDL_FALSE) returns 0 (no error) */
445 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 0xffffffff, SDL_FALSE);
446 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
449 "Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
450 lastError = (char *)SDL_GetError();
451 SDLTest_AssertPass("SDL_GetError()");
452 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
454 /* RandomUintXBoundaryValue(0, 0xfffffffe, SDL_FALSE) returns 0xffffffff (no error) */
455 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xfffffffe, SDL_FALSE);
456 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
458 uresult == 0xffffffff,
459 "Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %"SDL_PRIs64, uresult);
460 lastError = (char *)SDL_GetError();
461 SDLTest_AssertPass("SDL_GetError()");
462 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
464 /* RandomUintXBoundaryValue(0, 0xffffffff, SDL_FALSE) returns 0 (sets error) */
465 uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xffffffff, SDL_FALSE);
466 SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
469 "Validate result value for parameters(0,0xffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
470 lastError = (char *)SDL_GetError();
471 SDLTest_AssertPass("SDL_GetError()");
472 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
473 "SDL_GetError(): expected message '%s', was message: '%s'",
477 /* Clear error messages */
479 SDLTest_AssertPass("SDL_ClearError()");
481 return TEST_COMPLETED;
485 * @brief Calls to random boundary number generators for Uint64
488 sdltest_randomBoundaryNumberUint64(void *arg)
490 const char *expectedError = "That operation is not supported";
494 /* Clean error messages */
496 SDLTest_AssertPass("SDL_ClearError()");
498 /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
499 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 10, SDL_TRUE);
500 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
503 "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
505 /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
506 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE);
507 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
509 uresult == 10 || uresult == 11,
510 "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
512 /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
513 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE);
514 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
516 uresult == 10 || uresult == 11 || uresult == 12,
517 "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
519 /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
520 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE);
521 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
523 uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
524 "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
526 /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
527 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE);
528 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
530 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
531 "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
533 /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
534 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE);
535 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
537 uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
538 "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
540 /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
541 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE);
542 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
544 uresult == 0 || uresult == 21,
545 "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
547 /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
548 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE);
549 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
552 "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
554 /* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */
555 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
556 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
559 "Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
560 lastError = (char *)SDL_GetError();
561 SDLTest_AssertPass("SDL_GetError()");
562 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
564 /* RandomUintXBoundaryValue(0, 0xfffffffffffffffe, SDL_FALSE) returns 0xffffffffffffffff (no error) */
565 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xfffffffffffffffeULL, SDL_FALSE);
566 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
568 uresult == (Uint64)0xffffffffffffffffULL,
569 "Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %"SDL_PRIs64, uresult);
570 lastError = (char *)SDL_GetError();
571 SDLTest_AssertPass("SDL_GetError()");
572 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
574 /* RandomUintXBoundaryValue(0, 0xffffffffffffffff, SDL_FALSE) returns 0 (sets error) */
575 uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
576 SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
579 "Validate result value for parameters(0,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
580 lastError = (char *)SDL_GetError();
581 SDLTest_AssertPass("SDL_GetError()");
582 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
583 "SDL_GetError(): expected message '%s', was message: '%s'",
587 /* Clear error messages */
589 SDLTest_AssertPass("SDL_ClearError()");
591 return TEST_COMPLETED;
595 * @brief Calls to random boundary number generators for Sint8
598 sdltest_randomBoundaryNumberSint8(void *arg)
600 const char *expectedError = "That operation is not supported";
604 /* Clean error messages */
606 SDLTest_AssertPass("SDL_ClearError()");
608 /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
609 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 10, SDL_TRUE);
610 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
613 "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
615 /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
616 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 11, SDL_TRUE);
617 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
619 sresult == 10 || sresult == 11,
620 "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
622 /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
623 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 12, SDL_TRUE);
624 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
626 sresult == 10 || sresult == 11 || sresult == 12,
627 "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult);
629 /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
630 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 13, SDL_TRUE);
631 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
633 sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
634 "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult);
636 /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
637 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 20, SDL_TRUE);
638 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
640 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
641 "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
643 /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
644 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(20, 10, SDL_TRUE);
645 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
647 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
648 "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
650 /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
651 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(1, 20, SDL_FALSE);
652 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
654 sresult == 0 || sresult == 21,
655 "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
657 /* RandomSintXBoundaryValue(SCHAR_MIN, 99, SDL_FALSE) returns 100 */
658 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, 99, SDL_FALSE);
659 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
662 "Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
664 /* RandomSintXBoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (no error) */
665 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE);
666 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
668 sresult == SCHAR_MIN,
669 "Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MIN, sresult);
670 lastError = (char *)SDL_GetError();
671 SDLTest_AssertPass("SDL_GetError()");
672 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
674 /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX - 1, SDL_FALSE) returns SCHAR_MAX (no error) */
675 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX -1, SDL_FALSE);
676 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
678 sresult == SCHAR_MAX,
679 "Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MAX, sresult);
680 lastError = (char *)SDL_GetError();
681 SDLTest_AssertPass("SDL_GetError()");
682 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
684 /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (sets error) */
685 sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE);
686 SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
688 sresult == SCHAR_MIN,
689 "Validate result value for parameters(SCHAR_MIN,SCHAR_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MIN, sresult);
690 lastError = (char *)SDL_GetError();
691 SDLTest_AssertPass("SDL_GetError()");
692 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
693 "SDL_GetError(): expected message '%s', was message: '%s'",
697 /* Clear error messages */
699 SDLTest_AssertPass("SDL_ClearError()");
701 return TEST_COMPLETED;
705 * @brief Calls to random boundary number generators for Sint16
708 sdltest_randomBoundaryNumberSint16(void *arg)
710 const char *expectedError = "That operation is not supported";
714 /* Clean error messages */
716 SDLTest_AssertPass("SDL_ClearError()");
718 /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
719 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 10, SDL_TRUE);
720 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
723 "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
725 /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
726 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 11, SDL_TRUE);
727 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
729 sresult == 10 || sresult == 11,
730 "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
732 /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
733 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 12, SDL_TRUE);
734 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
736 sresult == 10 || sresult == 11 || sresult == 12,
737 "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult);
739 /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
740 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 13, SDL_TRUE);
741 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
743 sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
744 "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult);
746 /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
747 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 20, SDL_TRUE);
748 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
750 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
751 "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
753 /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
754 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(20, 10, SDL_TRUE);
755 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
757 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
758 "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
760 /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
761 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(1, 20, SDL_FALSE);
762 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
764 sresult == 0 || sresult == 21,
765 "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
767 /* RandomSintXBoundaryValue(SHRT_MIN, 99, SDL_FALSE) returns 100 */
768 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, 99, SDL_FALSE);
769 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
772 "Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
774 /* RandomSintXBoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE) returns SHRT_MIN (no error) */
775 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE);
776 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
779 "Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MIN, sresult);
780 lastError = (char *)SDL_GetError();
781 SDLTest_AssertPass("SDL_GetError()");
782 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
784 /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE) returns SHRT_MAX (no error) */
785 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE);
786 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
789 "Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MAX, sresult);
790 lastError = (char *)SDL_GetError();
791 SDLTest_AssertPass("SDL_GetError()");
792 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
794 /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE) returns 0 (sets error) */
795 sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE);
796 SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
799 "Validate result value for parameters(SHRT_MIN,SHRT_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MIN, sresult);
800 lastError = (char *)SDL_GetError();
801 SDLTest_AssertPass("SDL_GetError()");
802 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
803 "SDL_GetError(): expected message '%s', was message: '%s'",
807 /* Clear error messages */
809 SDLTest_AssertPass("SDL_ClearError()");
811 return TEST_COMPLETED;
815 * @brief Calls to random boundary number generators for Sint32
818 sdltest_randomBoundaryNumberSint32(void *arg)
820 const char *expectedError = "That operation is not supported";
823 #if ((ULONG_MAX) == (UINT_MAX))
824 Sint32 long_min = LONG_MIN;
825 Sint32 long_max = LONG_MAX;
827 Sint32 long_min = INT_MIN;
828 Sint32 long_max = INT_MAX;
831 /* Clean error messages */
833 SDLTest_AssertPass("SDL_ClearError()");
835 /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
836 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 10, SDL_TRUE);
837 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
840 "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
842 /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
843 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 11, SDL_TRUE);
844 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
846 sresult == 10 || sresult == 11,
847 "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
849 /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
850 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 12, SDL_TRUE);
851 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
853 sresult == 10 || sresult == 11 || sresult == 12,
854 "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult);
856 /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
857 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 13, SDL_TRUE);
858 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
860 sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
861 "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult);
863 /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
864 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 20, SDL_TRUE);
865 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
867 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
868 "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
870 /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
871 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(20, 10, SDL_TRUE);
872 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
874 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
875 "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
877 /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
878 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(1, 20, SDL_FALSE);
879 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
881 sresult == 0 || sresult == 21,
882 "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
884 /* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */
885 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, 99, SDL_FALSE);
886 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
889 "Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
891 /* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */
892 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min + 1, long_max, SDL_FALSE);
893 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
896 "Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_min, sresult);
897 lastError = (char *)SDL_GetError();
898 SDLTest_AssertPass("SDL_GetError()");
899 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
901 /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE) returns LONG_MAX (no error) */
902 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max - 1, SDL_FALSE);
903 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
906 "Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_max, sresult);
907 lastError = (char *)SDL_GetError();
908 SDLTest_AssertPass("SDL_GetError()");
909 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
911 /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE) returns 0 (sets error) */
912 sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max, SDL_FALSE);
913 SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
916 "Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_min, sresult);
917 lastError = (char *)SDL_GetError();
918 SDLTest_AssertPass("SDL_GetError()");
919 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
920 "SDL_GetError(): expected message '%s', was message: '%s'",
924 /* Clear error messages */
926 SDLTest_AssertPass("SDL_ClearError()");
928 return TEST_COMPLETED;
932 * @brief Calls to random boundary number generators for Sint64
935 sdltest_randomBoundaryNumberSint64(void *arg)
937 const char *expectedError = "That operation is not supported";
941 /* Clean error messages */
943 SDLTest_AssertPass("SDL_ClearError()");
945 /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
946 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 10, SDL_TRUE);
947 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
950 "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
952 /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
953 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE);
954 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
956 sresult == 10 || sresult == 11,
957 "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
959 /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
960 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE);
961 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
963 sresult == 10 || sresult == 11 || sresult == 12,
964 "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult);
966 /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
967 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE);
968 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
970 sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
971 "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult);
973 /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
974 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE);
975 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
977 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
978 "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
980 /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
981 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE);
982 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
984 sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
985 "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
987 /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
988 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE);
989 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
991 sresult == 0 || sresult == 21,
992 "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
994 /* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */
995 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, 99, SDL_FALSE);
996 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
999 "Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
1001 /* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */
1002 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN + 1, INT64_MAX, SDL_FALSE);
1003 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
1004 SDLTest_AssertCheck(
1005 sresult == INT64_MIN,
1006 "Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MIN, sresult);
1007 lastError = (char *)SDL_GetError();
1008 SDLTest_AssertPass("SDL_GetError()");
1009 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
1011 /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */
1012 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX - 1, SDL_FALSE);
1013 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
1014 SDLTest_AssertCheck(
1015 sresult == INT64_MAX,
1016 "Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MAX, sresult);
1017 lastError = (char *)SDL_GetError();
1018 SDLTest_AssertPass("SDL_GetError()");
1019 SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
1021 /* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */
1022 sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX, SDL_FALSE);
1023 SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
1024 SDLTest_AssertCheck(
1025 sresult == INT64_MIN,
1026 "Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %"SDL_PRIs64", got: %"SDL_PRIs64, INT64_MIN, sresult);
1027 lastError = (char *)SDL_GetError();
1028 SDLTest_AssertPass("SDL_GetError()");
1029 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
1030 "SDL_GetError(): expected message '%s', was message: '%s'",
1034 /* Clear error messages */
1036 SDLTest_AssertPass("SDL_ClearError()");
1038 return TEST_COMPLETED;
1042 * @brief Calls to SDLTest_RandomIntegerInRange
1045 sdltest_randomIntegerInRange(void *arg)
1049 #if ((ULONG_MAX) == (UINT_MAX))
1050 Sint32 long_min = LONG_MIN;
1051 Sint32 long_max = LONG_MAX;
1053 Sint32 long_min = INT_MIN;
1054 Sint32 long_max = INT_MAX;
1057 /* Standard range */
1058 min = (Sint32)SDLTest_RandomSint16();
1059 max = min + (Sint32)SDLTest_RandomUint8() + 2;
1060 result = SDLTest_RandomIntegerInRange(min, max);
1061 SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,max)");
1062 SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
1065 min = (Sint32)SDLTest_RandomSint16();
1067 result = SDLTest_RandomIntegerInRange(min, max);
1068 SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,min+1)");
1069 SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
1072 min = (Sint32)SDLTest_RandomSint16();
1074 result = SDLTest_RandomIntegerInRange(min, max);
1075 SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(min,min)");
1076 SDLTest_AssertCheck(min == result, "Validated returned value; expected: %d, got: %d", min, result);
1078 /* Zero range at zero */
1081 result = SDLTest_RandomIntegerInRange(min, max);
1082 SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(0,0)");
1083 SDLTest_AssertCheck(result == 0, "Validated returned value; expected: 0, got: %d", result);
1085 /* Swapped min-max */
1086 min = (Sint32)SDLTest_RandomSint16();
1087 max = min + (Sint32)SDLTest_RandomUint8() + 2;
1088 result = SDLTest_RandomIntegerInRange(max, min);
1089 SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(max,min)");
1090 SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
1092 /* Range with min at integer limit */
1094 max = long_max + (Sint32)SDLTest_RandomSint16();
1095 result = SDLTest_RandomIntegerInRange(min, max);
1096 SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,...)");
1097 SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
1099 /* Range with max at integer limit */
1100 min = long_min - (Sint32)SDLTest_RandomSint16();
1102 result = SDLTest_RandomIntegerInRange(min, max);
1103 SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(...,SINT32_MAX)");
1104 SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
1106 /* Full integer range */
1109 result = SDLTest_RandomIntegerInRange(min, max);
1110 SDLTest_AssertPass("Call to SDLTest_RandomIntegerInRange(SINT32_MIN,SINT32_MAX)");
1111 SDLTest_AssertCheck(min <= result && result <= max, "Validated returned value; expected: [%d,%d], got: %d", min, max, result);
1113 return TEST_COMPLETED;
1117 * @brief Calls to SDLTest_RandomAsciiString
1120 sdltest_randomAsciiString(void *arg)
1124 int nonAsciiCharacters;
1127 result = SDLTest_RandomAsciiString();
1128 SDLTest_AssertPass("Call to SDLTest_RandomAsciiString()");
1129 SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL");
1130 if (result != NULL) {
1131 len = SDL_strlen(result);
1132 SDLTest_AssertCheck(len >= 1 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", (int) len);
1133 nonAsciiCharacters = 0;
1134 for (i=0; i<len; i++) {
1135 if (iscntrl(result[i])) {
1136 nonAsciiCharacters++;
1139 SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters);
1140 if (nonAsciiCharacters) {
1141 SDLTest_LogError("Invalid result from generator: '%s'", result);
1146 return TEST_COMPLETED;
1151 * @brief Calls to SDLTest_RandomAsciiStringWithMaximumLength
1154 sdltest_randomAsciiStringWithMaximumLength(void *arg)
1156 const char* expectedError = "Parameter 'maxLength' is invalid";
1161 int nonAsciiCharacters;
1164 targetLen = 16 + SDLTest_RandomUint8();
1165 result = SDLTest_RandomAsciiStringWithMaximumLength((int) targetLen);
1166 SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", targetLen);
1167 SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL");
1168 if (result != NULL) {
1169 len = SDL_strlen(result);
1170 SDLTest_AssertCheck(len >= 1 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", (int) targetLen, (int) len);
1171 nonAsciiCharacters = 0;
1172 for (i=0; i<len; i++) {
1173 if (iscntrl(result[i])) {
1174 nonAsciiCharacters++;
1177 SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters);
1178 if (nonAsciiCharacters) {
1179 SDLTest_LogError("Invalid result from generator: '%s'", result);
1186 result = SDLTest_RandomAsciiStringWithMaximumLength((int) targetLen);
1187 SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringWithMaximumLength(%d)", targetLen);
1188 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1189 lastError = (char *)SDL_GetError();
1190 SDLTest_AssertPass("SDL_GetError()");
1191 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
1192 "SDL_GetError(): expected message '%s', was message: '%s'",
1196 /* Clear error messages */
1198 SDLTest_AssertPass("SDL_ClearError()");
1200 return TEST_COMPLETED;
1204 * @brief Calls to SDLTest_RandomAsciiStringOfSize
1207 sdltest_randomAsciiStringOfSize(void *arg)
1209 const char* expectedError = "Parameter 'size' is invalid";
1214 int nonAsciiCharacters;
1218 targetLen = 16 + SDLTest_RandomUint8();
1219 result = SDLTest_RandomAsciiStringOfSize((int) targetLen);
1220 SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringOfSize(%d)", targetLen);
1221 SDLTest_AssertCheck(result != NULL, "Validate that result is not NULL");
1222 if (result != NULL) {
1223 len = SDL_strlen(result);
1224 SDLTest_AssertCheck(len == targetLen, "Validate that result length; expected: len=%d, got: %d", (int) targetLen, (int) len);
1225 nonAsciiCharacters = 0;
1226 for (i=0; i<len; i++) {
1227 if (iscntrl(result[i])) {
1228 nonAsciiCharacters++;
1231 SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-ASCII characters, got: %d", nonAsciiCharacters);
1232 if (nonAsciiCharacters) {
1233 SDLTest_LogError("Invalid result from generator: '%s'", result);
1240 result = SDLTest_RandomAsciiStringOfSize((int) targetLen);
1241 SDLTest_AssertPass("Call to SDLTest_RandomAsciiStringOfSize(%d)", targetLen);
1242 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1243 lastError = (char *)SDL_GetError();
1244 SDLTest_AssertPass("SDL_GetError()");
1245 SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
1246 "SDL_GetError(): expected message '%s', was message: '%s'",
1250 /* Clear error messages */
1252 SDLTest_AssertPass("SDL_ClearError()");
1254 return TEST_COMPLETED;
1258 /* ================= Test References ================== */
1260 /* SDL_test test cases */
1261 static const SDLTest_TestCaseReference sdltestTest1 =
1262 { (SDLTest_TestCaseFp)sdltest_getFuzzerInvocationCount, "sdltest_getFuzzerInvocationCount", "Call to sdltest_GetFuzzerInvocationCount", TEST_ENABLED };
1264 static const SDLTest_TestCaseReference sdltestTest2 =
1265 { (SDLTest_TestCaseFp)sdltest_randomNumber, "sdltest_randomNumber", "Calls to random number generators", TEST_ENABLED };
1267 static const SDLTest_TestCaseReference sdltestTest3 =
1268 { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint8, "sdltest_randomBoundaryNumberUint8", "Calls to random boundary number generators for Uint8", TEST_ENABLED };
1270 static const SDLTest_TestCaseReference sdltestTest4 =
1271 { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint16, "sdltest_randomBoundaryNumberUint16", "Calls to random boundary number generators for Uint16", TEST_ENABLED };
1273 static const SDLTest_TestCaseReference sdltestTest5 =
1274 { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint32, "sdltest_randomBoundaryNumberUint32", "Calls to random boundary number generators for Uint32", TEST_ENABLED };
1276 static const SDLTest_TestCaseReference sdltestTest6 =
1277 { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint64, "sdltest_randomBoundaryNumberUint64", "Calls to random boundary number generators for Uint64", TEST_ENABLED };
1279 static const SDLTest_TestCaseReference sdltestTest7 =
1280 { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint8, "sdltest_randomBoundaryNumberSint8", "Calls to random boundary number generators for Sint8", TEST_ENABLED };
1282 static const SDLTest_TestCaseReference sdltestTest8 =
1283 { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint16, "sdltest_randomBoundaryNumberSint16", "Calls to random boundary number generators for Sint16", TEST_ENABLED };
1285 static const SDLTest_TestCaseReference sdltestTest9 =
1286 { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint32, "sdltest_randomBoundaryNumberSint32", "Calls to random boundary number generators for Sint32", TEST_ENABLED };
1288 static const SDLTest_TestCaseReference sdltestTest10 =
1289 { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint64, "sdltest_randomBoundaryNumberSint64", "Calls to random boundary number generators for Sint64", TEST_ENABLED };
1291 static const SDLTest_TestCaseReference sdltestTest11 =
1292 { (SDLTest_TestCaseFp)sdltest_randomIntegerInRange, "sdltest_randomIntegerInRange", "Calls to ranged random number generator", TEST_ENABLED };
1294 static const SDLTest_TestCaseReference sdltestTest12 =
1295 { (SDLTest_TestCaseFp)sdltest_randomAsciiString, "sdltest_randomAsciiString", "Calls to default ASCII string generator", TEST_ENABLED };
1297 static const SDLTest_TestCaseReference sdltestTest13 =
1298 { (SDLTest_TestCaseFp)sdltest_randomAsciiStringWithMaximumLength, "sdltest_randomAsciiStringWithMaximumLength", "Calls to random maximum length ASCII string generator", TEST_ENABLED };
1300 static const SDLTest_TestCaseReference sdltestTest14 =
1301 { (SDLTest_TestCaseFp)sdltest_randomAsciiStringOfSize, "sdltest_randomAsciiStringOfSize", "Calls to fixed size ASCII string generator", TEST_ENABLED };
1303 static const SDLTest_TestCaseReference sdltestTest15 =
1304 { (SDLTest_TestCaseFp)sdltest_generateRunSeed, "sdltest_generateRunSeed", "Checks internal harness function SDLTest_GenerateRunSeed", TEST_ENABLED };
1306 /* Sequence of SDL_test test cases */
1307 static const SDLTest_TestCaseReference *sdltestTests[] = {
1308 &sdltestTest1, &sdltestTest2, &sdltestTest3, &sdltestTest4, &sdltestTest5, &sdltestTest6,
1309 &sdltestTest7, &sdltestTest8, &sdltestTest9, &sdltestTest10, &sdltestTest11, &sdltestTest12,
1310 &sdltestTest13, &sdltestTest14, &sdltestTest15, NULL
1313 /* SDL_test test suite (global) */
1314 SDLTest_TestSuiteReference sdltestTestSuite = {