test/testautomation_pixels.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Sat, 04 May 2013 09:11:18 -0700
changeset 7142 f4a670e51cde
parent 7134 09ee216e6a25
child 7151 99a4964db4c3
permissions -rw-r--r--
Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
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
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   100
/* 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
   101
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   102
/**
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   103
 * @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
   104
 *
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
   105
 * @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
   106
 * @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
   107
 */
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   108
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
   109
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
   110
{
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   111
  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
   112
  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
   113
  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
   114
  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
   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
  /* 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
   117
  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
   118
    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
   119
    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
   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
    /* 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
   122
    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
   123
    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
   124
    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
   125
    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
   126
      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
   127
      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
   128
      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
   129
      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
   130
         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
   131
         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
   132
      }
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   133
      
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   134
      /* 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
   135
      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
   136
      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
   137
    }
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   138
  }
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   139
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   140
  /* 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
   141
  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
   142
    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
   143
    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
   144
  
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   145
    /* 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
   146
    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
   147
    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
   148
    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
   149
  }
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   150
  
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
   151
  /* Negative cases */
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
   152
  format = 0xffffffff;
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
   153
  result = SDL_AllocFormat(format);
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
   154
  SDLTest_AssertPass("Call to SDL_AllocFormat(0xffffffff)");
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
   155
  SDLTest_AssertCheck(result == NULL, "Verify result is 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
   156
  /* TODO: check error code */
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
   157
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
   158
  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
   159
  SDLTest_AssertPass("Call to 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
   160
  /* TODO: check error code */
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
   161
  
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
   162
  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
   163
}
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
   164
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
   165
/**
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
   166
 * @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
   167
 *
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
   168
 * @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
   169
 * @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
   170
 */
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
   171
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
   172
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
   173
{
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
   174
  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
   175
  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
   176
  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
   177
  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
   178
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
   179
  /* 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
   180
  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
   181
    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
   182
      /* 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
   183
      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
   184
        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
   185
        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
   186
      /* 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
   187
      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
   188
        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
   189
        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
   190
      /* 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
   191
      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
   192
        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
   193
        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
   194
    }
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
   195
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
   196
    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
   197
    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
   198
    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
   199
    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
   200
      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
   201
      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
   202
        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
   203
        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
   204
          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
   205
            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
   206
            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
   207
            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
   208
           }
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
         } 
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
      }
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
   211
      
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
   212
      /* 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
   213
      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
   214
      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
   215
    }
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
   216
  }
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
   217
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
  /* Negative cases */
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
  for (ncolors = 0; ncolors > -3; 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
   220
    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
   221
    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
   222
    SDLTest_AssertCheck(result == NULL, "Verify result is 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
   223
    /* TODO: check error code */
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   224
  }
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   225
f4a670e51cde Added additional input validation to SDL_AllocPalette; added error codes; added test case to Pixels suite for coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7134
diff changeset
   226
  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
   227
  SDLTest_AssertPass("Call to 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
   228
  /* TODO: check error code */
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
   229
    
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
   230
  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
   231
}
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   232
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   233
/* ================= 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
   234
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
   235
/* 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
   236
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
   237
		{ (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
   238
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
   239
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
   240
		{ (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
   241
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
   242
/* 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
   243
static const SDLTest_TestCaseReference *pixelsTests[] =  {
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
   244
	&pixelsTest1, &pixelsTest2, 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
   245
};
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   246
09ee216e6a25 Add pixels test suite; add a test to pixel suite; minor updates to test code to make VisualStudio happy
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   247
/* 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
   248
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
   249
	"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
   250
	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
   251
	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
   252
	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
   253
};