Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
1279 lines (1094 loc) · 57 KB

testautomation_sdltest.c

File metadata and controls

1279 lines (1094 loc) · 57 KB
 
1
2
3
4
/**
* SDL_test test suite
*/
May 12, 2013
May 12, 2013
5
6
7
8
9
10
11
12
13
/* Visual Studio 2008 doesn't have stdint.h */
#if defined(_MSC_VER) && _MSC_VER <= 1500
#define UINT8_MAX ~(Uint8)0
#define UINT16_MAX ~(Uint16)0
#define UINT32_MAX ~(Uint32)0
#define UINT64_MAX ~(Uint64)0
#else
#include <stdint.h>
#endif
14
15
16
#include <stdio.h>
#include <limits.h>
#include <float.h>
Feb 14, 2013
Feb 14, 2013
17
#include <ctype.h>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "SDL.h"
#include "SDL_test.h"
/* Test case functions */
/**
* @brief Calls to SDLTest_GetFuzzerInvocationCount()
*/
int
sdltest_getFuzzerInvocationCount(void *arg)
{
Uint8 result;
int fuzzerCount1, fuzzerCount2;
May 18, 2013
May 18, 2013
32
33
34
35
fuzzerCount1 = SDLTest_GetFuzzerInvocationCount();
SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()");
SDLTest_AssertCheck(fuzzerCount1 >= 0, "Verify returned value, expected: >=0, got: %d", fuzzerCount1);
May 18, 2013
May 18, 2013
36
37
38
39
40
41
42
result = SDLTest_RandomUint8();
SDLTest_AssertPass("Call to SDLTest_RandomUint8(), returned %d", result);
fuzzerCount2 = SDLTest_GetFuzzerInvocationCount();
SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()");
SDLTest_AssertCheck(fuzzerCount2 > fuzzerCount1, "Verify returned value, expected: >%d, got: %d", fuzzerCount1, fuzzerCount2);
May 18, 2013
May 18, 2013
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
return TEST_COMPLETED;
}
/**
* @brief Calls to random number generators
*/
int
sdltest_randomNumber(void *arg)
{
Sint64 result;
Uint64 uresult;
double dresult;
Uint64 umax;
Sint64 min, max;
May 18, 2013
May 18, 2013
59
60
61
62
result = (Sint64)SDLTest_RandomUint8();
umax = (1 << 8) - 1;
SDLTest_AssertPass("Call to SDLTest_RandomUint8");
Feb 13, 2013
Feb 13, 2013
63
SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
64
65
66
67
68
69
result = (Sint64)SDLTest_RandomSint8();
min = 1 - (1 << 7);
max = (1 << 7) - 1;
SDLTest_AssertPass("Call to SDLTest_RandomSint8");
SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
May 18, 2013
May 18, 2013
70
71
72
73
result = (Sint64)SDLTest_RandomUint16();
umax = (1 << 16) - 1;
SDLTest_AssertPass("Call to SDLTest_RandomUint16");
Feb 13, 2013
Feb 13, 2013
74
SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
75
76
77
78
79
80
81
82
83
84
result = (Sint64)SDLTest_RandomSint16();
min = 1 - (1 << 15);
max = (1 << 15) - 1;
SDLTest_AssertPass("Call to SDLTest_RandomSint16");
SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
result = (Sint64)SDLTest_RandomUint32();
umax = ((Uint64)1 << 32) - 1;
SDLTest_AssertPass("Call to SDLTest_RandomUint32");
Feb 13, 2013
Feb 13, 2013
85
SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
result = (Sint64)SDLTest_RandomSint32();
min = 1 - ((Sint64)1 << 31);
max = ((Sint64)1 << 31) - 1;
SDLTest_AssertPass("Call to SDLTest_RandomSint32");
SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
uresult = SDLTest_RandomUint64();
SDLTest_AssertPass("Call to SDLTest_RandomUint64");
result = SDLTest_RandomSint64();
SDLTest_AssertPass("Call to SDLTest_RandomSint64");
dresult = (double)SDLTest_RandomUnitFloat();
SDLTest_AssertPass("Call to SDLTest_RandomUnitFloat");
SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult);
May 18, 2013
May 18, 2013
102
103
104
105
106
107
108
109
110
111
112
dresult = (double)SDLTest_RandomFloat();
SDLTest_AssertPass("Call to SDLTest_RandomFloat");
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);
dresult = (double)SDLTest_RandomUnitDouble();
SDLTest_AssertPass("Call to SDLTest_RandomUnitDouble");
SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult);
dresult = SDLTest_RandomDouble();
SDLTest_AssertPass("Call to SDLTest_RandomDouble");
May 18, 2013
May 18, 2013
113
114
115
116
return TEST_COMPLETED;
}
Feb 13, 2013
Feb 13, 2013
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* @brief Calls to random boundary number generators for Uint8
*/
int
sdltest_randomBoundaryNumberUint8(void *arg)
{
const char *expectedError = "That operation is not supported";
char *lastError;
Uint64 uresult;
/* Clean error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
/* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10,
May 18, 2013
May 18, 2013
136
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
137
138
139
140
141
142
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11,
May 18, 2013
May 18, 2013
143
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
144
145
146
147
148
149
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12,
May 18, 2013
May 18, 2013
150
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
151
152
153
154
155
156
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
May 18, 2013
May 18, 2013
157
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
158
159
160
161
162
163
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
May 18, 2013
May 18, 2013
164
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
165
166
167
168
169
170
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
May 18, 2013
May 18, 2013
171
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
172
173
174
175
176
177
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 0 || uresult == 21,
May 18, 2013
May 18, 2013
178
179
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
180
181
182
183
184
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 100,
May 18, 2013
May 18, 2013
185
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/* RandomUintXBoundaryValue(1, 0xff, SDL_FALSE) returns 0 (no error) */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 255, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 0,
"Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xfe, SDL_FALSE) returns 0xff (no error) */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 254, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 0xff,
"Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xff, SDL_FALSE) returns 0 (sets error) */
uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 255, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
SDLTest_AssertCheck(
uresult == 0,
"Validate result value for parameters(0,255,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
expectedError,
lastError);
/* Clear error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
/*
* @brief Calls to random boundary number generators for Uint16
*/
int
sdltest_randomBoundaryNumberUint16(void *arg)
{
const char *expectedError = "That operation is not supported";
char *lastError;
Uint64 uresult;
/* Clean error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
/* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10,
May 18, 2013
May 18, 2013
246
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
247
248
249
250
251
252
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11,
May 18, 2013
May 18, 2013
253
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
254
255
256
257
258
259
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12,
May 18, 2013
May 18, 2013
260
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
261
262
263
264
265
266
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
May 18, 2013
May 18, 2013
267
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
268
269
270
271
272
273
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
May 18, 2013
May 18, 2013
274
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
275
276
277
278
279
280
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
May 18, 2013
May 18, 2013
281
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
282
283
284
285
286
287
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 0 || uresult == 21,
May 18, 2013
May 18, 2013
288
289
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
290
291
292
293
294
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 100,
May 18, 2013
May 18, 2013
295
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/* RandomUintXBoundaryValue(1, 0xffff, SDL_FALSE) returns 0 (no error) */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 0xffff, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 0,
"Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xfffe, SDL_FALSE) returns 0xffff (no error) */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xfffe, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 0xffff,
"Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xffff, SDL_FALSE) returns 0 (sets error) */
uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xffff, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
SDLTest_AssertCheck(
uresult == 0,
"Validate result value for parameters(0,0xffff,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
expectedError,
lastError);
/* Clear error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
May 18, 2013
May 18, 2013
336
Feb 13, 2013
Feb 13, 2013
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/*
* @brief Calls to random boundary number generators for Uint32
*/
int
sdltest_randomBoundaryNumberUint32(void *arg)
{
const char *expectedError = "That operation is not supported";
char *lastError;
Uint64 uresult;
/* Clean error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
/* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10,
May 18, 2013
May 18, 2013
356
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
357
358
359
360
361
362
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11,
May 18, 2013
May 18, 2013
363
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
364
365
366
367
368
369
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12,
May 18, 2013
May 18, 2013
370
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
371
372
373
374
375
376
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
May 18, 2013
May 18, 2013
377
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
378
379
380
381
382
383
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
May 18, 2013
May 18, 2013
384
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
385
386
387
388
389
390
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
May 18, 2013
May 18, 2013
391
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
392
393
394
395
396
397
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 0 || uresult == 21,
May 18, 2013
May 18, 2013
398
399
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
400
401
402
403
404
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 100,
May 18, 2013
May 18, 2013
405
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
/* RandomUintXBoundaryValue(1, 0xffffffff, SDL_FALSE) returns 0 (no error) */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 0xffffffff, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 0,
"Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xfffffffe, SDL_FALSE) returns 0xffffffff (no error) */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xfffffffe, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 0xffffffff,
"Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xffffffff, SDL_FALSE) returns 0 (sets error) */
uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xffffffff, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
SDLTest_AssertCheck(
uresult == 0,
"Validate result value for parameters(0,0xffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
expectedError,
lastError);
/* Clear error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
/*
* @brief Calls to random boundary number generators for Uint64
*/
int
sdltest_randomBoundaryNumberUint64(void *arg)
{
const char *expectedError = "That operation is not supported";
char *lastError;
Uint64 uresult;
/* Clean error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
/* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10,
May 18, 2013
May 18, 2013
466
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
467
468
469
470
471
472
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11,
May 18, 2013
May 18, 2013
473
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
474
475
476
477
478
479
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12,
May 18, 2013
May 18, 2013
480
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
481
482
483
484
485
486
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
May 18, 2013
May 18, 2013
487
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
488
489
490
491
492
493
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
May 18, 2013
May 18, 2013
494
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
495
496
497
498
499
500
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
May 18, 2013
May 18, 2013
501
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
502
503
504
505
506
507
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 0 || uresult == 21,
May 18, 2013
May 18, 2013
508
509
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
510
511
512
513
514
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 100,
May 18, 2013
May 18, 2013
515
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult);
Feb 13, 2013
Feb 13, 2013
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
/* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 0,
"Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xfffffffffffffffe, SDL_FALSE) returns 0xffffffffffffffff (no error) */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xfffffffffffffffeULL, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == (Uint64)0xffffffffffffffffULL,
"Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomUintXBoundaryValue(0, 0xffffffffffffffff, SDL_FALSE) returns 0 (sets error) */
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
SDLTest_AssertCheck(
uresult == 0,
"Validate result value for parameters(0,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %lld", uresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
expectedError,
lastError);
/* Clear error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
/*
* @brief Calls to random boundary number generators for Sint8
*/
int
sdltest_randomBoundaryNumberSint8(void *arg)
{
const char *expectedError = "That operation is not supported";
char *lastError;
Sint64 sresult;
/* Clean error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
/* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10,
May 18, 2013
May 18, 2013
576
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
577
578
579
580
581
582
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11,
May 18, 2013
May 18, 2013
583
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
584
585
586
587
588
589
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12,
May 18, 2013
May 18, 2013
590
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
591
592
593
594
595
596
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
May 18, 2013
May 18, 2013
597
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
598
599
600
601
602
603
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
May 18, 2013
May 18, 2013
604
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
605
606
607
608
609
610
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
May 18, 2013
May 18, 2013
611
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
612
613
614
615
616
617
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 0 || sresult == 21,
May 18, 2013
May 18, 2013
618
619
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
620
621
622
623
624
/* RandomSintXBoundaryValue(SCHAR_MIN, 99, SDL_FALSE) returns 100 */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == 100,
May 18, 2013
May 18, 2013
625
"Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
/* RandomSintXBoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (no error) */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == SCHAR_MIN,
"Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %lld", SCHAR_MIN, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX - 1, SDL_FALSE) returns SCHAR_MAX (no error) */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX -1, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == SCHAR_MAX,
"Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SCHAR_MAX, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (sets error) */
sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
SDLTest_AssertCheck(
sresult == SCHAR_MIN,
"Validate result value for parameters(SCHAR_MIN,SCHAR_MAX,SDL_FALSE); expected: %d, got: %lld", SCHAR_MIN, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
expectedError,
lastError);
/* Clear error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
May 18, 2013
May 18, 2013
663
Feb 13, 2013
Feb 13, 2013
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
return TEST_COMPLETED;
}
/*
* @brief Calls to random boundary number generators for Sint16
*/
int
sdltest_randomBoundaryNumberSint16(void *arg)
{
const char *expectedError = "That operation is not supported";
char *lastError;
Sint64 sresult;
/* Clean error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
/* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10,
May 18, 2013
May 18, 2013
686
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
687
688
689
690
691
692
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11,
May 18, 2013
May 18, 2013
693
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
694
695
696
697
698
699
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12,
May 18, 2013
May 18, 2013
700
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
701
702
703
704
705
706
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
May 18, 2013
May 18, 2013
707
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
708
709
710
711
712
713
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
May 18, 2013
May 18, 2013
714
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
715
716
717
718
719
720
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
May 18, 2013
May 18, 2013
721
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
722
723
724
725
726
727
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 0 || sresult == 21,
May 18, 2013
May 18, 2013
728
729
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
730
731
732
733
734
/* RandomSintXBoundaryValue(SHRT_MIN, 99, SDL_FALSE) returns 100 */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == 100,
May 18, 2013
May 18, 2013
735
"Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
/* RandomSintXBoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE) returns SHRT_MIN (no error) */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == SHRT_MIN,
"Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %lld", SHRT_MIN, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE) returns SHRT_MAX (no error) */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == SHRT_MAX,
"Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %lld", SHRT_MAX, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE) returns 0 (sets error) */
sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
SDLTest_AssertCheck(
sresult == SHRT_MIN,
"Validate result value for parameters(SHRT_MIN,SHRT_MAX,SDL_FALSE); expected: %d, got: %lld", SHRT_MIN, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
expectedError,
lastError);
/* Clear error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
May 18, 2013
May 18, 2013
776
Feb 13, 2013
Feb 13, 2013
777
778
779
780
781
782
783
784
785
/*
* @brief Calls to random boundary number generators for Sint32
*/
int
sdltest_randomBoundaryNumberSint32(void *arg)
{
const char *expectedError = "That operation is not supported";
char *lastError;
Sint64 sresult;
May 12, 2013
May 12, 2013
786
#if ((ULONG_MAX) == (UINT_MAX))
May 18, 2013
May 18, 2013
787
Sint32 long_min = LONG_MIN;
May 12, 2013
May 12, 2013
788
789
790
791
792
Sint32 long_max = LONG_MAX;
#else
Sint32 long_min = INT_MIN;
Sint32 long_max = INT_MAX;
#endif
Feb 13, 2013
Feb 13, 2013
793
794
795
796
797
798
799
800
801
802
/* Clean error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
/* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10,
May 18, 2013
May 18, 2013
803
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
804
805
806
807
808
809
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11,
May 18, 2013
May 18, 2013
810
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
811
812
813
814
815
816
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12,
May 18, 2013
May 18, 2013
817
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
818
819
820
821
822
823
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
May 18, 2013
May 18, 2013
824
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
825
826
827
828
829
830
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
May 18, 2013
May 18, 2013
831
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
832
833
834
835
836
837
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
May 18, 2013
May 18, 2013
838
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
839
840
841
842
843
844
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 0 || sresult == 21,
May 18, 2013
May 18, 2013
845
846
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
847
/* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */
May 12, 2013
May 12, 2013
848
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, 99, SDL_FALSE);
Feb 13, 2013
Feb 13, 2013
849
850
851
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
sresult == 100,
May 18, 2013
May 18, 2013
852
"Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
853
854
/* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */
May 12, 2013
May 12, 2013
855
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min + 1, long_max, SDL_FALSE);
Feb 13, 2013
Feb 13, 2013
856
857
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
May 12, 2013
May 12, 2013
858
859
sresult == long_min,
"Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", long_min, sresult);
Feb 13, 2013
Feb 13, 2013
860
861
862
863
864
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE) returns LONG_MAX (no error) */
May 12, 2013
May 12, 2013
865
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max - 1, SDL_FALSE);
Feb 13, 2013
Feb 13, 2013
866
867
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
May 12, 2013
May 12, 2013
868
869
sresult == long_max,
"Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %lld", long_max, sresult);
Feb 13, 2013
Feb 13, 2013
870
871
872
873
874
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE) returns 0 (sets error) */
May 12, 2013
May 12, 2013
875
sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max, SDL_FALSE);
Feb 13, 2013
Feb 13, 2013
876
877
SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
SDLTest_AssertCheck(
May 12, 2013
May 12, 2013
878
879
sresult == long_min,
"Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %d, got: %lld", long_min, sresult);
Feb 13, 2013
Feb 13, 2013
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
expectedError,
lastError);
/* Clear error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
return TEST_COMPLETED;
}
/*
* @brief Calls to random boundary number generators for Sint64
*/
int
sdltest_randomBoundaryNumberSint64(void *arg)
{
const char *expectedError = "That operation is not supported";
char *lastError;
Sint64 sresult;
/* Clean error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");
/* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10,
May 18, 2013
May 18, 2013
913
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
914
915
916
917
918
919
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11,
May 18, 2013
May 18, 2013
920
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
921
922
923
924
925
926
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12,
May 18, 2013
May 18, 2013
927
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
928
929
930
931
932
933
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
May 18, 2013
May 18, 2013
934
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
935
936
937
938
939
940
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
May 18, 2013
May 18, 2013
941
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
942
943
944
945
946
947
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
May 18, 2013
May 18, 2013
948
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
949
950
951
952
953
954
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 0 || sresult == 21,
May 18, 2013
May 18, 2013
955
956
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
957
958
959
960
961
/* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, 99, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == 100,
May 18, 2013
May 18, 2013
962
"Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult);
Feb 13, 2013
Feb 13, 2013
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == LLONG_MIN,
"Validate result value for parameters (LLONG_MIN+1,LLONG_MAX,SDL_FALSE); expected: %lld, got: %lld", LLONG_MIN, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == LLONG_MAX,
"Validate result value for parameters (LLONG_MIN,LLONG_MAX - 1,SDL_FALSE); expected: %lld, got: %lld", LLONG_MAX, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError == NULL || SDL_strlen(lastError) == 0, "Validate no error message was set");
/* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE);
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
SDLTest_AssertCheck(
sresult == LLONG_MIN,
"Validate result value for parameters(LLONG_MIN,LLONG_MAX,SDL_FALSE); expected: %lld, got: %lld", LLONG_MIN, sresult);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
expectedError,
lastError);
/* Clear error messages */
SDL_ClearError();
SDLTest_AssertPass("SDL_ClearError()");