SDL  2.0
testautomation_platform.c File Reference
#include <stdio.h>
#include "SDL.h"
#include "SDL_test.h"
+ Include dependency graph for testautomation_platform.c:

Go to the source code of this file.

Functions

static int _compareSizeOfType (size_t sizeoftype, size_t hardcodetype)
 Compare sizes of types. More...
 
int platform_testTypes (void *arg)
 Tests type sizes. More...
 
int platform_testEndianessAndSwap (void *arg)
 Tests platform endianness and SDL_SwapXY functions. More...
 
int platform_testGetFunctions (void *arg)
 
int platform_testHasFunctions (void *arg)
 
int platform_testGetVersion (void *arg)
 
int platform_testSDLVersion (void *arg)
 
int platform_testDefaultInit (void *arg)
 
int platform_testGetSetClearError (void *arg)
 
int platform_testSetErrorEmptyInput (void *arg)
 
int platform_testSetErrorInvalidInput (void *arg)
 
int platform_testGetPowerInfo (void *arg)
 

Variables

static const SDLTest_TestCaseReference platformTest1
 
static const SDLTest_TestCaseReference platformTest2
 
static const SDLTest_TestCaseReference platformTest3
 
static const SDLTest_TestCaseReference platformTest4
 
static const SDLTest_TestCaseReference platformTest5
 
static const SDLTest_TestCaseReference platformTest6
 
static const SDLTest_TestCaseReference platformTest7
 
static const SDLTest_TestCaseReference platformTest8
 
static const SDLTest_TestCaseReference platformTest9
 
static const SDLTest_TestCaseReference platformTest10
 
static const SDLTest_TestCaseReference platformTest11
 
static const SDLTest_TestCaseReferenceplatformTests []
 
SDLTest_TestSuiteReference platformTestSuite
 

Function Documentation

◆ _compareSizeOfType()

static int _compareSizeOfType ( size_t  sizeoftype,
size_t  hardcodetype 
)
static

Compare sizes of types.

Original code: automated SDL platform test written by Edgar Simo "bobbens" Extended and updated by aschiffler at ferzkopp dot net

Note
Watcom C flags these as Warning 201: "Unreachable code" if you just compare them directly, so we push it through a function to keep the compiler quiet. –ryan.

Definition at line 22 of file testautomation_platform.c.

Referenced by platform_testTypes().

23 {
24  return sizeoftype != hardcodetype;
25 }

◆ platform_testDefaultInit()

int platform_testDefaultInit ( void arg)

Definition at line 254 of file testautomation_platform.c.

References SDL_GetError, SDL_Init, SDL_INIT_EVERYTHING, SDL_WasInit, SDLTest_AssertCheck(), and TEST_COMPLETED.

255 {
256  int ret;
257  int subsystem;
258 
259  subsystem = SDL_WasInit(SDL_INIT_EVERYTHING);
260  SDLTest_AssertCheck( subsystem != 0,
261  "SDL_WasInit(0): returned %i, expected != 0",
262  subsystem);
263 
265  SDLTest_AssertCheck( ret == 0,
266  "SDL_Init(0): returned %i, expected 0, error: %s",
267  ret,
268  SDL_GetError());
269 
270  return TEST_COMPLETED;
271 }
#define SDL_GetError
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define SDL_INIT_EVERYTHING
Definition: SDL.h:84
#define TEST_COMPLETED
#define SDL_Init
#define SDL_WasInit

◆ platform_testEndianessAndSwap()

int platform_testEndianessAndSwap ( void arg)

Tests platform endianness and SDL_SwapXY functions.

Definition at line 54 of file testautomation_platform.c.

References SDL_BIG_ENDIAN, SDL_BYTEORDER, SDL_LIL_ENDIAN, SDL_PRIX64, SDL_Swap16(), SDL_Swap32(), SDL_Swap64(), SDLTest_AssertCheck(), and TEST_COMPLETED.

55 {
56  int real_byteorder;
57  Uint16 value = 0x1234;
58  Uint16 value16 = 0xCDAB;
59  Uint16 swapped16 = 0xABCD;
60  Uint32 value32 = 0xEFBEADDE;
61  Uint32 swapped32 = 0xDEADBEEF;
62 
63  Uint64 value64, swapped64;
64  value64 = 0xEFBEADDE;
65  value64 <<= 32;
66  value64 |= 0xCDAB3412;
67  swapped64 = 0x1234ABCD;
68  swapped64 <<= 32;
69  swapped64 |= 0xDEADBEEF;
70 
71  if ((*((char *) &value) >> 4) == 0x1) {
72  real_byteorder = SDL_BIG_ENDIAN;
73  } else {
74  real_byteorder = SDL_LIL_ENDIAN;
75  }
76 
77  /* Test endianness. */
78  SDLTest_AssertCheck( real_byteorder == SDL_BYTEORDER,
79  "Machine detected as %s endian, appears to be %s endian.",
80  (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big",
81  (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big" );
82 
83  /* Test 16 swap. */
84  SDLTest_AssertCheck( SDL_Swap16(value16) == swapped16,
85  "SDL_Swap16(): 16 bit swapped: 0x%X => 0x%X",
86  value16, SDL_Swap16(value16) );
87 
88  /* Test 32 swap. */
89  SDLTest_AssertCheck( SDL_Swap32(value32) == swapped32,
90  "SDL_Swap32(): 32 bit swapped: 0x%X => 0x%X",
91  value32, SDL_Swap32(value32) );
92 
93  /* Test 64 swap. */
94  SDLTest_AssertCheck( SDL_Swap64(value64) == swapped64,
95  "SDL_Swap64(): 64 bit swapped: 0x%"SDL_PRIX64" => 0x%"SDL_PRIX64,
96  value64, SDL_Swap64(value64) );
97 
98  return TEST_COMPLETED;
99 }
GLuint GLfloat GLfloat GLfloat x1
#define SDL_LIL_ENDIAN
Definition: SDL_endian.h:37
uint32_t Uint32
Definition: SDL_stdinc.h:181
uint64_t Uint64
Definition: SDL_stdinc.h:194
SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
Definition: SDL_endian.h:162
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
Definition: SDL_endian.h:107
GLsizei const GLfloat * value
#define TEST_COMPLETED
#define SDL_PRIX64
Definition: SDL_stdinc.h:238
#define SDL_BIG_ENDIAN
Definition: SDL_endian.h:38
SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x)
Definition: SDL_endian.h:196
uint16_t Uint16
Definition: SDL_stdinc.h:169
#define SDL_BYTEORDER

◆ platform_testGetFunctions()

int platform_testGetFunctions ( void arg)

Definition at line 110 of file testautomation_platform.c.

References NULL, SDL_GetCPUCacheLineSize, SDL_GetCPUCount, SDL_GetPlatform, SDL_GetRevision, SDL_GetRevisionNumber, SDL_strlen, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

111 {
112  char *platform;
113  char *revision;
114  int ret;
115  size_t len;
116 
117  platform = (char *)SDL_GetPlatform();
118  SDLTest_AssertPass("SDL_GetPlatform()");
119  SDLTest_AssertCheck(platform != NULL, "SDL_GetPlatform() != NULL");
120  if (platform != NULL) {
121  len = SDL_strlen(platform);
122  SDLTest_AssertCheck(len > 0,
123  "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i",
124  platform,
125  (int) len);
126  }
127 
128  ret = SDL_GetCPUCount();
129  SDLTest_AssertPass("SDL_GetCPUCount()");
130  SDLTest_AssertCheck(ret > 0,
131  "SDL_GetCPUCount(): expected count > 0, was: %i",
132  ret);
133 
134  ret = SDL_GetCPUCacheLineSize();
135  SDLTest_AssertPass("SDL_GetCPUCacheLineSize()");
136  SDLTest_AssertCheck(ret >= 0,
137  "SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i",
138  ret);
139 
140  revision = (char *)SDL_GetRevision();
141  SDLTest_AssertPass("SDL_GetRevision()");
142  SDLTest_AssertCheck(revision != NULL, "SDL_GetRevision() != NULL");
143 
144  ret = SDL_GetRevisionNumber();
145  SDLTest_AssertPass("SDL_GetRevisionNumber()");
146 
147  return TEST_COMPLETED;
148 }
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
GLenum GLsizei len
#define SDL_GetRevision
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define SDL_GetRevisionNumber
#define SDL_GetPlatform
#define TEST_COMPLETED
#define SDL_GetCPUCacheLineSize
#define NULL
Definition: begin_code.h:164
#define SDL_GetCPUCount
#define SDL_strlen

◆ platform_testGetPowerInfo()

int platform_testGetPowerInfo ( void arg)

Definition at line 453 of file testautomation_platform.c.

References NULL, SDL_GetPowerInfo, SDL_POWERSTATE_CHARGED, SDL_POWERSTATE_CHARGING, SDL_POWERSTATE_NO_BATTERY, SDL_POWERSTATE_ON_BATTERY, SDL_POWERSTATE_UNKNOWN, SDLTest_AssertCheck(), SDLTest_AssertPass(), state, and TEST_COMPLETED.

454 {
456  SDL_PowerState stateAgain;
457  int secs;
458  int secsAgain;
459  int pct;
460  int pctAgain;
461 
462  state = SDL_GetPowerInfo(&secs, &pct);
463  SDLTest_AssertPass("SDL_GetPowerInfo()");
465  state==SDL_POWERSTATE_UNKNOWN ||
466  state==SDL_POWERSTATE_ON_BATTERY ||
467  state==SDL_POWERSTATE_NO_BATTERY ||
468  state==SDL_POWERSTATE_CHARGING ||
469  state==SDL_POWERSTATE_CHARGED,
470  "SDL_GetPowerInfo(): state %i is one of the expected values",
471  (int)state);
472 
473  if (state==SDL_POWERSTATE_ON_BATTERY)
474  {
476  secs >= 0,
477  "SDL_GetPowerInfo(): on battery, secs >= 0, was: %i",
478  secs);
480  (pct >= 0) && (pct <= 100),
481  "SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i",
482  pct);
483  }
484 
485  if (state==SDL_POWERSTATE_UNKNOWN ||
487  {
489  secs == -1,
490  "SDL_GetPowerInfo(): no battery, secs == -1, was: %i",
491  secs);
493  pct == -1,
494  "SDL_GetPowerInfo(): no battery, pct == -1, was: %i",
495  pct);
496  }
497 
498  /* Partial return value variations */
499  stateAgain = SDL_GetPowerInfo(&secsAgain, NULL);
501  state==stateAgain,
502  "State %i returned when only 'secs' requested",
503  stateAgain);
505  secs==secsAgain,
506  "Value %i matches when only 'secs' requested",
507  secsAgain);
508  stateAgain = SDL_GetPowerInfo(NULL, &pctAgain);
510  state==stateAgain,
511  "State %i returned when only 'pct' requested",
512  stateAgain);
514  pct==pctAgain,
515  "Value %i matches when only 'pct' requested",
516  pctAgain);
517  stateAgain = SDL_GetPowerInfo(NULL, NULL);
519  state==stateAgain,
520  "State %i returned when no value requested",
521  stateAgain);
522 
523  return TEST_COMPLETED;
524 }
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
struct xkb_state * state
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define SDL_GetPowerInfo
#define TEST_COMPLETED
#define NULL
Definition: begin_code.h:164
SDL_PowerState
The basic state for the system&#39;s power supply.
Definition: SDL_power.h:42

◆ platform_testGetSetClearError()

int platform_testGetSetClearError ( void arg)

Definition at line 280 of file testautomation_platform.c.

References NULL, SDL_ClearError, SDL_GetError, SDL_SetError, SDL_strcmp, SDL_strlen, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

281 {
282  int result;
283  const char *testError = "Testing";
284  char *lastError;
285  size_t len;
286 
287  SDL_ClearError();
288  SDLTest_AssertPass("SDL_ClearError()");
289 
290  lastError = (char *)SDL_GetError();
291  SDLTest_AssertPass("SDL_GetError()");
292  SDLTest_AssertCheck(lastError != NULL,
293  "SDL_GetError() != NULL");
294  if (lastError != NULL)
295  {
296  len = SDL_strlen(lastError);
297  SDLTest_AssertCheck(len == 0,
298  "SDL_GetError(): no message expected, len: %i", (int) len);
299  }
300 
301  result = SDL_SetError("%s", testError);
302  SDLTest_AssertPass("SDL_SetError()");
303  SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
304  lastError = (char *)SDL_GetError();
305  SDLTest_AssertCheck(lastError != NULL,
306  "SDL_GetError() != NULL");
307  if (lastError != NULL)
308  {
309  len = SDL_strlen(lastError);
310  SDLTest_AssertCheck(len == SDL_strlen(testError),
311  "SDL_GetError(): expected message len %i, was len: %i",
312  (int) SDL_strlen(testError),
313  (int) len);
314  SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0,
315  "SDL_GetError(): expected message %s, was message: %s",
316  testError,
317  lastError);
318  }
319 
320  /* Clean up */
321  SDL_ClearError();
322  SDLTest_AssertPass("SDL_ClearError()");
323 
324  return TEST_COMPLETED;
325 }
#define SDL_ClearError
#define SDL_GetError
GLuint64EXT * result
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
GLenum GLsizei len
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define TEST_COMPLETED
#define NULL
Definition: begin_code.h:164
#define SDL_SetError
#define SDL_strlen
#define SDL_strcmp

◆ platform_testGetVersion()

int platform_testGetVersion ( void arg)

Definition at line 208 of file testautomation_platform.c.

References SDL_version::major, SDL_version::minor, SDL_GetVersion, SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDLTest_AssertCheck(), and TEST_COMPLETED.

209 {
210  SDL_version linked;
211  int major = SDL_MAJOR_VERSION;
212  int minor = SDL_MINOR_VERSION;
213 
214  SDL_GetVersion(&linked);
215  SDLTest_AssertCheck( linked.major >= major,
216  "SDL_GetVersion(): returned major %i (>= %i)",
217  linked.major,
218  major);
219  SDLTest_AssertCheck( linked.minor >= minor,
220  "SDL_GetVersion(): returned minor %i (>= %i)",
221  linked.minor,
222  minor);
223 
224  return TEST_COMPLETED;
225 }
#define SDL_MINOR_VERSION
Definition: SDL_version.h:61
#define SDL_MAJOR_VERSION
Definition: SDL_version.h:60
Uint8 major
Definition: SDL_version.h:53
#define SDL_GetVersion
Information the version of SDL in use.
Definition: SDL_version.h:51
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
Uint8 minor
Definition: SDL_version.h:54
#define TEST_COMPLETED

◆ platform_testHasFunctions()

int platform_testHasFunctions ( void arg)

Definition at line 164 of file testautomation_platform.c.

References SDL_Has3DNow, SDL_HasAltiVec, SDL_HasAVX, SDL_HasMMX, SDL_HasRDTSC, SDL_HasSSE, SDL_HasSSE2, SDL_HasSSE3, SDL_HasSSE41, SDL_HasSSE42, SDLTest_AssertPass(), and TEST_COMPLETED.

165 {
166  int ret;
167 
168  /* TODO: independently determine and compare values as well */
169 
170  ret = SDL_HasRDTSC();
171  SDLTest_AssertPass("SDL_HasRDTSC()");
172 
173  ret = SDL_HasAltiVec();
174  SDLTest_AssertPass("SDL_HasAltiVec()");
175 
176  ret = SDL_HasMMX();
177  SDLTest_AssertPass("SDL_HasMMX()");
178 
179  ret = SDL_Has3DNow();
180  SDLTest_AssertPass("SDL_Has3DNow()");
181 
182  ret = SDL_HasSSE();
183  SDLTest_AssertPass("SDL_HasSSE()");
184 
185  ret = SDL_HasSSE2();
186  SDLTest_AssertPass("SDL_HasSSE2()");
187 
188  ret = SDL_HasSSE3();
189  SDLTest_AssertPass("SDL_HasSSE3()");
190 
191  ret = SDL_HasSSE41();
192  SDLTest_AssertPass("SDL_HasSSE41()");
193 
194  ret = SDL_HasSSE42();
195  SDLTest_AssertPass("SDL_HasSSE42()");
196 
197  ret = SDL_HasAVX();
198  SDLTest_AssertPass("SDL_HasAVX()");
199 
200  return TEST_COMPLETED;
201 }
#define SDL_HasAltiVec
#define SDL_HasAVX
#define SDL_Has3DNow
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
#define SDL_HasSSE3
#define SDL_HasRDTSC
#define SDL_HasSSE42
#define SDL_HasMMX
#define TEST_COMPLETED
#define SDL_HasSSE41
#define SDL_HasSSE2
#define SDL_HasSSE

◆ platform_testSDLVersion()

int platform_testSDLVersion ( void arg)

Definition at line 231 of file testautomation_platform.c.

References SDL_version::major, SDL_version::minor, SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_VERSION, SDLTest_AssertCheck(), and TEST_COMPLETED.

232 {
233  SDL_version compiled;
234  int major = SDL_MAJOR_VERSION;
235  int minor = SDL_MINOR_VERSION;
236 
237  SDL_VERSION(&compiled);
238  SDLTest_AssertCheck( compiled.major >= major,
239  "SDL_VERSION() returned major %i (>= %i)",
240  compiled.major,
241  major);
242  SDLTest_AssertCheck( compiled.minor >= minor,
243  "SDL_VERSION() returned minor %i (>= %i)",
244  compiled.minor,
245  minor);
246 
247  return TEST_COMPLETED;
248 }
#define SDL_MINOR_VERSION
Definition: SDL_version.h:61
#define SDL_MAJOR_VERSION
Definition: SDL_version.h:60
Uint8 major
Definition: SDL_version.h:53
#define SDL_VERSION(x)
Macro to determine SDL version program was compiled against.
Definition: SDL_version.h:79
Information the version of SDL in use.
Definition: SDL_version.h:51
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
Uint8 minor
Definition: SDL_version.h:54
#define TEST_COMPLETED

◆ platform_testSetErrorEmptyInput()

int platform_testSetErrorEmptyInput ( void arg)

Definition at line 332 of file testautomation_platform.c.

References NULL, SDL_ClearError, SDL_GetError, SDL_SetError, SDL_strcmp, SDL_strlen, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

333 {
334  int result;
335  const char *testError = "";
336  char *lastError;
337  size_t len;
338 
339  result = SDL_SetError("%s", testError);
340  SDLTest_AssertPass("SDL_SetError()");
341  SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
342  lastError = (char *)SDL_GetError();
343  SDLTest_AssertCheck(lastError != NULL,
344  "SDL_GetError() != NULL");
345  if (lastError != NULL)
346  {
347  len = SDL_strlen(lastError);
348  SDLTest_AssertCheck(len == SDL_strlen(testError),
349  "SDL_GetError(): expected message len %i, was len: %i",
350  (int) SDL_strlen(testError),
351  (int) len);
352  SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0,
353  "SDL_GetError(): expected message '%s', was message: '%s'",
354  testError,
355  lastError);
356  }
357 
358  /* Clean up */
359  SDL_ClearError();
360  SDLTest_AssertPass("SDL_ClearError()");
361 
362  return TEST_COMPLETED;
363 }
#define SDL_ClearError
#define SDL_GetError
GLuint64EXT * result
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
GLenum GLsizei len
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define TEST_COMPLETED
#define NULL
Definition: begin_code.h:164
#define SDL_SetError
#define SDL_strlen
#define SDL_strcmp

◆ platform_testSetErrorInvalidInput()

int platform_testSetErrorInvalidInput ( void arg)

Definition at line 370 of file testautomation_platform.c.

References NULL, SDL_ClearError, SDL_GetError, SDL_SetError, SDL_strcmp, SDL_strlen, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

371 {
372  int result;
373  const char *invalidError = NULL;
374  const char *probeError = "Testing";
375  char *lastError;
376  size_t len;
377 
378  /* Reset */
379  SDL_ClearError();
380  SDLTest_AssertPass("SDL_ClearError()");
381 
382  /* Check for no-op */
383  result = SDL_SetError("%s", invalidError);
384  SDLTest_AssertPass("SDL_SetError()");
385  SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
386  lastError = (char *)SDL_GetError();
387  SDLTest_AssertCheck(lastError != NULL,
388  "SDL_GetError() != NULL");
389  if (lastError != NULL)
390  {
391  len = SDL_strlen(lastError);
392  SDLTest_AssertCheck(len == 0,
393  "SDL_GetError(): expected message len 0, was len: %i",
394  (int) len);
395  }
396 
397  /* Set */
398  result = SDL_SetError("%s", probeError);
399  SDLTest_AssertPass("SDL_SetError('%s')", probeError);
400  SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
401 
402  /* Check for no-op */
403  result = SDL_SetError("%s", invalidError);
404  SDLTest_AssertPass("SDL_SetError(NULL)");
405  SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
406  lastError = (char *)SDL_GetError();
407  SDLTest_AssertCheck(lastError != NULL,
408  "SDL_GetError() != NULL");
409  if (lastError != NULL)
410  {
411  len = SDL_strlen(lastError);
412  SDLTest_AssertCheck(len == 0,
413  "SDL_GetError(): expected message len 0, was len: %i",
414  (int) len);
415  }
416 
417  /* Reset */
418  SDL_ClearError();
419  SDLTest_AssertPass("SDL_ClearError()");
420 
421  /* Set and check */
422  result = SDL_SetError("%s", probeError);
423  SDLTest_AssertPass("SDL_SetError()");
424  SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
425  lastError = (char *)SDL_GetError();
426  SDLTest_AssertCheck(lastError != NULL,
427  "SDL_GetError() != NULL");
428  if (lastError != NULL)
429  {
430  len = SDL_strlen(lastError);
431  SDLTest_AssertCheck(len == SDL_strlen(probeError),
432  "SDL_GetError(): expected message len %i, was len: %i",
433  (int) SDL_strlen(probeError),
434  (int) len);
435  SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0,
436  "SDL_GetError(): expected message '%s', was message: '%s'",
437  probeError,
438  lastError);
439  }
440 
441  /* Clean up */
442  SDL_ClearError();
443  SDLTest_AssertPass("SDL_ClearError()");
444 
445  return TEST_COMPLETED;
446 }
#define SDL_ClearError
#define SDL_GetError
GLuint64EXT * result
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
GLenum GLsizei len
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define TEST_COMPLETED
#define NULL
Definition: begin_code.h:164
#define SDL_SetError
#define SDL_strlen
#define SDL_strcmp

◆ platform_testTypes()

int platform_testTypes ( void arg)

Tests type sizes.

Definition at line 32 of file testautomation_platform.c.

References _compareSizeOfType(), SDLTest_AssertCheck(), and TEST_COMPLETED.

33 {
34  int ret;
35 
36  ret = _compareSizeOfType( sizeof(Uint8), 1 );
37  SDLTest_AssertCheck( ret == 0, "sizeof(Uint8) = %lu, expected 1", (unsigned long)sizeof(Uint8) );
38 
39  ret = _compareSizeOfType( sizeof(Uint16), 2 );
40  SDLTest_AssertCheck( ret == 0, "sizeof(Uint16) = %lu, expected 2", (unsigned long)sizeof(Uint16) );
41 
42  ret = _compareSizeOfType( sizeof(Uint32), 4 );
43  SDLTest_AssertCheck( ret == 0, "sizeof(Uint32) = %lu, expected 4", (unsigned long)sizeof(Uint32) );
44 
45  ret = _compareSizeOfType( sizeof(Uint64), 8 );
46  SDLTest_AssertCheck( ret == 0, "sizeof(Uint64) = %lu, expected 8", (unsigned long)sizeof(Uint64) );
47 
48  return TEST_COMPLETED;
49 }
static int _compareSizeOfType(size_t sizeoftype, size_t hardcodetype)
Compare sizes of types.
uint32_t Uint32
Definition: SDL_stdinc.h:181
uint64_t Uint64
Definition: SDL_stdinc.h:194
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
uint8_t Uint8
Definition: SDL_stdinc.h:157
#define TEST_COMPLETED
uint16_t Uint16
Definition: SDL_stdinc.h:169

Variable Documentation

◆ platformTest1

const SDLTest_TestCaseReference platformTest1
static
Initial value:
=
{ (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED}
int platform_testTypes(void *arg)
Tests type sizes.
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 529 of file testautomation_platform.c.

◆ platformTest10

const SDLTest_TestCaseReference platformTest10
static
Initial value:
=
{ (SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED}
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int platform_testSetErrorInvalidInput(void *arg)

Definition at line 556 of file testautomation_platform.c.

◆ platformTest11

const SDLTest_TestCaseReference platformTest11
static
Initial value:
=
{ (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED }
int platform_testGetPowerInfo(void *arg)
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 559 of file testautomation_platform.c.

◆ platformTest2

const SDLTest_TestCaseReference platformTest2
static
Initial value:
=
{ (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED}
int platform_testEndianessAndSwap(void *arg)
Tests platform endianness and SDL_SwapXY functions.
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 532 of file testautomation_platform.c.

◆ platformTest3

const SDLTest_TestCaseReference platformTest3
static
Initial value:
=
{ (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED}
int(* SDLTest_TestCaseFp)(void *arg)
int platform_testGetFunctions(void *arg)
#define TEST_ENABLED

Definition at line 535 of file testautomation_platform.c.

◆ platformTest4

const SDLTest_TestCaseReference platformTest4
static
Initial value:
=
{ (SDLTest_TestCaseFp)platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED}
int(* SDLTest_TestCaseFp)(void *arg)
int platform_testHasFunctions(void *arg)
#define TEST_ENABLED

Definition at line 538 of file testautomation_platform.c.

◆ platformTest5

const SDLTest_TestCaseReference platformTest5
static
Initial value:
=
{ (SDLTest_TestCaseFp)platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED}
int platform_testGetVersion(void *arg)
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 541 of file testautomation_platform.c.

◆ platformTest6

const SDLTest_TestCaseReference platformTest6
static
Initial value:
=
{ (SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED}
int(* SDLTest_TestCaseFp)(void *arg)
int platform_testSDLVersion(void *arg)
#define TEST_ENABLED

Definition at line 544 of file testautomation_platform.c.

◆ platformTest7

const SDLTest_TestCaseReference platformTest7
static
Initial value:
=
{ (SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED}
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int platform_testDefaultInit(void *arg)

Definition at line 547 of file testautomation_platform.c.

◆ platformTest8

const SDLTest_TestCaseReference platformTest8
static
Initial value:
=
{ (SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED}
int(* SDLTest_TestCaseFp)(void *arg)
int platform_testGetSetClearError(void *arg)
#define TEST_ENABLED

Definition at line 550 of file testautomation_platform.c.

◆ platformTest9

const SDLTest_TestCaseReference platformTest9
static
Initial value:
=
{ (SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED}
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int platform_testSetErrorEmptyInput(void *arg)

Definition at line 553 of file testautomation_platform.c.

◆ platformTests

const SDLTest_TestCaseReference* platformTests[]
static
Initial value:
= {
}
static const SDLTest_TestCaseReference platformTest9
static const SDLTest_TestCaseReference platformTest2
static const SDLTest_TestCaseReference platformTest11
static const SDLTest_TestCaseReference platformTest6
static const SDLTest_TestCaseReference platformTest10
static const SDLTest_TestCaseReference platformTest1
static const SDLTest_TestCaseReference platformTest4
static const SDLTest_TestCaseReference platformTest5
#define NULL
Definition: begin_code.h:164
static const SDLTest_TestCaseReference platformTest7
static const SDLTest_TestCaseReference platformTest3
static const SDLTest_TestCaseReference platformTest8

Definition at line 563 of file testautomation_platform.c.

◆ platformTestSuite

SDLTest_TestSuiteReference platformTestSuite
Initial value:
= {
"Platform",
}
static const SDLTest_TestCaseReference * platformTests[]
#define NULL
Definition: begin_code.h:164

Definition at line 579 of file testautomation_platform.c.