* @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 */
| 125 | * @sa http://wiki.libsdl.org/moin.fcg/SDL_FreeFormat |
| 126 | */ |
| 127 | int |
| 128 | pixels_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]; |
nothing calls this directly
no test coverage detected