test/testautomation_pixels.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 19:59:00 -0400
changeset 10266 c09f06c4e8c8
parent 9046 c3ec7c3e6c24
permissions -rw-r--r--
emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     1
/**
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
 * Pixels test suite
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
 */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     5
#include <stdio.h>
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     6
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     7
#include "SDL.h"
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     8
#include "SDL_test.h"
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     9
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    10
/* Test case functions */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    11
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    12
/* Definition of all RGB formats used to test pixel conversions */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    13
const int _numRGBPixelFormats = 30;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
    14
Uint32 _RGBPixelFormats[] =
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    15
  {
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    16
    SDL_PIXELFORMAT_INDEX1LSB,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    17
    SDL_PIXELFORMAT_INDEX1MSB,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    18
    SDL_PIXELFORMAT_INDEX4LSB,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    19
    SDL_PIXELFORMAT_INDEX4MSB,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    20
    SDL_PIXELFORMAT_INDEX8,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    21
    SDL_PIXELFORMAT_RGB332,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    22
    SDL_PIXELFORMAT_RGB444,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    23
    SDL_PIXELFORMAT_RGB555,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    24
    SDL_PIXELFORMAT_BGR555,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    25
    SDL_PIXELFORMAT_ARGB4444,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    26
    SDL_PIXELFORMAT_RGBA4444,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    27
    SDL_PIXELFORMAT_ABGR4444,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    28
    SDL_PIXELFORMAT_BGRA4444,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    29
    SDL_PIXELFORMAT_ARGB1555,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    30
    SDL_PIXELFORMAT_RGBA5551,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    31
    SDL_PIXELFORMAT_ABGR1555,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    32
    SDL_PIXELFORMAT_BGRA5551,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    33
    SDL_PIXELFORMAT_RGB565,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    34
    SDL_PIXELFORMAT_BGR565,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    35
    SDL_PIXELFORMAT_RGB24,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    36
    SDL_PIXELFORMAT_BGR24,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    37
    SDL_PIXELFORMAT_RGB888,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    38
    SDL_PIXELFORMAT_RGBX8888,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    39
    SDL_PIXELFORMAT_BGR888,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    40
    SDL_PIXELFORMAT_BGRX8888,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    41
    SDL_PIXELFORMAT_ARGB8888,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    42
    SDL_PIXELFORMAT_RGBA8888,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    43
    SDL_PIXELFORMAT_ABGR8888,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    44
    SDL_PIXELFORMAT_BGRA8888,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    45
    SDL_PIXELFORMAT_ARGB2101010
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    46
  };
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
    47
char* _RGBPixelFormatsVerbose[] =
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    48
  {
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    49
    "SDL_PIXELFORMAT_INDEX1LSB",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    50
    "SDL_PIXELFORMAT_INDEX1MSB",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    51
    "SDL_PIXELFORMAT_INDEX4LSB",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    52
    "SDL_PIXELFORMAT_INDEX4MSB",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    53
    "SDL_PIXELFORMAT_INDEX8",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    54
    "SDL_PIXELFORMAT_RGB332",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    55
    "SDL_PIXELFORMAT_RGB444",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    56
    "SDL_PIXELFORMAT_RGB555",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    57
    "SDL_PIXELFORMAT_BGR555",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    58
    "SDL_PIXELFORMAT_ARGB4444",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    59
    "SDL_PIXELFORMAT_RGBA4444",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    60
    "SDL_PIXELFORMAT_ABGR4444",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    61
    "SDL_PIXELFORMAT_BGRA4444",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    62
    "SDL_PIXELFORMAT_ARGB1555",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    63
    "SDL_PIXELFORMAT_RGBA5551",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    64
    "SDL_PIXELFORMAT_ABGR1555",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    65
    "SDL_PIXELFORMAT_BGRA5551",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    66
    "SDL_PIXELFORMAT_RGB565",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    67
    "SDL_PIXELFORMAT_BGR565",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    68
    "SDL_PIXELFORMAT_RGB24",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    69
    "SDL_PIXELFORMAT_BGR24",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
    "SDL_PIXELFORMAT_RGB888",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
    "SDL_PIXELFORMAT_RGBX8888",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    72
    "SDL_PIXELFORMAT_BGR888",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    73
    "SDL_PIXELFORMAT_BGRX8888",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    74
    "SDL_PIXELFORMAT_ARGB8888",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    75
    "SDL_PIXELFORMAT_RGBA8888",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    76
    "SDL_PIXELFORMAT_ABGR8888",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    77
    "SDL_PIXELFORMAT_BGRA8888",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    78
    "SDL_PIXELFORMAT_ARGB2101010"
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
  };
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    80
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    81
/* Definition of all Non-RGB formats used to test pixel conversions */
9046
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 7879
diff changeset
    82
const int _numNonRGBPixelFormats = 7;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
    83
Uint32 _nonRGBPixelFormats[] =
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    84
  {
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    85
    SDL_PIXELFORMAT_YV12,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    86
    SDL_PIXELFORMAT_IYUV,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    87
    SDL_PIXELFORMAT_YUY2,
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    88
    SDL_PIXELFORMAT_UYVY,
9046
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 7879
diff changeset
    89
    SDL_PIXELFORMAT_YVYU,
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 7879
diff changeset
    90
    SDL_PIXELFORMAT_NV12,
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 7879
diff changeset
    91
    SDL_PIXELFORMAT_NV21
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    92
  };
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
    93
char* _nonRGBPixelFormatsVerbose[] =
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    94
  {
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    95
    "SDL_PIXELFORMAT_YV12",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    96
    "SDL_PIXELFORMAT_IYUV",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    97
    "SDL_PIXELFORMAT_YUY2",
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    98
    "SDL_PIXELFORMAT_UYVY",
9046
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 7879
diff changeset
    99
    "SDL_PIXELFORMAT_YVYU",
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 7879
diff changeset
   100
    "SDL_PIXELFORMAT_NV12",
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 7879
diff changeset
   101
    "SDL_PIXELFORMAT_NV21"
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   102
  };
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   103
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   104
/* Definition of some invalid formats for negative tests */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   105
const int _numInvalidPixelFormats = 2;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   106
Uint32 _invalidPixelFormats[] =
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   107
  {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   108
    0xfffffffe,
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   109
    0xffffffff
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   110
  };
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   111
char* _invalidPixelFormatsVerbose[] =
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   112
  {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   113
    "SDL_PIXELFORMAT_UNKNOWN",
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   114
    "SDL_PIXELFORMAT_UNKNOWN"
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   115
  };
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   116
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   117
/* Test case functions */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   118
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   119
/**
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   120
 * @brief Call to SDL_AllocFormat and SDL_FreeFormat
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   121
 *
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   122
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_AllocFormat
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   123
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_FreeFormat
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   124
 */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   125
int
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   126
pixels_allocFreeFormat(void *arg)
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   127
{
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   128
  const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN";
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   129
  const char *expectedError = "Parameter 'format' is invalid";
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   130
  const char *error;
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   131
  int i;
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   132
  Uint32 format;
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   133
  Uint32 masks;
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   134
  SDL_PixelFormat* result;
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   135
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   136
  /* Blank/unknown format */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   137
  format = 0;
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   138
  SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   139
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   140
  /* Allocate format */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   141
  result = SDL_AllocFormat(format);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   142
  SDLTest_AssertPass("Call to SDL_AllocFormat()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   143
  SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   144
  if (result != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   145
    SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   146
    SDLTest_AssertCheck(result->BitsPerPixel == 0, "Verify value of result.BitsPerPixel; expected: 0, got %u", result->BitsPerPixel);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   147
    SDLTest_AssertCheck(result->BytesPerPixel == 0, "Verify value of result.BytesPerPixel; expected: 0, got %u", result->BytesPerPixel);
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   148
    masks = result->Rmask | result->Gmask | result->Bmask | result->Amask;
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   149
    SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %u", masks);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   150
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   151
    /* Deallocate again */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   152
    SDL_FreeFormat(result);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   153
    SDLTest_AssertPass("Call to SDL_FreeFormat()");
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   154
  }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   155
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   156
  /* RGB formats */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   157
  for (i = 0; i < _numRGBPixelFormats; i++) {
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   158
    format = _RGBPixelFormats[i];
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   159
    SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   160
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   161
    /* Allocate format */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   162
    result = SDL_AllocFormat(format);
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   163
    SDLTest_AssertPass("Call to SDL_AllocFormat()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   164
    SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   165
    if (result != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   166
      SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   167
      SDLTest_AssertCheck(result->BitsPerPixel > 0, "Verify value of result.BitsPerPixel; expected: >0, got %u", result->BitsPerPixel);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   168
      SDLTest_AssertCheck(result->BytesPerPixel > 0, "Verify value of result.BytesPerPixel; expected: >0, got %u", result->BytesPerPixel);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   169
      if (result->palette != NULL) {
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   170
         masks = result->Rmask | result->Gmask | result->Bmask | result->Amask;
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   171
         SDLTest_AssertCheck(masks > 0, "Verify value of result.[RGBA]mask combined; expected: >0, got %u", masks);
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   172
      }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   173
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   174
      /* Deallocate again */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   175
      SDL_FreeFormat(result);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   176
      SDLTest_AssertPass("Call to SDL_FreeFormat()");
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   177
    }
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   178
  }
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   179
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   180
  /* Non-RGB formats */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   181
  for (i = 0; i < _numNonRGBPixelFormats; i++) {
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   182
    format = _nonRGBPixelFormats[i];
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   183
    SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   184
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   185
    /* Try to allocate format */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   186
    result = SDL_AllocFormat(format);
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   187
    SDLTest_AssertPass("Call to SDL_AllocFormat()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   188
    SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   189
  }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   190
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   191
  /* Negative cases */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   192
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   193
  /* Invalid Formats */
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   194
  for (i = 0; i < _numInvalidPixelFormats; i++) {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   195
    SDL_ClearError();
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   196
    SDLTest_AssertPass("Call to SDL_ClearError()");
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   197
    format = _invalidPixelFormats[i];
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   198
    result = SDL_AllocFormat(format);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   199
    SDLTest_AssertPass("Call to SDL_AllocFormat(%u)", format);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   200
    SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   201
    error = SDL_GetError();
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   202
    SDLTest_AssertPass("Call to SDL_GetError()");
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   203
    SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   204
    if (error != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   205
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   206
          "Validate error message, expected: '%s', got: '%s'", expectedError, error);
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   207
    }
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   208
  }
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   209
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   210
  /* Invalid free pointer */
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   211
  SDL_ClearError();
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   212
  SDLTest_AssertPass("Call to SDL_ClearError()");
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   213
  SDL_FreeFormat(NULL);
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   214
  SDLTest_AssertPass("Call to SDL_FreeFormat(NULL)");
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   215
  error = SDL_GetError();
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   216
  SDLTest_AssertPass("Call to SDL_GetError()");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   217
  SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   218
  if (error != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   219
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   220
          "Validate error message, expected: '%s', got: '%s'", expectedError, error);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   221
  }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   222
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   223
  return TEST_COMPLETED;
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   224
}
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   225
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   226
/**
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   227
 * @brief Call to SDL_GetPixelFormatName
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   228
 *
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   229
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetPixelFormatName
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   230
 */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   231
int
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   232
pixels_getPixelFormatName(void *arg)
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   233
{
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   234
  const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN";
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   235
  const char *error;
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   236
  int i;
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   237
  Uint32 format;
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   238
  char* result;
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   239
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   240
  /* Blank/undefined format */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   241
  format = 0;
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   242
  SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   243
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   244
  /* Get name of format */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   245
  result = (char *)SDL_GetPixelFormatName(format);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   246
  SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   247
  SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   248
  if (result != NULL) {
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7677
diff changeset
   249
      SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   250
      SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0,
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   251
        "Verify result text; expected: %s, got %s", unknownFormat, result);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   252
  }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   253
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   254
  /* RGB formats */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   255
  for (i = 0; i < _numRGBPixelFormats; i++) {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   256
    format = _RGBPixelFormats[i];
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   257
    SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   258
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   259
    /* Get name of format */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   260
    result = (char *)SDL_GetPixelFormatName(format);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   261
    SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   262
    SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   263
    if (result != NULL) {
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7677
diff changeset
   264
      SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   265
      SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0,
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   266
        "Verify result text; expected: %s, got %s", _RGBPixelFormatsVerbose[i], result);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   267
    }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   268
  }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   269
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   270
  /* Non-RGB formats */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   271
  for (i = 0; i < _numNonRGBPixelFormats; i++) {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   272
    format = _nonRGBPixelFormats[i];
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   273
    SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   274
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   275
    /* Get name of format */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   276
    result = (char *)SDL_GetPixelFormatName(format);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   277
    SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   278
    SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   279
    if (result != NULL) {
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7677
diff changeset
   280
      SDLTest_AssertCheck(result[0] != '\0', "Verify result is non-empty");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   281
      SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0,
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   282
        "Verify result text; expected: %s, got %s", _nonRGBPixelFormatsVerbose[i], result);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   283
    }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   284
  }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   285
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   286
  /* Negative cases */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   287
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   288
  /* Invalid Formats */
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   289
  SDL_ClearError();
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   290
  SDLTest_AssertPass("Call to SDL_ClearError()");
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   291
  for (i = 0; i < _numInvalidPixelFormats; i++) {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   292
    format = _invalidPixelFormats[i];
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   293
    result = (char *)SDL_GetPixelFormatName(format);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   294
    SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   295
    SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   296
    if (result != NULL) {
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7677
diff changeset
   297
      SDLTest_AssertCheck(result[0] != '\0',
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   298
        "Verify result is non-empty; got: %s", result);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   299
      SDLTest_AssertCheck(SDL_strcmp(result, _invalidPixelFormatsVerbose[i]) == 0,
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   300
        "Validate name is UNKNOWN, expected: '%s', got: '%s'", _invalidPixelFormatsVerbose[i], result);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   301
    }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   302
    error = SDL_GetError();
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   303
    SDLTest_AssertPass("Call to SDL_GetError()");
7879
cee8a400dc51 Fix error assert for negative cases of pixels_getPixelFormatName test
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
   304
    SDLTest_AssertCheck(error == NULL || error[0] == '\0', "Validate that error message is empty");
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   305
  }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   306
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   307
  return TEST_COMPLETED;
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   308
}
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   309
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   310
/**
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   311
 * @brief Call to SDL_AllocPalette and SDL_FreePalette
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   312
 *
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   313
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_AllocPalette
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   314
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_FreePalette
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   315
 */
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   316
int
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   317
pixels_allocFreePalette(void *arg)
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   318
{
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   319
  const char *expectedError1 = "Parameter 'ncolors' is invalid";
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   320
  const char *expectedError2 = "Parameter 'palette' is invalid";
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   321
  const char *error;
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   322
  int variation;
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   323
  int i;
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   324
  int ncolors;
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   325
  SDL_Palette* result;
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   326
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   327
  /* Allocate palette */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   328
  for (variation = 1; variation <= 3; variation++) {
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   329
    switch (variation) {
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   330
      /* Just one color */
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   331
      case 1:
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   332
        ncolors = 1;
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   333
        break;
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   334
      /* Two colors */
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   335
      case 2:
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   336
        ncolors = 2;
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   337
        break;
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   338
      /* More than two colors */
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   339
      case 3:
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   340
        ncolors = SDLTest_RandomIntegerInRange(8, 16);
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   341
        break;
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   342
    }
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   343
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   344
    result = SDL_AllocPalette(ncolors);
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   345
    SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   346
    SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   347
    if (result != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   348
      SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors);
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   349
      if (result->ncolors > 0) {
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   350
        SDLTest_AssertCheck(result->colors != NULL, "Verify value of result.colors is not NULL");
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   351
        if (result->colors != NULL) {
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   352
          for(i = 0; i < result->ncolors; i++) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   353
            SDLTest_AssertCheck(result->colors[i].r == 255, "Verify value of result.colors[%d].r; expected: 255, got %u", i, result->colors[i].r);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   354
            SDLTest_AssertCheck(result->colors[i].g == 255, "Verify value of result.colors[%d].g; expected: 255, got %u", i, result->colors[i].g);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   355
            SDLTest_AssertCheck(result->colors[i].b == 255, "Verify value of result.colors[%d].b; expected: 255, got %u", i, result->colors[i].b);
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   356
           }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   357
         }
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   358
      }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   359
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   360
      /* Deallocate again */
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   361
      SDL_FreePalette(result);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   362
      SDLTest_AssertPass("Call to SDL_FreePalette()");
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   363
    }
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   364
  }
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   365
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   366
  /* Negative cases */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   367
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   368
  /* Invalid number of colors */
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   369
  for (ncolors = 0; ncolors > -3; ncolors--) {
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   370
    SDL_ClearError();
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   371
    SDLTest_AssertPass("Call to SDL_ClearError()");
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   372
    result = SDL_AllocPalette(ncolors);
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   373
    SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors);
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   374
    SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   375
    error = SDL_GetError();
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   376
    SDLTest_AssertPass("Call to SDL_GetError()");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   377
    SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   378
    if (error != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   379
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0,
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   380
          "Validate error message, expected: '%s', got: '%s'", expectedError1, error);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   381
    }
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   382
  }
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   383
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   384
  /* Invalid free pointer */
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   385
  SDL_ClearError();
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   386
  SDLTest_AssertPass("Call to SDL_ClearError()");
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   387
  SDL_FreePalette(NULL);
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   388
  SDLTest_AssertPass("Call to SDL_FreePalette(NULL)");
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   389
  error = SDL_GetError();
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   390
  SDLTest_AssertPass("Call to SDL_GetError()");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   391
  SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   392
  if (error != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   393
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0,
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   394
          "Validate error message, expected: '%s', got: '%s'", expectedError2, error);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   395
  }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   396
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   397
  return TEST_COMPLETED;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   398
}
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   399
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   400
/**
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   401
 * @brief Call to SDL_CalculateGammaRamp
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   402
 *
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   403
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_CalculateGammaRamp
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   404
 */
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   405
int
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   406
pixels_calcGammaRamp(void *arg)
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   407
{
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   408
  const char *expectedError1 = "Parameter 'gamma' is invalid";
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   409
  const char *expectedError2 = "Parameter 'ramp' is invalid";
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   410
  const char *error;
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   411
  float gamma;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   412
  Uint16 *ramp;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   413
  int variation;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   414
  int i;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   415
  int changed;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   416
  Uint16 magic = 0xbeef;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   417
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
   418
  /* Allocate temp ramp array and fill with some value */
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   419
  ramp = (Uint16 *)SDL_malloc(256 * sizeof(Uint16));
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   420
  SDLTest_AssertCheck(ramp != NULL, "Validate temp ramp array could be allocated");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   421
  if (ramp == NULL) return TEST_ABORTED;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   422
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   423
  /* Make call with different gamma values */
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   424
  for (variation = 0; variation < 4; variation++) {
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   425
    switch (variation) {
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   426
      /* gamma = 0 all black */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   427
      case 0:
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   428
        gamma = 0.0f;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   429
        break;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   430
      /* gamma = 1 identity */
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   431
      case 1:
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   432
        gamma = 1.0f;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   433
        break;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   434
      /* gamma = [0.2,0.8] normal range */
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   435
      case 2:
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   436
        gamma = 0.2f + 0.8f * SDLTest_RandomUnitFloat();
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   437
        break;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   438
      /* gamma = >1.1 non-standard range */
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   439
      case 3:
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   440
        gamma = 1.1f + SDLTest_RandomUnitFloat();
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   441
        break;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   442
    }
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   443
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   444
    /* Make call and check that values were updated */
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   445
    for (i = 0; i < 256; i++) ramp[i] = magic;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   446
    SDL_CalculateGammaRamp(gamma, ramp);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   447
    SDLTest_AssertPass("Call to SDL_CalculateGammaRamp(%f)", gamma);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   448
    changed = 0;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   449
    for (i = 0; i < 256; i++) if (ramp[i] != magic) changed++;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   450
    SDLTest_AssertCheck(changed > 250, "Validate that ramp was calculated; expected: >250 values changed, got: %d values changed", changed);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   451
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   452
    /* Additional value checks for some cases */
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   453
    i = SDLTest_RandomIntegerInRange(64,192);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   454
    switch (variation) {
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   455
      case 0:
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   456
        SDLTest_AssertCheck(ramp[i] == 0, "Validate value at position %d; expected: 0, got: %d", i, ramp[i]);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   457
        break;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   458
      case 1:
7162
f2fb5a030227 Fixed precedence warning in test suite for pixels.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7153
diff changeset
   459
        SDLTest_AssertCheck(ramp[i] == ((i << 8) | i), "Validate value at position %d; expected: %d, got: %d", i, (i << 8) | i, ramp[i]);
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   460
        break;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   461
      case 2:
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   462
      case 3:
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   463
        SDLTest_AssertCheck(ramp[i] > 0, "Validate value at position %d; expected: >0, got: %d", i, ramp[i]);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   464
        break;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   465
    }
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   466
  }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   467
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   468
  /* Negative cases */
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   469
  SDL_ClearError();
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   470
  SDLTest_AssertPass("Call to SDL_ClearError()");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   471
  gamma = -1;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   472
  for (i=0; i<256; i++) ramp[i] = magic;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   473
  SDL_CalculateGammaRamp(gamma, ramp);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   474
  SDLTest_AssertPass("Call to SDL_CalculateGammaRamp(%f)", gamma);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   475
  error = SDL_GetError();
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   476
  SDLTest_AssertPass("Call to SDL_GetError()");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   477
  SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   478
  if (error != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   479
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0,
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   480
          "Validate error message, expected: '%s', got: '%s'", expectedError1, error);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   481
  }
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   482
  changed = 0;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   483
  for (i = 0; i < 256; i++) if (ramp[i] != magic) changed++;
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   484
  SDLTest_AssertCheck(changed ==0, "Validate that ramp unchanged; expected: 0 values changed got: %d values changed", changed);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   485
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   486
  SDL_CalculateGammaRamp(0.5f, NULL);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   487
  SDLTest_AssertPass("Call to SDL_CalculateGammaRamp(0.5,NULL)");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   488
  error = SDL_GetError();
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   489
  SDLTest_AssertPass("Call to SDL_GetError()");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   490
  SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   491
  if (error != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   492
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0,
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   493
          "Validate error message, expected: '%s', got: '%s'", expectedError2, error);
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   494
  }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   495
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   496
  /* Cleanup */
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   497
  SDL_free(ramp);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   498
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   499
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   500
  return TEST_COMPLETED;
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   501
}
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   502
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   503
/* ================= Test References ================== */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   504
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   505
/* Pixels test cases */
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   506
static const SDLTest_TestCaseReference pixelsTest1 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   507
        { (SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_AllocFormat and SDL_FreeFormat", TEST_ENABLED };
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   508
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   509
static const SDLTest_TestCaseReference pixelsTest2 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   510
        { (SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_AllocPalette and SDL_FreePalette", TEST_ENABLED };
7142
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   511
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   512
static const SDLTest_TestCaseReference pixelsTest3 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   513
        { (SDLTest_TestCaseFp)pixels_calcGammaRamp, "pixels_calcGammaRamp", "Call to SDL_CalculateGammaRamp", TEST_ENABLED };
7151
99a4964db4c3 Add input validation to SDL_CalculateGammaRamp; add test coverage to Pixels suite; update test cases in Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7142
diff changeset
   514
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   515
static const SDLTest_TestCaseReference pixelsTest4 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   516
        { (SDLTest_TestCaseFp)pixels_getPixelFormatName, "pixels_getPixelFormatName", "Call to SDL_GetPixelFormatName", TEST_ENABLED };
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   517
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   518
/* Sequence of Pixels test cases */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   519
static const SDLTest_TestCaseReference *pixelsTests[] =  {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   520
    &pixelsTest1, &pixelsTest2, &pixelsTest3, &pixelsTest4, NULL
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   521
};
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   522
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   523
/* Pixels test suite (global) */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   524
SDLTest_TestSuiteReference pixelsTestSuite = {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   525
    "Pixels",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   526
    NULL,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   527
    pixelsTests,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7162
diff changeset
   528
    NULL
7134
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   529
};