test/testautomation_pixels.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Fri, 10 May 2013 21:04:51 +0200
changeset 7162 f2fb5a030227
parent 7153 51cf5475ac56
child 7191 75360622e65f
permissions -rw-r--r--
Fixed precedence warning in test suite for pixels.
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;
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
    14
Uint32 _RGBPixelFormats[] = 
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
  };
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
    47
char* _RGBPixelFormatsVerbose[] = 
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 */
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
    82
const int _numNonRGBPixelFormats = 5;
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
    83
Uint32 _nonRGBPixelFormats[] = 
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,
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
    89
    SDL_PIXELFORMAT_YVYU 
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
    90
  };
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
    91
char* _nonRGBPixelFormatsVerbose[] = 
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
  {
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
    93
    "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
    94
    "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
    95
    "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
    96
    "SDL_PIXELFORMAT_UYVY",
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_YVYU" 
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
  };
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
    99
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   100
/* 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
   101
const int _numInvalidPixelFormats = 2;
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   102
Uint32 _invalidPixelFormats[] = 
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   103
  {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   104
    0xfffffffe,
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   105
    0xffffffff
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   106
  };
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   107
char* _invalidPixelFormatsVerbose[] = 
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   108
  {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   109
    "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
   110
    "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
   111
  };
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   112
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
   113
/* 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
   114
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
   115
/**
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
   116
 * @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
   117
 *
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
   118
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_AllocFormat
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
   119
 * @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
   120
 */
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
   121
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
   122
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
   123
{
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   124
  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
   125
  const char *expectedError = "Parameter 'format' 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
   126
  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
   127
  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
   128
  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
   129
  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
   130
  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
   131
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   132
  /* 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
   133
  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
   134
  SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   135
  
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   136
  /* 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
   137
  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
   138
  SDLTest_AssertPass("Call to SDL_AllocFormat()");
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   139
  SDLTest_AssertCheck(result != NULL, "Verify result is 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
   140
  if (result != NULL) {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   141
    SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->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_AssertCheck(result->BitsPerPixel == 0, "Verify value of result.BitsPerPixel; expected: 0, got %u", result->BitsPerPixel);  
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   143
    SDLTest_AssertCheck(result->BytesPerPixel == 0, "Verify value of result.BytesPerPixel; expected: 0, got %u", result->BytesPerPixel);  
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   144
    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
   145
    SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %u", masks);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   146
      
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   147
    /* 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
   148
    SDL_FreeFormat(result);
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_AssertPass("Call to SDL_FreeFormat()");          
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   150
  }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   151
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
   152
  /* 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
   153
  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
   154
    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
   155
    SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], 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
   156
  
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
    /* 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
   158
    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
   159
    SDLTest_AssertPass("Call to SDL_AllocFormat()");
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
   160
    SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");  
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
    if (result != NULL) {
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
      SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->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_AssertCheck(result->BitsPerPixel > 0, "Verify value of result.BitsPerPixel; expected: >0, got %u", result->BitsPerPixel);  
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
   164
      SDLTest_AssertCheck(result->BytesPerPixel > 0, "Verify value of result.BytesPerPixel; expected: >0, got %u", result->BytesPerPixel);  
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->palette != NULL) {      
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
   166
         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
   167
         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
   168
      }
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
   169
      
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
      /* 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
   171
      SDL_FreeFormat(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
   172
      SDLTest_AssertPass("Call to SDL_FreeFormat()");          
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
   173
    }
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
  }
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
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
   176
  /* 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
   177
  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
   178
    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
   179
    SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], 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
   180
  
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
    /* 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
   182
    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
   183
    SDLTest_AssertPass("Call to SDL_AllocFormat()");
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
   184
    SDLTest_AssertCheck(result == NULL, "Verify result is NULL");  
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
  }
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
  
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
   187
  /* Negative cases */
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
   188
  
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   189
  /* Invalid Formats */  
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   190
  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
   191
    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
   192
    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
   193
    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
   194
    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
   195
    SDLTest_AssertPass("Call to SDL_AllocFormat(%u)", format);
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_AssertCheck(result == NULL, "Verify result is NULL");  
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   197
    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
   198
    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
   199
    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
   200
    if (error != 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
   201
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 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
   202
          "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
   203
    }
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
   204
  }
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
   205
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
  /* 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
   207
  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
   208
  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
   209
  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
   210
  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
   211
  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
   212
  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
   213
  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
   214
  if (error != 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
   215
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 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
   216
          "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
   217
  }
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
   218
  
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
   219
  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
   220
}
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
   221
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
   222
/**
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   223
 * @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
   224
 *
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   225
 * @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
   226
 */
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   227
int
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   228
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
   229
{
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   230
  const char *unknownFormat = "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
   231
  const char *error;   
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   232
  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
   233
  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
   234
  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
   235
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   236
  /* 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
   237
  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
   238
  SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format);
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
  /* 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
   241
  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
   242
  SDLTest_AssertPass("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
   243
  SDLTest_AssertCheck(result != NULL, "Verify result is 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
   244
  if (result != NULL) {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   245
      SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty");
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_AssertCheck(SDL_strcmp(result, unknownFormat) == 0, 
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   247
        "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
   248
  }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   249
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   250
  /* 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
   251
  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
   252
    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
   253
    SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   254
  
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   255
    /* 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
   256
    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
   257
    SDLTest_AssertPass("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
   258
    SDLTest_AssertCheck(result != NULL, "Verify result is 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
   259
    if (result != NULL) {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   260
      SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty");
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_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[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
   262
        "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
   263
    }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   264
  }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   265
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   266
  /* 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
   267
  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
   268
    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
   269
    SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   270
  
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   271
    /* 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
   272
    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
   273
    SDLTest_AssertPass("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
   274
    SDLTest_AssertCheck(result != NULL, "Verify result is 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
   275
    if (result != NULL) {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   276
      SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty");
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_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[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
   278
        "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
   279
    }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   280
  }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   281
  
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   282
  /* Negative cases */
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
  /* Invalid Formats */  
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   285
  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
   286
  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
   287
  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
   288
    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
   289
    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
   290
    SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format);
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   291
    SDLTest_AssertCheck(result != NULL, "Verify result is 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
   292
    if (result != NULL) {
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   293
      SDLTest_AssertCheck(SDL_strlen(result) > 0, 
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   294
        "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
   295
      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
   296
        "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
   297
    }
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   298
    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
   299
    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
   300
    SDLTest_AssertCheck(error != NULL && SDL_strlen(error) == 0, "Validate that error message is empty");
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
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   303
  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
   304
}
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
/**
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
   307
 * @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
   308
 *
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
   309
 * @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
   310
 * @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
   311
 */
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
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
   313
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
   314
{
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
   315
  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
   316
  const char *expectedError2 = "Parameter 'palette' 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
   317
  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
   318
  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
   319
  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
   320
  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
   321
  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
   322
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
  /* Allocate palette */
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
  for (variation = 1; variation <= 3; 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
   325
    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
   326
      /* 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
   327
      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
   328
        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
   329
        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
   330
      /* 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
   331
      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
   332
        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
   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
      /* 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
   335
      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
   336
        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
   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
    }
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
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
    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
   341
    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
   342
    SDLTest_AssertCheck(result != NULL, "Verify result 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
   343
    if (result != 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
   344
      SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->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
      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
   346
        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
   347
        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
   348
          for(i = 0; i < result->ncolors; 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
   349
            SDLTest_AssertCheck(result->colors[i].r == 255, "Verify value of result.colors[%d].r; expected: 255, got %u", i, result->colors[i].r);  
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[i].g == 255, "Verify value of result.colors[%d].g; expected: 255, got %u", i, result->colors[i].g);  
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
            SDLTest_AssertCheck(result->colors[i].b == 255, "Verify value of result.colors[%d].b; expected: 255, got %u", i, result->colors[i].b);  
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
           }
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
   353
         } 
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
   354
      }
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
   355
      
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
      /* 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
   357
      SDL_FreePalette(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
   358
      SDLTest_AssertPass("Call to 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
   359
    }
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
  }
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
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
   362
  /* Negative cases */
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
   363
    
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
   364
  /* 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
   365
  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
   366
    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
   367
    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
   368
    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
   369
    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
   370
    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
   371
    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
   372
    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
   373
    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
   374
    if (error != 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
   375
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 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
   376
          "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
   377
    }
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
   378
  }
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
   379
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
  /* 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
   381
  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
   382
  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
   383
  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
   384
  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
   385
  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
   386
  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
   387
  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
   388
  if (error != 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
   389
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 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
   390
          "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
   391
  }
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
    
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
   393
  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
   394
}
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
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
   396
/**
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
 * @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
   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
 * @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
   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
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
   402
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
   403
{
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
  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
   405
  const char *expectedError2 = "Parameter 'ramp' 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
   406
  const char *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
   407
  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
   408
  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
   409
  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
   410
  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
   411
  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
   412
  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
   413
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
  /* Allocate temp ramp array and fill with some value*/
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
  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
   416
  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
   417
  if (ramp == NULL) return TEST_ABORTED;
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
   418
  
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
  /* 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
   420
  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
   421
    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
   422
      /* gamma = 0 all black */
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
      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
   424
        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
   425
        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
   426
      /* 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
   427
      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
   428
        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
   429
        break;
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   430
      /* 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
   431
      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
   432
        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
   433
        break;
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   434
      /* 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
   435
      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
   436
        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
   437
        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
   438
    }
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
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
   440
    /* Make call and check that values were updated */  
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
    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
   442
    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
   443
    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
   444
    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
   445
    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
   446
    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
   447
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
    /* 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
   449
    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
   450
    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
   451
      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
   452
        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
   453
        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
   454
      case 1:
7162
f2fb5a030227 Fixed precedence warning in test suite for pixels.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7153
diff changeset
   455
        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
   456
        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
   457
      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
   458
      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
   459
        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
   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
    }
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
  }
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
  
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
  /* 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
   465
  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
   466
  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
   467
  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
   468
  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
   469
  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
   470
  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
   471
  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
   472
  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
   473
  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
   474
  if (error != 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
   475
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 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
   476
          "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
   477
  }
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
  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
   479
  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
   480
  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
   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
  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
   483
  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
   484
  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
   485
  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
   486
  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
   487
  if (error != 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
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 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
   489
          "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
   490
  }
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
  
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
   492
  /* 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
   493
  SDL_free(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
   494
    
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
   495
    
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
   496
  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
   497
}
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
   498
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
   499
/* ================= 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
   500
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
   501
/* 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
   502
static const SDLTest_TestCaseReference pixelsTest1 =
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
		{ (SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_AllocFormat and SDL_FreeFormat", TEST_ENABLED };
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
static const SDLTest_TestCaseReference pixelsTest2 =
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
   506
		{ (SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_AllocPalette and SDL_FreePalette", TEST_ENABLED };
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
   507
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
   508
static const SDLTest_TestCaseReference pixelsTest3 =
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
   509
		{ (SDLTest_TestCaseFp)pixels_calcGammaRamp, "pixels_calcGammaRamp", "Call to SDL_CalculateGammaRamp", TEST_ENABLED };
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
   510
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   511
static const SDLTest_TestCaseReference pixelsTest4 =
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   512
		{ (SDLTest_TestCaseFp)pixels_getPixelFormatName, "pixels_getPixelFormatName", "Call to SDL_GetPixelFormatName", TEST_ENABLED };
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   513
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
   514
/* 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
   515
static const SDLTest_TestCaseReference *pixelsTests[] =  {
7153
51cf5475ac56 Add test for SDL_GetPixelFormatName to Pixels suite; minor improvements to Pixels suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7151
diff changeset
   516
	&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
   517
};
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
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
/* 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
   520
SDLTest_TestSuiteReference pixelsTestSuite = {
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
	"Pixels",
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
	NULL,
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
	pixelsTests,
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
	NULL
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
   525
};