MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / pixels_allocFreeFormat

Function pixels_allocFreeFormat

deps/SDL2/test/testautomation_pixels.c:127–226  ·  view source on GitHub ↗

* @brief Call to SDL_AllocFormat and SDL_FreeFormat * * @sa http://wiki.libsdl.org/moin.fcg/SDL_AllocFormat * @sa http://wiki.libsdl.org/moin.fcg/SDL_FreeFormat */

Source from the content-addressed store, hash-verified

125 * @sa http://wiki.libsdl.org/moin.fcg/SDL_FreeFormat
126 */
127int
128pixels_allocFreeFormat(void *arg)
129{
130 const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN";
131 const char *expectedError = "Parameter 'format' is invalid";
132 const char *error;
133 int i;
134 Uint32 format;
135 Uint32 masks;
136 SDL_PixelFormat* result;
137
138 /* Blank/unknown format */
139 format = 0;
140 SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format);
141
142 /* Allocate format */
143 result = SDL_AllocFormat(format);
144 SDLTest_AssertPass("Call to SDL_AllocFormat()");
145 SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
146 if (result != NULL) {
147 SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format);
148 SDLTest_AssertCheck(result->BitsPerPixel == 0, "Verify value of result.BitsPerPixel; expected: 0, got %u", result->BitsPerPixel);
149 SDLTest_AssertCheck(result->BytesPerPixel == 0, "Verify value of result.BytesPerPixel; expected: 0, got %u", result->BytesPerPixel);
150 masks = result->Rmask | result->Gmask | result->Bmask | result->Amask;
151 SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %u", masks);
152
153 /* Deallocate again */
154 SDL_FreeFormat(result);
155 SDLTest_AssertPass("Call to SDL_FreeFormat()");
156 }
157
158 /* RGB formats */
159 for (i = 0; i < _numRGBPixelFormats; i++) {
160 format = _RGBPixelFormats[i];
161 SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format);
162
163 /* Allocate format */
164 result = SDL_AllocFormat(format);
165 SDLTest_AssertPass("Call to SDL_AllocFormat()");
166 SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
167 if (result != NULL) {
168 SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format);
169 SDLTest_AssertCheck(result->BitsPerPixel > 0, "Verify value of result.BitsPerPixel; expected: >0, got %u", result->BitsPerPixel);
170 SDLTest_AssertCheck(result->BytesPerPixel > 0, "Verify value of result.BytesPerPixel; expected: >0, got %u", result->BytesPerPixel);
171 if (result->palette != NULL) {
172 masks = result->Rmask | result->Gmask | result->Bmask | result->Amask;
173 SDLTest_AssertCheck(masks > 0, "Verify value of result.[RGBA]mask combined; expected: >0, got %u", masks);
174 }
175
176 /* Deallocate again */
177 SDL_FreeFormat(result);
178 SDLTest_AssertPass("Call to SDL_FreeFormat()");
179 }
180 }
181
182 /* Non-RGB formats */
183 for (i = 0; i < _numNonRGBPixelFormats; i++) {
184 format = _nonRGBPixelFormats[i];

Callers

nothing calls this directly

Calls 8

SDLTest_LogFunction · 0.85
SDL_AllocFormatFunction · 0.85
SDLTest_AssertPassFunction · 0.85
SDLTest_AssertCheckFunction · 0.85
SDL_FreeFormatFunction · 0.85
SDL_ClearErrorFunction · 0.85
SDL_GetErrorFunction · 0.85
SDL_strcmpFunction · 0.85

Tested by

no test coverage detected