test/testautomation_hints.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 19:59:00 -0400
changeset 10266 c09f06c4e8c8
parent 8645 d69fdbefeecf
permissions -rw-r--r--
emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8645
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     1
/**
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
 * Hints test suite
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
 */
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     5
#include <stdio.h>
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     6
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     7
#include "SDL.h"
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     8
#include "SDL_test.h"
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     9
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    10
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    11
const int _numHintsEnum = 25;
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    12
char* _HintsEnum[] =
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    13
  {
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    14
    SDL_HINT_ACCELEROMETER_AS_JOYSTICK,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    15
    SDL_HINT_FRAMEBUFFER_ACCELERATION,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    16
    SDL_HINT_GAMECONTROLLERCONFIG,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    17
    SDL_HINT_GRAB_KEYBOARD,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    18
    SDL_HINT_IDLE_TIMER_DISABLED,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    19
    SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    20
    SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    21
    SDL_HINT_MOUSE_RELATIVE_MODE_WARP,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    22
    SDL_HINT_ORIENTATIONS,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    23
    SDL_HINT_RENDER_DIRECT3D_THREADSAFE,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    24
    SDL_HINT_RENDER_DRIVER,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    25
    SDL_HINT_RENDER_OPENGL_SHADERS,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    26
    SDL_HINT_RENDER_SCALE_QUALITY,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    27
    SDL_HINT_RENDER_VSYNC,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    28
    SDL_HINT_TIMER_RESOLUTION,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    29
    SDL_HINT_VIDEO_ALLOW_SCREENSAVER,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    30
    SDL_HINT_VIDEO_HIGHDPI_DISABLED,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    31
    SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    32
    SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    33
    SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    34
    SDL_HINT_VIDEO_WIN_D3DCOMPILER,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    35
    SDL_HINT_VIDEO_X11_XINERAMA,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    36
    SDL_HINT_VIDEO_X11_XRANDR,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    37
    SDL_HINT_VIDEO_X11_XVIDMODE,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    38
    SDL_HINT_XINPUT_ENABLED,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    39
  };
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    40
char* _HintsVerbose[] =
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    41
  {
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    42
    "SDL_HINT_ACCELEROMETER_AS_JOYSTICK",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    43
    "SDL_HINT_FRAMEBUFFER_ACCELERATION",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    44
    "SDL_HINT_GAMECONTROLLERCONFIG",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    45
    "SDL_HINT_GRAB_KEYBOARD",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    46
    "SDL_HINT_IDLE_TIMER_DISABLED",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    47
    "SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    48
    "SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    49
    "SDL_HINT_MOUSE_RELATIVE_MODE_WARP",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    50
    "SDL_HINT_ORIENTATIONS",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    51
    "SDL_HINT_RENDER_DIRECT3D_THREADSAFE",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    52
    "SDL_HINT_RENDER_DRIVER",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    53
    "SDL_HINT_RENDER_OPENGL_SHADERS",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    54
    "SDL_HINT_RENDER_SCALE_QUALITY",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    55
    "SDL_HINT_RENDER_VSYNC",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    56
    "SDL_HINT_TIMER_RESOLUTION",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    57
    "SDL_HINT_VIDEO_ALLOW_SCREENSAVER",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    58
    "SDL_HINT_VIDEO_HIGHDPI_DISABLED",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    59
    "SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    60
    "SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    61
    "SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    62
    "SDL_HINT_VIDEO_WIN_D3DCOMPILER",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    63
    "SDL_HINT_VIDEO_X11_XINERAMA",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    64
    "SDL_HINT_VIDEO_X11_XRANDR",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    65
    "SDL_HINT_VIDEO_X11_XVIDMODE",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    66
    "SDL_HINT_XINPUT_ENABLED"
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    67
  };
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    68
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    69
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
/* Test case functions */
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    72
/**
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    73
 * @brief Call to SDL_GetHint
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    74
 */
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    75
int
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    76
hints_getHint(void *arg)
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    77
{
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    78
  char *result1;
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
  char *result2;
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    80
  int i;
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    81
    
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
  for (i=0; i<_numHintsEnum; i++) {
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    83
    result1 = (char *)SDL_GetHint((char*)_HintsEnum[i]);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    84
    SDLTest_AssertPass("Call to SDL_GetHint(%s) - using define definition", (char*)_HintsEnum[i]);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    85
    result2 = (char *)SDL_GetHint((char *)_HintsVerbose[i]);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    86
    SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    87
    SDLTest_AssertCheck(
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    88
      (result1 == NULL && result2 == NULL) || (SDL_strcmp(result1, result2) == 0),
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    89
      "Verify returned values are equal; got: result1='%s' result2='%s",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    90
      (result1 == NULL) ? "null" : result1,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    91
      (result2 == NULL) ? "null" : result2);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    92
  }
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    93
  
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    94
  return TEST_COMPLETED;
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    95
}
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    96
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    97
/**
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    98
 * @brief Call to SDL_SetHint
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    99
 */
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   100
int
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   101
hints_setHint(void *arg)
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   102
{
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   103
  char *originalValue;
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   104
  char *value;
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   105
  char *testValue;
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   106
  SDL_bool result;
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   107
  int i, j;
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   108
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   109
  /* Create random values to set */                    
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   110
  value = SDLTest_RandomAsciiStringOfSize(10);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   111
    
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   112
  for (i=0; i<_numHintsEnum; i++) {
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   113
    /* Capture current value */
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   114
    originalValue = (char *)SDL_GetHint((char*)_HintsEnum[i]);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   115
    SDLTest_AssertPass("Call to SDL_GetHint(%s)", (char*)_HintsEnum[i]);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   116
    
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   117
    /* Set value (twice) */
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   118
    for (j=1; j<=2; j++) {
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   119
      result = SDL_SetHint((char*)_HintsEnum[i], value);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   120
      SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", (char*)_HintsEnum[i], value, j);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   121
      SDLTest_AssertCheck(
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   122
        result == SDL_TRUE || result == SDL_FALSE, 
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   123
        "Verify valid result was returned, got: %i",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   124
        (int)result);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   125
      testValue = (char *)SDL_GetHint((char*)_HintsEnum[i]);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   126
      SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   127
      SDLTest_AssertCheck(
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   128
        (SDL_strcmp(value, testValue) == 0),
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   129
        "Verify returned value equals set value; got: testValue='%s' value='%s",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   130
        (testValue == NULL) ? "null" : testValue,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   131
        value);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   132
    }
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   133
      
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   134
    /* Reset original value */
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   135
    result = SDL_SetHint((char*)_HintsEnum[i], originalValue);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   136
    SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", (char*)_HintsEnum[i]);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   137
    SDLTest_AssertCheck(
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   138
      result == SDL_TRUE || result == SDL_FALSE, 
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   139
      "Verify valid result was returned, got: %i",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   140
      (int)result);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   141
  }
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   142
  
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   143
  SDL_free(value);
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   144
  
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   145
  return TEST_COMPLETED;
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   146
}
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   147
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   148
/* ================= Test References ================== */
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   149
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   150
/* Hints test cases */
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   151
static const SDLTest_TestCaseReference hintsTest1 =
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   152
        { (SDLTest_TestCaseFp)hints_getHint, "hints_getHint", "Call to SDL_GetHint", TEST_ENABLED };
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   153
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   154
static const SDLTest_TestCaseReference hintsTest2 =
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   155
        { (SDLTest_TestCaseFp)hints_setHint, "hints_setHint", "Call to SDL_SetHint", TEST_ENABLED };
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   156
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   157
/* Sequence of Hints test cases */
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   158
static const SDLTest_TestCaseReference *hintsTests[] =  {
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   159
    &hintsTest1, &hintsTest2, NULL
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   160
};
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   161
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   162
/* Hints test suite (global) */
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   163
SDLTest_TestSuiteReference hintsTestSuite = {
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   164
    "Hints",
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   165
    NULL,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   166
    hintsTests,
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   167
    NULL
d69fdbefeecf Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   168
};