diff options
Diffstat (limited to 'contrib/SDL-3.2.8/test/testautomation_platform.c')
| -rw-r--r-- | contrib/SDL-3.2.8/test/testautomation_platform.c | 557 |
1 files changed, 557 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/test/testautomation_platform.c b/contrib/SDL-3.2.8/test/testautomation_platform.c new file mode 100644 index 0000000..2a70e75 --- /dev/null +++ b/contrib/SDL-3.2.8/test/testautomation_platform.c | |||
| @@ -0,0 +1,557 @@ | |||
| 1 | /** | ||
| 2 | * Original code: automated SDL platform test written by Edgar Simo "bobbens" | ||
| 3 | * Extended and updated by aschiffler at ferzkopp dot net | ||
| 4 | */ | ||
| 5 | #include <SDL3/SDL.h> | ||
| 6 | #include <SDL3/SDL_test.h> | ||
| 7 | #include "testautomation_suites.h" | ||
| 8 | |||
| 9 | /* ================= Test Case Implementation ================== */ | ||
| 10 | |||
| 11 | /* Helper functions */ | ||
| 12 | |||
| 13 | /** | ||
| 14 | * Compare sizes of types. | ||
| 15 | * | ||
| 16 | * @note Watcom C flags these as Warning 201: "Unreachable code" if you just | ||
| 17 | * compare them directly, so we push it through a function to keep the | ||
| 18 | * compiler quiet. --ryan. | ||
| 19 | */ | ||
| 20 | static int compareSizeOfType(size_t sizeoftype, size_t hardcodetype) | ||
| 21 | { | ||
| 22 | return sizeoftype != hardcodetype; | ||
| 23 | } | ||
| 24 | |||
| 25 | /* Test case functions */ | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Tests type sizes. | ||
| 29 | */ | ||
| 30 | static int SDLCALL platform_testTypes(void *arg) | ||
| 31 | { | ||
| 32 | int ret; | ||
| 33 | |||
| 34 | ret = compareSizeOfType(sizeof(Uint8), 1); | ||
| 35 | SDLTest_AssertCheck(ret == 0, "sizeof(Uint8) = %u, expected 1", (unsigned int)sizeof(Uint8)); | ||
| 36 | |||
| 37 | ret = compareSizeOfType(sizeof(Uint16), 2); | ||
| 38 | SDLTest_AssertCheck(ret == 0, "sizeof(Uint16) = %u, expected 2", (unsigned int)sizeof(Uint16)); | ||
| 39 | |||
| 40 | ret = compareSizeOfType(sizeof(Uint32), 4); | ||
| 41 | SDLTest_AssertCheck(ret == 0, "sizeof(Uint32) = %u, expected 4", (unsigned int)sizeof(Uint32)); | ||
| 42 | |||
| 43 | ret = compareSizeOfType(sizeof(Uint64), 8); | ||
| 44 | SDLTest_AssertCheck(ret == 0, "sizeof(Uint64) = %u, expected 8", (unsigned int)sizeof(Uint64)); | ||
| 45 | |||
| 46 | return TEST_COMPLETED; | ||
| 47 | } | ||
| 48 | |||
| 49 | /** | ||
| 50 | * Tests platform endianness and SDL_SwapXY functions. | ||
| 51 | */ | ||
| 52 | static int SDLCALL platform_testEndianessAndSwap(void *arg) | ||
| 53 | { | ||
| 54 | int real_byteorder; | ||
| 55 | int real_floatwordorder = 0; | ||
| 56 | Uint16 value = 0x1234; | ||
| 57 | Uint16 value16 = 0xCDAB; | ||
| 58 | Uint16 swapped16 = 0xABCD; | ||
| 59 | Uint32 value32 = 0xEFBEADDE; | ||
| 60 | Uint32 swapped32 = 0xDEADBEEF; | ||
| 61 | |||
| 62 | union | ||
| 63 | { | ||
| 64 | double d; | ||
| 65 | Uint32 ui32[2]; | ||
| 66 | } value_double; | ||
| 67 | |||
| 68 | Uint64 value64, swapped64; | ||
| 69 | value64 = 0xEFBEADDE; | ||
| 70 | value64 <<= 32; | ||
| 71 | value64 |= 0xCDAB3412; | ||
| 72 | swapped64 = 0x1234ABCD; | ||
| 73 | swapped64 <<= 32; | ||
| 74 | swapped64 |= 0xDEADBEEF; | ||
| 75 | value_double.d = 3.141593; | ||
| 76 | |||
| 77 | if ((*((char *)&value) >> 4) == 0x1) { | ||
| 78 | real_byteorder = SDL_BIG_ENDIAN; | ||
| 79 | } else { | ||
| 80 | real_byteorder = SDL_LIL_ENDIAN; | ||
| 81 | } | ||
| 82 | |||
| 83 | /* Test endianness. */ | ||
| 84 | SDLTest_AssertCheck(real_byteorder == SDL_BYTEORDER, | ||
| 85 | "Machine detected as %s endian, appears to be %s endian.", | ||
| 86 | (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big", | ||
| 87 | (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big"); | ||
| 88 | |||
| 89 | if (value_double.ui32[0] == 0x82c2bd7f && value_double.ui32[1] == 0x400921fb) { | ||
| 90 | real_floatwordorder = SDL_LIL_ENDIAN; | ||
| 91 | } else if (value_double.ui32[0] == 0x400921fb && value_double.ui32[1] == 0x82c2bd7f) { | ||
| 92 | real_floatwordorder = SDL_BIG_ENDIAN; | ||
| 93 | } | ||
| 94 | |||
| 95 | /* Test endianness. */ | ||
| 96 | SDLTest_AssertCheck(real_floatwordorder == SDL_FLOATWORDORDER, | ||
| 97 | "Machine detected as having %s endian float word order, appears to be %s endian.", | ||
| 98 | (SDL_FLOATWORDORDER == SDL_LIL_ENDIAN) ? "little" : "big", | ||
| 99 | (real_floatwordorder == SDL_LIL_ENDIAN) ? "little" : (real_floatwordorder == SDL_BIG_ENDIAN) ? "big" | ||
| 100 | : "unknown"); | ||
| 101 | |||
| 102 | /* Test 16 swap. */ | ||
| 103 | SDLTest_AssertCheck(SDL_Swap16(value16) == swapped16, | ||
| 104 | "SDL_Swap16(): 16 bit swapped: 0x%X => 0x%X", | ||
| 105 | value16, SDL_Swap16(value16)); | ||
| 106 | |||
| 107 | /* Test 32 swap. */ | ||
| 108 | SDLTest_AssertCheck(SDL_Swap32(value32) == swapped32, | ||
| 109 | "SDL_Swap32(): 32 bit swapped: 0x%" SDL_PRIX32 " => 0x%" SDL_PRIX32, | ||
| 110 | value32, SDL_Swap32(value32)); | ||
| 111 | |||
| 112 | /* Test 64 swap. */ | ||
| 113 | SDLTest_AssertCheck(SDL_Swap64(value64) == swapped64, | ||
| 114 | "SDL_Swap64(): 64 bit swapped: 0x%" SDL_PRIX64 " => 0x%" SDL_PRIX64, | ||
| 115 | value64, SDL_Swap64(value64)); | ||
| 116 | |||
| 117 | return TEST_COMPLETED; | ||
| 118 | } | ||
| 119 | |||
| 120 | /** | ||
| 121 | * Tests SDL_GetXYZ() functions | ||
| 122 | * \sa SDL_GetPlatform | ||
| 123 | * \sa SDL_GetNumLogicalCPUCores | ||
| 124 | * \sa SDL_GetRevision | ||
| 125 | * \sa SDL_GetCPUCacheLineSize | ||
| 126 | */ | ||
| 127 | static int SDLCALL platform_testGetFunctions(void *arg) | ||
| 128 | { | ||
| 129 | const char *platform; | ||
| 130 | const char *revision; | ||
| 131 | int ret; | ||
| 132 | size_t len; | ||
| 133 | |||
| 134 | platform = SDL_GetPlatform(); | ||
| 135 | SDLTest_AssertPass("SDL_GetPlatform()"); | ||
| 136 | SDLTest_AssertCheck(platform != NULL, "SDL_GetPlatform() != NULL"); | ||
| 137 | if (platform != NULL) { | ||
| 138 | len = SDL_strlen(platform); | ||
| 139 | SDLTest_AssertCheck(len > 0, | ||
| 140 | "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i", | ||
| 141 | platform, | ||
| 142 | (int)len); | ||
| 143 | } | ||
| 144 | |||
| 145 | ret = SDL_GetNumLogicalCPUCores(); | ||
| 146 | SDLTest_AssertPass("SDL_GetNumLogicalCPUCores()"); | ||
| 147 | SDLTest_AssertCheck(ret > 0, | ||
| 148 | "SDL_GetNumLogicalCPUCores(): expected count > 0, was: %i", | ||
| 149 | ret); | ||
| 150 | |||
| 151 | ret = SDL_GetCPUCacheLineSize(); | ||
| 152 | SDLTest_AssertPass("SDL_GetCPUCacheLineSize()"); | ||
| 153 | SDLTest_AssertCheck(ret >= 0, | ||
| 154 | "SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i", | ||
| 155 | ret); | ||
| 156 | |||
| 157 | revision = SDL_GetRevision(); | ||
| 158 | SDLTest_AssertPass("SDL_GetRevision()"); | ||
| 159 | SDLTest_AssertCheck(revision != NULL, "SDL_GetRevision() != NULL"); | ||
| 160 | |||
| 161 | return TEST_COMPLETED; | ||
| 162 | } | ||
| 163 | |||
| 164 | /** | ||
| 165 | * Tests SDL_HasXYZ() functions | ||
| 166 | * \sa SDL_HasAltiVec | ||
| 167 | * \sa SDL_HasMMX | ||
| 168 | * \sa SDL_HasSSE | ||
| 169 | * \sa SDL_HasSSE2 | ||
| 170 | * \sa SDL_HasSSE3 | ||
| 171 | * \sa SDL_HasSSE41 | ||
| 172 | * \sa SDL_HasSSE42 | ||
| 173 | * \sa SDL_HasAVX | ||
| 174 | */ | ||
| 175 | static int SDLCALL platform_testHasFunctions(void *arg) | ||
| 176 | { | ||
| 177 | /* TODO: independently determine and compare values as well */ | ||
| 178 | |||
| 179 | SDL_HasAltiVec(); | ||
| 180 | SDLTest_AssertPass("SDL_HasAltiVec()"); | ||
| 181 | |||
| 182 | SDL_HasMMX(); | ||
| 183 | SDLTest_AssertPass("SDL_HasMMX()"); | ||
| 184 | |||
| 185 | SDL_HasSSE(); | ||
| 186 | SDLTest_AssertPass("SDL_HasSSE()"); | ||
| 187 | |||
| 188 | SDL_HasSSE2(); | ||
| 189 | SDLTest_AssertPass("SDL_HasSSE2()"); | ||
| 190 | |||
| 191 | SDL_HasSSE3(); | ||
| 192 | SDLTest_AssertPass("SDL_HasSSE3()"); | ||
| 193 | |||
| 194 | SDL_HasSSE41(); | ||
| 195 | SDLTest_AssertPass("SDL_HasSSE41()"); | ||
| 196 | |||
| 197 | SDL_HasSSE42(); | ||
| 198 | SDLTest_AssertPass("SDL_HasSSE42()"); | ||
| 199 | |||
| 200 | SDL_HasAVX(); | ||
| 201 | SDLTest_AssertPass("SDL_HasAVX()"); | ||
| 202 | |||
| 203 | return TEST_COMPLETED; | ||
| 204 | } | ||
| 205 | |||
| 206 | /** | ||
| 207 | * Tests SDL_GetVersion | ||
| 208 | * \sa SDL_GetVersion | ||
| 209 | */ | ||
| 210 | static int SDLCALL platform_testGetVersion(void *arg) | ||
| 211 | { | ||
| 212 | int linked = SDL_GetVersion(); | ||
| 213 | SDLTest_AssertCheck(linked >= SDL_VERSION, | ||
| 214 | "SDL_GetVersion(): returned version %d (>= %d)", | ||
| 215 | linked, | ||
| 216 | SDL_VERSION); | ||
| 217 | |||
| 218 | return TEST_COMPLETED; | ||
| 219 | } | ||
| 220 | |||
| 221 | /** | ||
| 222 | * Tests default SDL_Init | ||
| 223 | */ | ||
| 224 | static int SDLCALL platform_testDefaultInit(void *arg) | ||
| 225 | { | ||
| 226 | bool ret; | ||
| 227 | int subsystem; | ||
| 228 | |||
| 229 | subsystem = SDL_WasInit(0); | ||
| 230 | SDLTest_AssertCheck(subsystem != 0, | ||
| 231 | "SDL_WasInit(0): returned %i, expected != 0", | ||
| 232 | subsystem); | ||
| 233 | |||
| 234 | ret = SDL_Init(0); | ||
| 235 | SDLTest_AssertCheck(ret == true, | ||
| 236 | "SDL_Init(0): returned %i, expected true, error: %s", | ||
| 237 | ret, | ||
| 238 | SDL_GetError()); | ||
| 239 | |||
| 240 | return TEST_COMPLETED; | ||
| 241 | } | ||
| 242 | |||
| 243 | /** | ||
| 244 | * Tests SDL_Get/Set/ClearError | ||
| 245 | * \sa SDL_GetError | ||
| 246 | * \sa SDL_SetError | ||
| 247 | * \sa SDL_ClearError | ||
| 248 | */ | ||
| 249 | static int SDLCALL platform_testGetSetClearError(void *arg) | ||
| 250 | { | ||
| 251 | int result; | ||
| 252 | const char *testError = "Testing"; | ||
| 253 | const char *lastError; | ||
| 254 | size_t len; | ||
| 255 | |||
| 256 | SDL_ClearError(); | ||
| 257 | SDLTest_AssertPass("SDL_ClearError()"); | ||
| 258 | |||
| 259 | lastError = SDL_GetError(); | ||
| 260 | SDLTest_AssertPass("SDL_GetError()"); | ||
| 261 | SDLTest_AssertCheck(lastError != NULL, | ||
| 262 | "SDL_GetError() != NULL"); | ||
| 263 | if (lastError != NULL) { | ||
| 264 | len = SDL_strlen(lastError); | ||
| 265 | SDLTest_AssertCheck(len == 0, | ||
| 266 | "SDL_GetError(): no message expected, len: %i", (int)len); | ||
| 267 | } | ||
| 268 | |||
| 269 | result = SDL_SetError("%s", testError); | ||
| 270 | SDLTest_AssertPass("SDL_SetError()"); | ||
| 271 | SDLTest_AssertCheck(result == false, "SDL_SetError: expected false, got: %i", result); | ||
| 272 | lastError = SDL_GetError(); | ||
| 273 | SDLTest_AssertCheck(lastError != NULL, | ||
| 274 | "SDL_GetError() != NULL"); | ||
| 275 | if (lastError != NULL) { | ||
| 276 | len = SDL_strlen(lastError); | ||
| 277 | SDLTest_AssertCheck(len == SDL_strlen(testError), | ||
| 278 | "SDL_GetError(): expected message len %i, was len: %i", | ||
| 279 | (int)SDL_strlen(testError), | ||
| 280 | (int)len); | ||
| 281 | SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, | ||
| 282 | "SDL_GetError(): expected message %s, was message: %s", | ||
| 283 | testError, | ||
| 284 | lastError); | ||
| 285 | } | ||
| 286 | |||
| 287 | /* Clean up */ | ||
| 288 | SDL_ClearError(); | ||
| 289 | SDLTest_AssertPass("SDL_ClearError()"); | ||
| 290 | |||
| 291 | return TEST_COMPLETED; | ||
| 292 | } | ||
| 293 | |||
| 294 | /** | ||
| 295 | * Tests SDL_SetError with empty input | ||
| 296 | * \sa SDL_SetError | ||
| 297 | */ | ||
| 298 | static int SDLCALL platform_testSetErrorEmptyInput(void *arg) | ||
| 299 | { | ||
| 300 | int result; | ||
| 301 | const char *testError = ""; | ||
| 302 | const char *lastError; | ||
| 303 | size_t len; | ||
| 304 | |||
| 305 | result = SDL_SetError("%s", testError); | ||
| 306 | SDLTest_AssertPass("SDL_SetError()"); | ||
| 307 | SDLTest_AssertCheck(result == false, "SDL_SetError: expected false, got: %i", result); | ||
| 308 | lastError = SDL_GetError(); | ||
| 309 | SDLTest_AssertCheck(lastError != NULL, | ||
| 310 | "SDL_GetError() != NULL"); | ||
| 311 | if (lastError != NULL) { | ||
| 312 | len = SDL_strlen(lastError); | ||
| 313 | SDLTest_AssertCheck(len == SDL_strlen(testError), | ||
| 314 | "SDL_GetError(): expected message len %i, was len: %i", | ||
| 315 | (int)SDL_strlen(testError), | ||
| 316 | (int)len); | ||
| 317 | SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0, | ||
| 318 | "SDL_GetError(): expected message '%s', was message: '%s'", | ||
| 319 | testError, | ||
| 320 | lastError); | ||
| 321 | } | ||
| 322 | |||
| 323 | /* Clean up */ | ||
| 324 | SDL_ClearError(); | ||
| 325 | SDLTest_AssertPass("SDL_ClearError()"); | ||
| 326 | |||
| 327 | return TEST_COMPLETED; | ||
| 328 | } | ||
| 329 | |||
| 330 | #ifdef HAVE_WFORMAT_OVERFLOW | ||
| 331 | #pragma GCC diagnostic push | ||
| 332 | #pragma GCC diagnostic ignored "-Wformat-overflow" | ||
| 333 | #endif | ||
| 334 | |||
| 335 | /** | ||
| 336 | * Tests SDL_SetError with invalid input | ||
| 337 | * \sa SDL_SetError | ||
| 338 | */ | ||
| 339 | static int SDLCALL platform_testSetErrorInvalidInput(void *arg) | ||
| 340 | { | ||
| 341 | int result; | ||
| 342 | const char *invalidError = ""; | ||
| 343 | const char *probeError = "Testing"; | ||
| 344 | const char *lastError; | ||
| 345 | size_t len; | ||
| 346 | |||
| 347 | /* Reset */ | ||
| 348 | SDL_ClearError(); | ||
| 349 | SDLTest_AssertPass("SDL_ClearError()"); | ||
| 350 | |||
| 351 | /* Check for no-op */ | ||
| 352 | result = SDL_SetError("%s", invalidError); | ||
| 353 | SDLTest_AssertPass("SDL_SetError()"); | ||
| 354 | SDLTest_AssertCheck(result == false, "SDL_SetError: expected false, got: %i", result); | ||
| 355 | lastError = SDL_GetError(); | ||
| 356 | SDLTest_AssertCheck(lastError != NULL, | ||
| 357 | "SDL_GetError() != NULL"); | ||
| 358 | if (lastError != NULL) { | ||
| 359 | len = SDL_strlen(lastError); | ||
| 360 | SDLTest_AssertCheck(len == 0 || SDL_strcmp(lastError, "(null)") == 0, | ||
| 361 | "SDL_GetError(): expected message len 0, was len: %i", | ||
| 362 | (int)len); | ||
| 363 | } | ||
| 364 | |||
| 365 | /* Set */ | ||
| 366 | result = SDL_SetError("%s", probeError); | ||
| 367 | SDLTest_AssertPass("SDL_SetError('%s')", probeError); | ||
| 368 | SDLTest_AssertCheck(result == false, "SDL_SetError: expected false, got: %i", result); | ||
| 369 | |||
| 370 | /* Check for no-op */ | ||
| 371 | result = SDL_SetError("%s", invalidError); | ||
| 372 | SDLTest_AssertPass("SDL_SetError(NULL)"); | ||
| 373 | SDLTest_AssertCheck(result == false, "SDL_SetError: expected false, got: %i", result); | ||
| 374 | lastError = SDL_GetError(); | ||
| 375 | SDLTest_AssertCheck(lastError != NULL, | ||
| 376 | "SDL_GetError() != NULL"); | ||
| 377 | if (lastError != NULL) { | ||
| 378 | len = SDL_strlen(lastError); | ||
| 379 | SDLTest_AssertCheck(len == 0 || SDL_strcmp(lastError, "(null)") == 0, | ||
| 380 | "SDL_GetError(): expected message len 0, was len: %i", | ||
| 381 | (int)len); | ||
| 382 | } | ||
| 383 | |||
| 384 | /* Reset */ | ||
| 385 | SDL_ClearError(); | ||
| 386 | SDLTest_AssertPass("SDL_ClearError()"); | ||
| 387 | |||
| 388 | /* Set and check */ | ||
| 389 | result = SDL_SetError("%s", probeError); | ||
| 390 | SDLTest_AssertPass("SDL_SetError()"); | ||
| 391 | SDLTest_AssertCheck(result == false, "SDL_SetError: expected false, got: %i", result); | ||
| 392 | lastError = SDL_GetError(); | ||
| 393 | SDLTest_AssertCheck(lastError != NULL, | ||
| 394 | "SDL_GetError() != NULL"); | ||
| 395 | if (lastError != NULL) { | ||
| 396 | len = SDL_strlen(lastError); | ||
| 397 | SDLTest_AssertCheck(len == SDL_strlen(probeError), | ||
| 398 | "SDL_GetError(): expected message len %i, was len: %i", | ||
| 399 | (int)SDL_strlen(probeError), | ||
| 400 | (int)len); | ||
| 401 | SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0, | ||
| 402 | "SDL_GetError(): expected message '%s', was message: '%s'", | ||
| 403 | probeError, | ||
| 404 | lastError); | ||
| 405 | } | ||
| 406 | |||
| 407 | /* Clean up */ | ||
| 408 | SDL_ClearError(); | ||
| 409 | SDLTest_AssertPass("SDL_ClearError()"); | ||
| 410 | |||
| 411 | return TEST_COMPLETED; | ||
| 412 | } | ||
| 413 | |||
| 414 | #ifdef HAVE_WFORMAT_OVERFLOW | ||
| 415 | #pragma GCC diagnostic pop | ||
| 416 | #endif | ||
| 417 | |||
| 418 | /** | ||
| 419 | * Tests SDL_GetPowerInfo | ||
| 420 | * \sa SDL_GetPowerInfo | ||
| 421 | */ | ||
| 422 | static int SDLCALL platform_testGetPowerInfo(void *arg) | ||
| 423 | { | ||
| 424 | SDL_PowerState state; | ||
| 425 | SDL_PowerState stateAgain; | ||
| 426 | int secs; | ||
| 427 | int secsAgain; | ||
| 428 | int pct; | ||
| 429 | int pctAgain; | ||
| 430 | |||
| 431 | state = SDL_GetPowerInfo(&secs, &pct); | ||
| 432 | SDLTest_AssertPass("SDL_GetPowerInfo()"); | ||
| 433 | SDLTest_AssertCheck( | ||
| 434 | state == SDL_POWERSTATE_UNKNOWN || | ||
| 435 | state == SDL_POWERSTATE_ON_BATTERY || | ||
| 436 | state == SDL_POWERSTATE_NO_BATTERY || | ||
| 437 | state == SDL_POWERSTATE_CHARGING || | ||
| 438 | state == SDL_POWERSTATE_CHARGED, | ||
| 439 | "SDL_GetPowerInfo(): state %i is one of the expected values", | ||
| 440 | (int)state); | ||
| 441 | |||
| 442 | if (state == SDL_POWERSTATE_ON_BATTERY) { | ||
| 443 | SDLTest_AssertCheck( | ||
| 444 | secs >= 0, | ||
| 445 | "SDL_GetPowerInfo(): on battery, secs >= 0, was: %i", | ||
| 446 | secs); | ||
| 447 | SDLTest_AssertCheck( | ||
| 448 | (pct >= 0) && (pct <= 100), | ||
| 449 | "SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i", | ||
| 450 | pct); | ||
| 451 | } | ||
| 452 | |||
| 453 | if (state == SDL_POWERSTATE_UNKNOWN || | ||
| 454 | state == SDL_POWERSTATE_NO_BATTERY) { | ||
| 455 | SDLTest_AssertCheck( | ||
| 456 | secs == -1, | ||
| 457 | "SDL_GetPowerInfo(): no battery, secs == -1, was: %i", | ||
| 458 | secs); | ||
| 459 | SDLTest_AssertCheck( | ||
| 460 | pct == -1, | ||
| 461 | "SDL_GetPowerInfo(): no battery, pct == -1, was: %i", | ||
| 462 | pct); | ||
| 463 | } | ||
| 464 | |||
| 465 | /* Partial return value variations */ | ||
| 466 | stateAgain = SDL_GetPowerInfo(&secsAgain, NULL); | ||
| 467 | SDLTest_AssertCheck( | ||
| 468 | state == stateAgain, | ||
| 469 | "State %i returned when only 'secs' requested", | ||
| 470 | stateAgain); | ||
| 471 | SDLTest_AssertCheck( | ||
| 472 | secs == secsAgain, | ||
| 473 | "Value %i matches when only 'secs' requested", | ||
| 474 | secsAgain); | ||
| 475 | stateAgain = SDL_GetPowerInfo(NULL, &pctAgain); | ||
| 476 | SDLTest_AssertCheck( | ||
| 477 | state == stateAgain, | ||
| 478 | "State %i returned when only 'pct' requested", | ||
| 479 | stateAgain); | ||
| 480 | SDLTest_AssertCheck( | ||
| 481 | pct == pctAgain, | ||
| 482 | "Value %i matches when only 'pct' requested", | ||
| 483 | pctAgain); | ||
| 484 | stateAgain = SDL_GetPowerInfo(NULL, NULL); | ||
| 485 | SDLTest_AssertCheck( | ||
| 486 | state == stateAgain, | ||
| 487 | "State %i returned when no value requested", | ||
| 488 | stateAgain); | ||
| 489 | |||
| 490 | return TEST_COMPLETED; | ||
| 491 | } | ||
| 492 | |||
| 493 | /* ================= Test References ================== */ | ||
| 494 | |||
| 495 | /* Platform test cases */ | ||
| 496 | static const SDLTest_TestCaseReference platformTest1 = { | ||
| 497 | platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED | ||
| 498 | }; | ||
| 499 | |||
| 500 | static const SDLTest_TestCaseReference platformTest2 = { | ||
| 501 | platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianness and swap functions", TEST_ENABLED | ||
| 502 | }; | ||
| 503 | |||
| 504 | static const SDLTest_TestCaseReference platformTest3 = { | ||
| 505 | platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED | ||
| 506 | }; | ||
| 507 | |||
| 508 | static const SDLTest_TestCaseReference platformTest4 = { | ||
| 509 | platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED | ||
| 510 | }; | ||
| 511 | |||
| 512 | static const SDLTest_TestCaseReference platformTest5 = { | ||
| 513 | platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED | ||
| 514 | }; | ||
| 515 | |||
| 516 | static const SDLTest_TestCaseReference platformTest6 = { | ||
| 517 | platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED | ||
| 518 | }; | ||
| 519 | |||
| 520 | static const SDLTest_TestCaseReference platformTest7 = { | ||
| 521 | platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED | ||
| 522 | }; | ||
| 523 | |||
| 524 | static const SDLTest_TestCaseReference platformTest8 = { | ||
| 525 | platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED | ||
| 526 | }; | ||
| 527 | |||
| 528 | static const SDLTest_TestCaseReference platformTest9 = { | ||
| 529 | platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED | ||
| 530 | }; | ||
| 531 | |||
| 532 | static const SDLTest_TestCaseReference platformTest10 = { | ||
| 533 | platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED | ||
| 534 | }; | ||
| 535 | |||
| 536 | /* Sequence of Platform test cases */ | ||
| 537 | static const SDLTest_TestCaseReference *platformTests[] = { | ||
| 538 | &platformTest1, | ||
| 539 | &platformTest2, | ||
| 540 | &platformTest3, | ||
| 541 | &platformTest4, | ||
| 542 | &platformTest5, | ||
| 543 | &platformTest6, | ||
| 544 | &platformTest7, | ||
| 545 | &platformTest8, | ||
| 546 | &platformTest9, | ||
| 547 | &platformTest10, | ||
| 548 | NULL | ||
| 549 | }; | ||
| 550 | |||
| 551 | /* Platform test suite (global) */ | ||
| 552 | SDLTest_TestSuiteReference platformTestSuite = { | ||
| 553 | "Platform", | ||
| 554 | NULL, | ||
| 555 | platformTests, | ||
| 556 | NULL | ||
| 557 | }; | ||
