testautomation_pixels.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. /**
  2. * Pixels test suite
  3. */
  4. #include <stdio.h>
  5. #include "SDL.h"
  6. #include "SDL_test.h"
  7. /* Test case functions */
  8. /* Definition of all RGB formats used to test pixel conversions */
  9. const int _numRGBPixelFormats = 31;
  10. Uint32 _RGBPixelFormats[] = {
  11. SDL_PIXELFORMAT_INDEX1LSB,
  12. SDL_PIXELFORMAT_INDEX1MSB,
  13. SDL_PIXELFORMAT_INDEX4LSB,
  14. SDL_PIXELFORMAT_INDEX4MSB,
  15. SDL_PIXELFORMAT_INDEX8,
  16. SDL_PIXELFORMAT_RGB332,
  17. SDL_PIXELFORMAT_RGB444,
  18. SDL_PIXELFORMAT_BGR444,
  19. SDL_PIXELFORMAT_RGB555,
  20. SDL_PIXELFORMAT_BGR555,
  21. SDL_PIXELFORMAT_ARGB4444,
  22. SDL_PIXELFORMAT_RGBA4444,
  23. SDL_PIXELFORMAT_ABGR4444,
  24. SDL_PIXELFORMAT_BGRA4444,
  25. SDL_PIXELFORMAT_ARGB1555,
  26. SDL_PIXELFORMAT_RGBA5551,
  27. SDL_PIXELFORMAT_ABGR1555,
  28. SDL_PIXELFORMAT_BGRA5551,
  29. SDL_PIXELFORMAT_RGB565,
  30. SDL_PIXELFORMAT_BGR565,
  31. SDL_PIXELFORMAT_RGB24,
  32. SDL_PIXELFORMAT_BGR24,
  33. SDL_PIXELFORMAT_RGB888,
  34. SDL_PIXELFORMAT_RGBX8888,
  35. SDL_PIXELFORMAT_BGR888,
  36. SDL_PIXELFORMAT_BGRX8888,
  37. SDL_PIXELFORMAT_ARGB8888,
  38. SDL_PIXELFORMAT_RGBA8888,
  39. SDL_PIXELFORMAT_ABGR8888,
  40. SDL_PIXELFORMAT_BGRA8888,
  41. SDL_PIXELFORMAT_ARGB2101010
  42. };
  43. const char *_RGBPixelFormatsVerbose[] = {
  44. "SDL_PIXELFORMAT_INDEX1LSB",
  45. "SDL_PIXELFORMAT_INDEX1MSB",
  46. "SDL_PIXELFORMAT_INDEX4LSB",
  47. "SDL_PIXELFORMAT_INDEX4MSB",
  48. "SDL_PIXELFORMAT_INDEX8",
  49. "SDL_PIXELFORMAT_RGB332",
  50. "SDL_PIXELFORMAT_RGB444",
  51. "SDL_PIXELFORMAT_BGR444",
  52. "SDL_PIXELFORMAT_RGB555",
  53. "SDL_PIXELFORMAT_BGR555",
  54. "SDL_PIXELFORMAT_ARGB4444",
  55. "SDL_PIXELFORMAT_RGBA4444",
  56. "SDL_PIXELFORMAT_ABGR4444",
  57. "SDL_PIXELFORMAT_BGRA4444",
  58. "SDL_PIXELFORMAT_ARGB1555",
  59. "SDL_PIXELFORMAT_RGBA5551",
  60. "SDL_PIXELFORMAT_ABGR1555",
  61. "SDL_PIXELFORMAT_BGRA5551",
  62. "SDL_PIXELFORMAT_RGB565",
  63. "SDL_PIXELFORMAT_BGR565",
  64. "SDL_PIXELFORMAT_RGB24",
  65. "SDL_PIXELFORMAT_BGR24",
  66. "SDL_PIXELFORMAT_RGB888",
  67. "SDL_PIXELFORMAT_RGBX8888",
  68. "SDL_PIXELFORMAT_BGR888",
  69. "SDL_PIXELFORMAT_BGRX8888",
  70. "SDL_PIXELFORMAT_ARGB8888",
  71. "SDL_PIXELFORMAT_RGBA8888",
  72. "SDL_PIXELFORMAT_ABGR8888",
  73. "SDL_PIXELFORMAT_BGRA8888",
  74. "SDL_PIXELFORMAT_ARGB2101010"
  75. };
  76. /* Definition of all Non-RGB formats used to test pixel conversions */
  77. const int _numNonRGBPixelFormats = 7;
  78. Uint32 _nonRGBPixelFormats[] = {
  79. SDL_PIXELFORMAT_YV12,
  80. SDL_PIXELFORMAT_IYUV,
  81. SDL_PIXELFORMAT_YUY2,
  82. SDL_PIXELFORMAT_UYVY,
  83. SDL_PIXELFORMAT_YVYU,
  84. SDL_PIXELFORMAT_NV12,
  85. SDL_PIXELFORMAT_NV21
  86. };
  87. const char *_nonRGBPixelFormatsVerbose[] = {
  88. "SDL_PIXELFORMAT_YV12",
  89. "SDL_PIXELFORMAT_IYUV",
  90. "SDL_PIXELFORMAT_YUY2",
  91. "SDL_PIXELFORMAT_UYVY",
  92. "SDL_PIXELFORMAT_YVYU",
  93. "SDL_PIXELFORMAT_NV12",
  94. "SDL_PIXELFORMAT_NV21"
  95. };
  96. /* Definition of some invalid formats for negative tests */
  97. const int _numInvalidPixelFormats = 2;
  98. Uint32 _invalidPixelFormats[] = {
  99. 0xfffffffe,
  100. 0xffffffff
  101. };
  102. const char *_invalidPixelFormatsVerbose[] = {
  103. "SDL_PIXELFORMAT_UNKNOWN",
  104. "SDL_PIXELFORMAT_UNKNOWN"
  105. };
  106. /* Test case functions */
  107. /**
  108. * @brief Call to SDL_AllocFormat and SDL_FreeFormat
  109. *
  110. * @sa http://wiki.libsdl.org/SDL_AllocFormat
  111. * @sa http://wiki.libsdl.org/SDL_FreeFormat
  112. */
  113. int pixels_allocFreeFormat(void *arg)
  114. {
  115. const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN";
  116. const char *expectedError = "Parameter 'format' is invalid";
  117. const char *error;
  118. int i;
  119. Uint32 format;
  120. Uint32 masks;
  121. SDL_PixelFormat *result;
  122. /* Blank/unknown format */
  123. format = 0;
  124. SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", unknownFormat, format);
  125. /* Allocate format */
  126. result = SDL_AllocFormat(format);
  127. SDLTest_AssertPass("Call to SDL_AllocFormat()");
  128. SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
  129. if (result != NULL) {
  130. SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format);
  131. SDLTest_AssertCheck(result->BitsPerPixel == 0, "Verify value of result.BitsPerPixel; expected: 0, got %u", result->BitsPerPixel);
  132. SDLTest_AssertCheck(result->BytesPerPixel == 0, "Verify value of result.BytesPerPixel; expected: 0, got %u", result->BytesPerPixel);
  133. masks = result->Rmask | result->Gmask | result->Bmask | result->Amask;
  134. SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %" SDL_PRIu32, masks);
  135. /* Deallocate again */
  136. SDL_FreeFormat(result);
  137. SDLTest_AssertPass("Call to SDL_FreeFormat()");
  138. }
  139. /* RGB formats */
  140. for (i = 0; i < _numRGBPixelFormats; i++) {
  141. format = _RGBPixelFormats[i];
  142. SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", _RGBPixelFormatsVerbose[i], format);
  143. /* Allocate format */
  144. result = SDL_AllocFormat(format);
  145. SDLTest_AssertPass("Call to SDL_AllocFormat()");
  146. SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
  147. if (result != NULL) {
  148. SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format);
  149. SDLTest_AssertCheck(result->BitsPerPixel > 0, "Verify value of result.BitsPerPixel; expected: >0, got %u", result->BitsPerPixel);
  150. SDLTest_AssertCheck(result->BytesPerPixel > 0, "Verify value of result.BytesPerPixel; expected: >0, got %u", result->BytesPerPixel);
  151. if (result->palette != NULL) {
  152. masks = result->Rmask | result->Gmask | result->Bmask | result->Amask;
  153. SDLTest_AssertCheck(masks > 0, "Verify value of result.[RGBA]mask combined; expected: >0, got %" SDL_PRIu32, masks);
  154. }
  155. /* Deallocate again */
  156. SDL_FreeFormat(result);
  157. SDLTest_AssertPass("Call to SDL_FreeFormat()");
  158. }
  159. }
  160. /* Non-RGB formats */
  161. for (i = 0; i < _numNonRGBPixelFormats; i++) {
  162. format = _nonRGBPixelFormats[i];
  163. SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", _nonRGBPixelFormatsVerbose[i], format);
  164. /* Try to allocate format */
  165. result = SDL_AllocFormat(format);
  166. SDLTest_AssertPass("Call to SDL_AllocFormat()");
  167. SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
  168. }
  169. /* Negative cases */
  170. /* Invalid Formats */
  171. for (i = 0; i < _numInvalidPixelFormats; i++) {
  172. SDL_ClearError();
  173. SDLTest_AssertPass("Call to SDL_ClearError()");
  174. format = _invalidPixelFormats[i];
  175. result = SDL_AllocFormat(format);
  176. SDLTest_AssertPass("Call to SDL_AllocFormat(%" SDL_PRIu32 ")", format);
  177. SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
  178. error = SDL_GetError();
  179. SDLTest_AssertPass("Call to SDL_GetError()");
  180. SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
  181. if (error != NULL) {
  182. SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
  183. "Validate error message, expected: '%s', got: '%s'", expectedError, error);
  184. }
  185. }
  186. /* Invalid free pointer */
  187. SDL_ClearError();
  188. SDLTest_AssertPass("Call to SDL_ClearError()");
  189. SDL_FreeFormat(NULL);
  190. SDLTest_AssertPass("Call to SDL_FreeFormat(NULL)");
  191. error = SDL_GetError();
  192. SDLTest_AssertPass("Call to SDL_GetError()");
  193. SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
  194. if (error != NULL) {
  195. SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
  196. "Validate error message, expected: '%s', got: '%s'", expectedError, error);
  197. }
  198. return TEST_COMPLETED;
  199. }
  200. /**
  201. * @brief Call to SDL_GetPixelFormatName
  202. *
  203. * @sa http://wiki.libsdl.org/SDL_GetPixelFormatName
  204. */
  205. int pixels_getPixelFormatName(void *arg)
  206. {
  207. const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN";
  208. const char *error;
  209. int i;
  210. Uint32 format;
  211. const char *result;
  212. /* Blank/undefined format */
  213. format = 0;
  214. SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", unknownFormat, format);
  215. /* Get name of format */
  216. result = SDL_GetPixelFormatName(format);
  217. SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
  218. SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
  219. if (result != NULL) {
  220. SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty");
  221. SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0,
  222. "Verify result text; expected: %s, got %s", unknownFormat, result);
  223. }
  224. /* RGB formats */
  225. for (i = 0; i < _numRGBPixelFormats; i++) {
  226. format = _RGBPixelFormats[i];
  227. SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", _RGBPixelFormatsVerbose[i], format);
  228. /* Get name of format */
  229. result = SDL_GetPixelFormatName(format);
  230. SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
  231. SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
  232. if (result != NULL) {
  233. SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty");
  234. SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0,
  235. "Verify result text; expected: %s, got %s", _RGBPixelFormatsVerbose[i], result);
  236. }
  237. }
  238. /* Non-RGB formats */
  239. for (i = 0; i < _numNonRGBPixelFormats; i++) {
  240. format = _nonRGBPixelFormats[i];
  241. SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", _nonRGBPixelFormatsVerbose[i], format);
  242. /* Get name of format */
  243. result = SDL_GetPixelFormatName(format);
  244. SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
  245. SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
  246. if (result != NULL) {
  247. SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty");
  248. SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0,
  249. "Verify result text; expected: %s, got %s", _nonRGBPixelFormatsVerbose[i], result);
  250. }
  251. }
  252. /* Negative cases */
  253. /* Invalid Formats */
  254. SDL_ClearError();
  255. SDLTest_AssertPass("Call to SDL_ClearError()");
  256. for (i = 0; i < _numInvalidPixelFormats; i++) {
  257. format = _invalidPixelFormats[i];
  258. result = SDL_GetPixelFormatName(format);
  259. SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%" SDL_PRIu32 ")", format);
  260. SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
  261. if (result != NULL) {
  262. SDLTest_AssertCheck(result[0] != '\0',
  263. "Verify result is non-empty; got: %s", result);
  264. SDLTest_AssertCheck(SDL_strcmp(result, _invalidPixelFormatsVerbose[i]) == 0,
  265. "Validate name is UNKNOWN, expected: '%s', got: '%s'", _invalidPixelFormatsVerbose[i], result);
  266. }
  267. error = SDL_GetError();
  268. SDLTest_AssertPass("Call to SDL_GetError()");
  269. SDLTest_AssertCheck(error == NULL || error[0] == '\0', "Validate that error message is empty");
  270. }
  271. return TEST_COMPLETED;
  272. }
  273. /**
  274. * @brief Call to SDL_AllocPalette and SDL_FreePalette
  275. *
  276. * @sa http://wiki.libsdl.org/SDL_AllocPalette
  277. * @sa http://wiki.libsdl.org/SDL_FreePalette
  278. */
  279. int pixels_allocFreePalette(void *arg)
  280. {
  281. const char *expectedError1 = "Parameter 'ncolors' is invalid";
  282. const char *expectedError2 = "Parameter 'palette' is invalid";
  283. const char *error;
  284. int variation;
  285. int i;
  286. int ncolors;
  287. SDL_Palette *result;
  288. /* Allocate palette */
  289. for (variation = 1; variation <= 3; variation++) {
  290. switch (variation) {
  291. /* Just one color */
  292. default:
  293. case 1:
  294. ncolors = 1;
  295. break;
  296. /* Two colors */
  297. case 2:
  298. ncolors = 2;
  299. break;
  300. /* More than two colors */
  301. case 3:
  302. ncolors = SDLTest_RandomIntegerInRange(8, 16);
  303. break;
  304. }
  305. result = SDL_AllocPalette(ncolors);
  306. SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors);
  307. SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
  308. if (result != NULL) {
  309. SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors);
  310. if (result->ncolors > 0) {
  311. SDLTest_AssertCheck(result->colors != NULL, "Verify value of result.colors is not NULL");
  312. if (result->colors != NULL) {
  313. for (i = 0; i < result->ncolors; i++) {
  314. SDLTest_AssertCheck(result->colors[i].r == 255, "Verify value of result.colors[%d].r; expected: 255, got %u", i, result->colors[i].r);
  315. SDLTest_AssertCheck(result->colors[i].g == 255, "Verify value of result.colors[%d].g; expected: 255, got %u", i, result->colors[i].g);
  316. SDLTest_AssertCheck(result->colors[i].b == 255, "Verify value of result.colors[%d].b; expected: 255, got %u", i, result->colors[i].b);
  317. }
  318. }
  319. }
  320. /* Deallocate again */
  321. SDL_FreePalette(result);
  322. SDLTest_AssertPass("Call to SDL_FreePalette()");
  323. }
  324. }
  325. /* Negative cases */
  326. /* Invalid number of colors */
  327. for (ncolors = 0; ncolors > -3; ncolors--) {
  328. SDL_ClearError();
  329. SDLTest_AssertPass("Call to SDL_ClearError()");
  330. result = SDL_AllocPalette(ncolors);
  331. SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors);
  332. SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
  333. error = SDL_GetError();
  334. SDLTest_AssertPass("Call to SDL_GetError()");
  335. SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
  336. if (error != NULL) {
  337. SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0,
  338. "Validate error message, expected: '%s', got: '%s'", expectedError1, error);
  339. }
  340. }
  341. /* Invalid free pointer */
  342. SDL_ClearError();
  343. SDLTest_AssertPass("Call to SDL_ClearError()");
  344. SDL_FreePalette(NULL);
  345. SDLTest_AssertPass("Call to SDL_FreePalette(NULL)");
  346. error = SDL_GetError();
  347. SDLTest_AssertPass("Call to SDL_GetError()");
  348. SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
  349. if (error != NULL) {
  350. SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0,
  351. "Validate error message, expected: '%s', got: '%s'", expectedError2, error);
  352. }
  353. return TEST_COMPLETED;
  354. }
  355. /**
  356. * @brief Call to SDL_CalculateGammaRamp
  357. *
  358. * @sa http://wiki.libsdl.org/SDL_CalculateGammaRamp
  359. */
  360. int
  361. pixels_calcGammaRamp(void *arg)
  362. {
  363. const char *expectedError1 = "Parameter 'gamma' is invalid";
  364. const char *expectedError2 = "Parameter 'ramp' is invalid";
  365. const char *error;
  366. float gamma;
  367. Uint16 *ramp;
  368. int variation;
  369. int i;
  370. int changed;
  371. Uint16 magic = 0xbeef;
  372. /* Allocate temp ramp array and fill with some value */
  373. ramp = (Uint16 *)SDL_malloc(256 * sizeof(Uint16));
  374. SDLTest_AssertCheck(ramp != NULL, "Validate temp ramp array could be allocated");
  375. if (ramp == NULL) return TEST_ABORTED;
  376. /* Make call with different gamma values */
  377. for (variation = 0; variation < 4; variation++) {
  378. switch (variation) {
  379. /* gamma = 0 all black */
  380. default:
  381. case 0:
  382. gamma = 0.0f;
  383. break;
  384. /* gamma = 1 identity */
  385. case 1:
  386. gamma = 1.0f;
  387. break;
  388. /* gamma = [0.2,0.8] normal range */
  389. case 2:
  390. gamma = 0.2f + 0.8f * SDLTest_RandomUnitFloat();
  391. break;
  392. /* gamma = >1.1 non-standard range */
  393. case 3:
  394. gamma = 1.1f + SDLTest_RandomUnitFloat();
  395. break;
  396. }
  397. /* Make call and check that values were updated */
  398. for (i = 0; i < 256; i++) ramp[i] = magic;
  399. SDL_CalculateGammaRamp(gamma, ramp);
  400. SDLTest_AssertPass("Call to SDL_CalculateGammaRamp(%f)", gamma);
  401. changed = 0;
  402. for (i = 0; i < 256; i++) if (ramp[i] != magic) changed++;
  403. SDLTest_AssertCheck(changed > 250, "Validate that ramp was calculated; expected: >250 values changed, got: %d values changed", changed);
  404. /* Additional value checks for some cases */
  405. i = SDLTest_RandomIntegerInRange(64,192);
  406. switch (variation) {
  407. case 0:
  408. SDLTest_AssertCheck(ramp[i] == 0, "Validate value at position %d; expected: 0, got: %d", i, ramp[i]);
  409. break;
  410. case 1:
  411. SDLTest_AssertCheck(ramp[i] == ((i << 8) | i), "Validate value at position %d; expected: %d, got: %d", i, (i << 8) | i, ramp[i]);
  412. break;
  413. case 2:
  414. case 3:
  415. SDLTest_AssertCheck(ramp[i] > 0, "Validate value at position %d; expected: >0, got: %d", i, ramp[i]);
  416. break;
  417. }
  418. }
  419. /* Negative cases */
  420. SDL_ClearError();
  421. SDLTest_AssertPass("Call to SDL_ClearError()");
  422. gamma = -1;
  423. for (i=0; i<256; i++) ramp[i] = magic;
  424. SDL_CalculateGammaRamp(gamma, ramp);
  425. SDLTest_AssertPass("Call to SDL_CalculateGammaRamp(%f)", gamma);
  426. error = SDL_GetError();
  427. SDLTest_AssertPass("Call to SDL_GetError()");
  428. SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
  429. if (error != NULL) {
  430. SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0,
  431. "Validate error message, expected: '%s', got: '%s'", expectedError1, error);
  432. }
  433. changed = 0;
  434. for (i = 0; i < 256; i++) if (ramp[i] != magic) changed++;
  435. SDLTest_AssertCheck(changed ==0, "Validate that ramp unchanged; expected: 0 values changed got: %d values changed", changed);
  436. SDL_CalculateGammaRamp(0.5f, NULL);
  437. SDLTest_AssertPass("Call to SDL_CalculateGammaRamp(0.5,NULL)");
  438. error = SDL_GetError();
  439. SDLTest_AssertPass("Call to SDL_GetError()");
  440. SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
  441. if (error != NULL) {
  442. SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0,
  443. "Validate error message, expected: '%s', got: '%s'", expectedError2, error);
  444. }
  445. /* Cleanup */
  446. SDL_free(ramp);
  447. return TEST_COMPLETED;
  448. }
  449. /* ================= Test References ================== */
  450. /* Pixels test cases */
  451. static const SDLTest_TestCaseReference pixelsTest1 = {
  452. (SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_AllocFormat and SDL_FreeFormat", TEST_ENABLED
  453. };
  454. static const SDLTest_TestCaseReference pixelsTest2 = {
  455. (SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_AllocPalette and SDL_FreePalette", TEST_ENABLED
  456. };
  457. static const SDLTest_TestCaseReference pixelsTest3 =
  458. { (SDLTest_TestCaseFp)pixels_calcGammaRamp, "pixels_calcGammaRamp", "Call to SDL_CalculateGammaRamp", TEST_ENABLED };
  459. static const SDLTest_TestCaseReference pixelsTest4 =
  460. { (SDLTest_TestCaseFp)pixels_getPixelFormatName, "pixels_getPixelFormatName", "Call to SDL_GetPixelFormatName", TEST_ENABLED };
  461. /* Sequence of Pixels test cases */
  462. static const SDLTest_TestCaseReference *pixelsTests[] = {
  463. &pixelsTest1, &pixelsTest2, &pixelsTest3, &pixelsTest4, NULL
  464. };
  465. /* Pixels test suite (global) */
  466. SDLTest_TestSuiteReference pixelsTestSuite = {
  467. "Pixels",
  468. NULL,
  469. pixelsTests,
  470. NULL
  471. };