testautomation_pixels.c 18 KB

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