test/testautomation_sdltest.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 17 Aug 2016 21:04:50 +0200
changeset 10275 ba7dc3ebb81e
parent 9260 039714172dc3
permissions -rw-r--r--
Emscripten: Fixed opening previously closed joystick.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     1
/**
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
 * SDL_test test suite
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
 */
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
     5
/* Visual Studio 2008 doesn't have stdint.h */
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
     6
#if defined(_MSC_VER) && _MSC_VER <= 1500
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
     7
#define UINT8_MAX   ~(Uint8)0
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
     8
#define UINT16_MAX  ~(Uint16)0
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
     9
#define UINT32_MAX  ~(Uint32)0
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    10
#define UINT64_MAX  ~(Uint64)0
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    11
#else
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    12
#include <stdint.h>
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    13
#endif
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    14
#include <stdio.h>
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    15
#include <limits.h>
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    16
#include <float.h>
6875
6c446c82c583 Add tests to SDLtest suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6872
diff changeset
    17
#include <ctype.h>
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    18
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    19
#include "SDL.h"
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    20
#include "SDL_test.h"
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    21
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    22
/* Test case functions */
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    23
8605
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    24
/* Forward declarations for internal harness functions */
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    25
extern char *SDLTest_GenerateRunSeed(const int length);
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    26
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    27
/**
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    28
 * @brief Calls to SDLTest_GenerateRunSeed()
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    29
 */
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    30
int
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    31
sdltest_generateRunSeed(void *arg)
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    32
{
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    33
  char* result;
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    34
  int i, l;
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    35
  
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    36
  for (i = 1; i <= 10; i += 3) {   
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    37
     result = SDLTest_GenerateRunSeed((const int)i);
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    38
     SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()");
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    39
     SDLTest_AssertCheck(result != NULL, "Verify returned value is not NULL");
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    40
     if (result != NULL) {
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    41
       l = SDL_strlen(result);
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    42
       SDLTest_AssertCheck(l == i, "Verify length of returned value is %d, got: %d", i, l);
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    43
       SDL_free(result);
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    44
     }
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    45
  }
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    46
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    47
  /* Negative cases */
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    48
  for (i = -2; i <= 0; i++) {   
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    49
     result = SDLTest_GenerateRunSeed((const int)i);
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    50
     SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()");
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    51
     SDLTest_AssertCheck(result == NULL, "Verify returned value is not NULL");
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    52
  }
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    53
  
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    54
  return TEST_COMPLETED;
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    55
}
57faccca4fab Fix bug/add test coverage for SDLTest_GenerateRunSeed helper; improve test harness adding output of repro steps for failures; improve negative test for SDL_GetError/SDL_SetError
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7721
diff changeset
    56
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    57
/**
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    58
 * @brief Calls to SDLTest_GetFuzzerInvocationCount()
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    59
 */
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    60
int
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    61
sdltest_getFuzzerInvocationCount(void *arg)
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    62
{
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    63
  Uint8 result;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    64
  int fuzzerCount1, fuzzerCount2;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
    65
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    66
  fuzzerCount1 = SDLTest_GetFuzzerInvocationCount();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    67
  SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()");
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    68
  SDLTest_AssertCheck(fuzzerCount1 >= 0, "Verify returned value, expected: >=0, got: %d", fuzzerCount1);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
    69
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
  result = SDLTest_RandomUint8();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
  SDLTest_AssertPass("Call to SDLTest_RandomUint8(), returned %d", result);
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    72
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    73
  fuzzerCount2 = SDLTest_GetFuzzerInvocationCount();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    74
  SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()");
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    75
  SDLTest_AssertCheck(fuzzerCount2 > fuzzerCount1, "Verify returned value, expected: >%d, got: %d", fuzzerCount1, fuzzerCount2);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
    76
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    77
  return TEST_COMPLETED;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    78
}
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    80
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    81
/**
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
 * @brief Calls to random number generators
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    83
 */
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    84
int
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    85
sdltest_randomNumber(void *arg)
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    86
{
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    87
  Sint64 result;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    88
  Uint64 uresult;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    89
  double dresult;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    90
  Uint64 umax;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    91
  Sint64 min, max;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
    92
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    93
  result = (Sint64)SDLTest_RandomUint8();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    94
  umax = (1 << 8) - 1;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    95
  SDLTest_AssertPass("Call to SDLTest_RandomUint8");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
    96
  SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result);
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    97
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    98
  result = (Sint64)SDLTest_RandomSint8();
7614
af0bd07212bd Fix Bug 2021: Win32: Stack overflow due to recursive SDL_LogOutput on SDL_LogError without console; fix off-by-one error in SDLtest test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7191
diff changeset
    99
  min = 0 - (1 << 7);
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   100
  max =     (1 << 7) - 1;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   101
  SDLTest_AssertPass("Call to SDLTest_RandomSint8");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   102
  SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   103
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   104
  result = (Sint64)SDLTest_RandomUint16();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   105
  umax = (1 << 16) - 1;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   106
  SDLTest_AssertPass("Call to SDLTest_RandomUint16");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   107
  SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result);
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   108
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   109
  result = (Sint64)SDLTest_RandomSint16();
7614
af0bd07212bd Fix Bug 2021: Win32: Stack overflow due to recursive SDL_LogOutput on SDL_LogError without console; fix off-by-one error in SDLtest test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7191
diff changeset
   110
  min = 0 - (1 << 15);
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   111
  max =     (1 << 15) - 1;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   112
  SDLTest_AssertPass("Call to SDLTest_RandomSint16");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   113
  SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result);
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   114
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   115
  result = (Sint64)SDLTest_RandomUint32();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   116
  umax = ((Uint64)1 << 32) - 1;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   117
  SDLTest_AssertPass("Call to SDLTest_RandomUint32");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   118
  SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%"SDL_PRIu64"], got: %"SDL_PRIs64, umax, result);
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   119
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   120
  result = (Sint64)SDLTest_RandomSint32();
7614
af0bd07212bd Fix Bug 2021: Win32: Stack overflow due to recursive SDL_LogOutput on SDL_LogError without console; fix off-by-one error in SDLtest test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7191
diff changeset
   121
  min = 0 - ((Sint64)1 << 31);
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   122
  max =     ((Sint64)1 << 31) - 1;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   123
  SDLTest_AssertPass("Call to SDLTest_RandomSint32");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   124
  SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result);
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   125
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   126
  uresult = SDLTest_RandomUint64();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   127
  SDLTest_AssertPass("Call to SDLTest_RandomUint64");
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   128
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   129
  result = SDLTest_RandomSint64();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   130
  SDLTest_AssertPass("Call to SDLTest_RandomSint64");
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   131
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   132
  dresult = (double)SDLTest_RandomUnitFloat();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   133
  SDLTest_AssertPass("Call to SDLTest_RandomUnitFloat");
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   134
  SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   135
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   136
  dresult = (double)SDLTest_RandomFloat();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   137
  SDLTest_AssertPass("Call to SDLTest_RandomFloat");
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   138
  SDLTest_AssertCheck(dresult >= (double)(-FLT_MAX) && dresult <= (double)FLT_MAX, "Verify result value, expected: [%e,%e], got: %e", (double)(-FLT_MAX), (double)FLT_MAX, dresult);
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   139
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   140
  dresult = (double)SDLTest_RandomUnitDouble();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   141
  SDLTest_AssertPass("Call to SDLTest_RandomUnitDouble");
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   142
  SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult);
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   143
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   144
  dresult = SDLTest_RandomDouble();
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   145
  SDLTest_AssertPass("Call to SDLTest_RandomDouble");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   146
6839
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   147
  return TEST_COMPLETED;
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   148
}
2494f667555c Add SDL_test test suite; add fuzzer test cases; fix fuzzer bug; fix compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   149
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   150
/*
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   151
 * @brief Calls to random boundary number generators for Uint8
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   152
 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   153
int
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   154
sdltest_randomBoundaryNumberUint8(void *arg)
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   155
{
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   156
  const char *expectedError = "That operation is not supported";
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   157
  char *lastError;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   158
  Uint64 uresult;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   159
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   160
  /* Clean error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   161
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   162
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   163
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   164
  /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   165
  uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   166
  SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   167
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   168
    uresult == 10,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   169
    "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   170
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   171
  /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   172
  uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 11, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   173
  SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   174
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   175
    uresult == 10 || uresult == 11,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   176
    "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   177
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   178
  /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   179
  uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 12, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   180
  SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   181
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   182
    uresult == 10 || uresult == 11 || uresult == 12,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   183
    "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   184
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   185
  /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   186
  uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 13, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   187
  SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   188
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   189
    uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   190
    "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   191
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   192
  /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   193
  uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 20, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   194
  SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   195
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   196
    uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   197
    "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   198
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   199
  /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   200
  uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(20, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   201
  SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   202
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   203
    uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   204
    "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   205
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   206
  /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   207
  uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 20, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   208
  SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   209
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   210
    uresult == 0 || uresult == 21,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   211
    "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   212
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   213
  /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   214
  uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 99, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   215
  SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   216
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   217
    uresult == 100,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   218
    "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   219
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   220
  /* RandomUintXBoundaryValue(1, 0xff, SDL_FALSE) returns 0 (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   221
  uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 255, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   222
  SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   223
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   224
    uresult == 0,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   225
    "Validate result value for parameters (1,255,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   226
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   227
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   228
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   229
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   230
  /* RandomUintXBoundaryValue(0, 0xfe, SDL_FALSE) returns 0xff (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   231
  uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 254, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   232
  SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   233
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   234
    uresult == 0xff,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   235
    "Validate result value for parameters (0,254,SDL_FALSE); expected: 0xff, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   236
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   237
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   238
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   239
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   240
  /* RandomUintXBoundaryValue(0, 0xff, SDL_FALSE) returns 0 (sets error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   241
  uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 255, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   242
  SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   243
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   244
    uresult == 0,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   245
    "Validate result value for parameters(0,255,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   246
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   247
  SDLTest_AssertPass("SDL_GetError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   248
  SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   249
             "SDL_GetError(): expected message '%s', was message: '%s'",
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   250
             expectedError,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   251
             lastError);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   252
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   253
  /* Clear error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   254
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   255
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   256
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   257
  return TEST_COMPLETED;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   258
}
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   259
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   260
/*
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   261
 * @brief Calls to random boundary number generators for Uint16
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   262
 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   263
int
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   264
sdltest_randomBoundaryNumberUint16(void *arg)
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   265
{
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   266
  const char *expectedError = "That operation is not supported";
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   267
  char *lastError;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   268
  Uint64 uresult;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   269
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   270
  /* Clean error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   271
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   272
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   273
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   274
  /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   275
  uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   276
  SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   277
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   278
    uresult == 10,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   279
    "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   280
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   281
  /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   282
  uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 11, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   283
  SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   284
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   285
    uresult == 10 || uresult == 11,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   286
    "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   287
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   288
  /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   289
  uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 12, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   290
  SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   291
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   292
    uresult == 10 || uresult == 11 || uresult == 12,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   293
    "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   294
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   295
  /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   296
  uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 13, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   297
  SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   298
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   299
    uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   300
    "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   301
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   302
  /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   303
  uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 20, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   304
  SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   305
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   306
    uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   307
    "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   308
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   309
  /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   310
  uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(20, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   311
  SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   312
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   313
    uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   314
    "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   315
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   316
  /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   317
  uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 20, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   318
  SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   319
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   320
    uresult == 0 || uresult == 21,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   321
    "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   322
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   323
  /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   324
  uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 99, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   325
  SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   326
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   327
    uresult == 100,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   328
    "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   329
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   330
  /* RandomUintXBoundaryValue(1, 0xffff, SDL_FALSE) returns 0 (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   331
  uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 0xffff, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   332
  SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   333
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   334
    uresult == 0,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   335
    "Validate result value for parameters (1,0xffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   336
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   337
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   338
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   339
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   340
  /* RandomUintXBoundaryValue(0, 0xfffe, SDL_FALSE) returns 0xffff (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   341
  uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xfffe, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   342
  SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   343
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   344
    uresult == 0xffff,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   345
    "Validate result value for parameters (0,0xfffe,SDL_FALSE); expected: 0xffff, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   346
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   347
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   348
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   349
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   350
  /* RandomUintXBoundaryValue(0, 0xffff, SDL_FALSE) returns 0 (sets error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   351
  uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 0xffff, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   352
  SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   353
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   354
    uresult == 0,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   355
    "Validate result value for parameters(0,0xffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   356
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   357
  SDLTest_AssertPass("SDL_GetError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   358
  SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   359
             "SDL_GetError(): expected message '%s', was message: '%s'",
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   360
             expectedError,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   361
             lastError);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   362
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   363
  /* Clear error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   364
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   365
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   366
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   367
  return TEST_COMPLETED;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   368
}
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   369
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   370
/*
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   371
 * @brief Calls to random boundary number generators for Uint32
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   372
 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   373
int
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   374
sdltest_randomBoundaryNumberUint32(void *arg)
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   375
{
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   376
  const char *expectedError = "That operation is not supported";
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   377
  char *lastError;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   378
  Uint64 uresult;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   379
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   380
  /* Clean error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   381
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   382
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   383
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   384
  /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   385
  uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   386
  SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   387
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   388
    uresult == 10,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   389
    "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   390
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   391
  /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   392
  uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 11, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   393
  SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   394
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   395
    uresult == 10 || uresult == 11,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   396
    "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   397
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   398
  /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   399
  uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 12, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   400
  SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   401
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   402
    uresult == 10 || uresult == 11 || uresult == 12,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   403
    "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   404
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   405
  /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   406
  uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 13, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   407
  SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   408
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   409
    uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   410
    "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   411
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   412
  /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   413
  uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 20, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   414
  SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   415
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   416
    uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   417
    "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   418
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   419
  /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   420
  uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(20, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   421
  SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   422
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   423
    uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   424
    "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   425
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   426
  /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   427
  uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 20, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   428
  SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   429
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   430
    uresult == 0 || uresult == 21,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   431
    "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   432
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   433
  /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   434
  uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 99, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   435
  SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   436
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   437
    uresult == 100,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   438
    "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   439
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   440
  /* RandomUintXBoundaryValue(1, 0xffffffff, SDL_FALSE) returns 0 (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   441
  uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 0xffffffff, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   442
  SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   443
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   444
    uresult == 0,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   445
    "Validate result value for parameters (1,0xffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   446
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   447
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   448
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   449
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   450
  /* RandomUintXBoundaryValue(0, 0xfffffffe, SDL_FALSE) returns 0xffffffff (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   451
  uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xfffffffe, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   452
  SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   453
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   454
    uresult == 0xffffffff,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   455
    "Validate result value for parameters (0,0xfffffffe,SDL_FALSE); expected: 0xffffffff, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   456
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   457
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   458
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   459
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   460
  /* RandomUintXBoundaryValue(0, 0xffffffff, SDL_FALSE) returns 0 (sets error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   461
  uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 0xffffffff, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   462
  SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   463
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   464
    uresult == 0,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   465
    "Validate result value for parameters(0,0xffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   466
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   467
  SDLTest_AssertPass("SDL_GetError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   468
  SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   469
             "SDL_GetError(): expected message '%s', was message: '%s'",
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   470
             expectedError,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   471
             lastError);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   472
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   473
  /* Clear error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   474
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   475
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   476
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   477
  return TEST_COMPLETED;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   478
}
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   479
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   480
/*
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   481
 * @brief Calls to random boundary number generators for Uint64
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   482
 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   483
int
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   484
sdltest_randomBoundaryNumberUint64(void *arg)
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   485
{
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   486
  const char *expectedError = "That operation is not supported";
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   487
  char *lastError;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   488
  Uint64 uresult;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   489
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   490
  /* Clean error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   491
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   492
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   493
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   494
  /* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   495
  uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   496
  SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   497
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   498
    uresult == 10,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   499
    "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   500
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   501
  /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   502
  uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   503
  SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   504
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   505
    uresult == 10 || uresult == 11,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   506
    "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   507
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   508
  /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   509
  uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   510
  SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   511
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   512
    uresult == 10 || uresult == 11 || uresult == 12,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   513
    "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   514
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   515
  /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   516
  uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   517
  SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   518
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   519
    uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   520
    "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   521
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   522
  /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   523
  uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   524
  SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   525
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   526
    uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   527
    "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   528
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   529
  /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   530
  uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   531
  SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   532
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   533
    uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   534
    "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   535
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   536
  /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   537
  uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   538
  SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   539
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   540
    uresult == 0 || uresult == 21,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   541
    "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, uresult);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   542
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   543
  /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   544
  uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   545
  SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   546
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   547
    uresult == 100,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   548
    "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   549
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   550
  /* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   551
  uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   552
  SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   553
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   554
    uresult == 0,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   555
    "Validate result value for parameters (1,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   556
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   557
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   558
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   559
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   560
  /* RandomUintXBoundaryValue(0, 0xfffffffffffffffe, SDL_FALSE) returns 0xffffffffffffffff (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   561
  uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xfffffffffffffffeULL, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   562
  SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   563
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   564
    uresult == (Uint64)0xffffffffffffffffULL,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   565
    "Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   566
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   567
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   568
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   569
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   570
  /* RandomUintXBoundaryValue(0, 0xffffffffffffffff, SDL_FALSE) returns 0 (sets error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   571
  uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   572
  SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   573
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   574
    uresult == 0,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   575
    "Validate result value for parameters(0,0xffffffffffffffff,SDL_FALSE); expected: 0, got: %"SDL_PRIs64, uresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   576
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   577
  SDLTest_AssertPass("SDL_GetError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   578
  SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   579
             "SDL_GetError(): expected message '%s', was message: '%s'",
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   580
             expectedError,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   581
             lastError);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   582
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   583
  /* Clear error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   584
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   585
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   586
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   587
  return TEST_COMPLETED;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   588
}
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   589
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   590
/*
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   591
 * @brief Calls to random boundary number generators for Sint8
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   592
 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   593
int
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   594
sdltest_randomBoundaryNumberSint8(void *arg)
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   595
{
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   596
  const char *expectedError = "That operation is not supported";
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   597
  char *lastError;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   598
  Sint64 sresult;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   599
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   600
  /* Clean error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   601
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   602
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   603
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   604
  /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   605
  sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   606
  SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   607
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   608
    sresult == 10,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   609
    "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   610
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   611
  /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   612
  sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 11, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   613
  SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   614
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   615
    sresult == 10 || sresult == 11,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   616
    "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   617
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   618
  /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   619
  sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 12, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   620
  SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   621
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   622
    sresult == 10 || sresult == 11 || sresult == 12,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   623
    "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   624
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   625
  /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   626
  sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 13, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   627
  SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   628
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   629
    sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   630
    "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   631
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   632
  /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   633
  sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 20, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   634
  SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   635
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   636
    sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   637
    "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   638
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   639
  /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   640
  sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(20, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   641
  SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   642
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   643
    sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   644
    "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   645
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   646
  /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   647
  sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(1, 20, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   648
  SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   649
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   650
    sresult == 0 || sresult == 21,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   651
    "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   652
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   653
  /* RandomSintXBoundaryValue(SCHAR_MIN, 99, SDL_FALSE) returns 100 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   654
  sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, 99, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   655
  SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   656
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   657
    sresult == 100,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   658
    "Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   659
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   660
  /* RandomSintXBoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   661
  sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   662
  SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   663
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   664
    sresult == SCHAR_MIN,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   665
    "Validate result value for parameters (SCHAR_MIN + 1,SCHAR_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MIN, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   666
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   667
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   668
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   669
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   670
  /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX - 1, SDL_FALSE) returns SCHAR_MAX (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   671
  sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX -1, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   672
  SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   673
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   674
    sresult == SCHAR_MAX,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   675
    "Validate result value for parameters (SCHAR_MIN,SCHAR_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MAX, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   676
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   677
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   678
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   679
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   680
  /* RandomSintXBoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (sets error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   681
  sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, SCHAR_MAX, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   682
  SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   683
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   684
    sresult == SCHAR_MIN,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   685
    "Validate result value for parameters(SCHAR_MIN,SCHAR_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SCHAR_MIN, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   686
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   687
  SDLTest_AssertPass("SDL_GetError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   688
  SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   689
             "SDL_GetError(): expected message '%s', was message: '%s'",
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   690
             expectedError,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   691
             lastError);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   692
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   693
  /* Clear error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   694
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   695
  SDLTest_AssertPass("SDL_ClearError()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   696
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   697
  return TEST_COMPLETED;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   698
}
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   699
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   700
/*
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   701
 * @brief Calls to random boundary number generators for Sint16
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   702
 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   703
int
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   704
sdltest_randomBoundaryNumberSint16(void *arg)
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   705
{
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   706
  const char *expectedError = "That operation is not supported";
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   707
  char *lastError;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   708
  Sint64 sresult;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   709
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   710
  /* Clean error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   711
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   712
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   713
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   714
  /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   715
  sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   716
  SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   717
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   718
    sresult == 10,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   719
    "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   720
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   721
  /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   722
  sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 11, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   723
  SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   724
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   725
    sresult == 10 || sresult == 11,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   726
    "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   727
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   728
  /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   729
  sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 12, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   730
  SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   731
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   732
    sresult == 10 || sresult == 11 || sresult == 12,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   733
    "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   734
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   735
  /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   736
  sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 13, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   737
  SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   738
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   739
    sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   740
    "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   741
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   742
  /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   743
  sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 20, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   744
  SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   745
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   746
    sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   747
    "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   748
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   749
  /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   750
  sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(20, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   751
  SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   752
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   753
    sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   754
    "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   755
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   756
  /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   757
  sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(1, 20, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   758
  SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   759
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   760
    sresult == 0 || sresult == 21,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   761
    "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   762
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   763
  /* RandomSintXBoundaryValue(SHRT_MIN, 99, SDL_FALSE) returns 100 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   764
  sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, 99, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   765
  SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   766
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   767
    sresult == 100,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   768
    "Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   769
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   770
  /* RandomSintXBoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE) returns SHRT_MIN (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   771
  sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   772
  SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   773
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   774
    sresult == SHRT_MIN,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   775
    "Validate result value for parameters (SHRT_MIN+1,SHRT_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MIN, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   776
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   777
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   778
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   779
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   780
  /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE) returns SHRT_MAX (no error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   781
  sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX - 1, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   782
  SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   783
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   784
    sresult == SHRT_MAX,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   785
    "Validate result value for parameters (SHRT_MIN,SHRT_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MAX, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   786
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   787
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   788
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   789
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   790
  /* RandomSintXBoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE) returns 0 (sets error) */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   791
  sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   792
  SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   793
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   794
    sresult == SHRT_MIN,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   795
    "Validate result value for parameters(SHRT_MIN,SHRT_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, SHRT_MIN, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   796
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   797
  SDLTest_AssertPass("SDL_GetError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   798
  SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   799
             "SDL_GetError(): expected message '%s', was message: '%s'",
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   800
             expectedError,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   801
             lastError);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   802
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   803
  /* Clear error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   804
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   805
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   806
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   807
  return TEST_COMPLETED;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   808
}
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   809
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   810
/*
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   811
 * @brief Calls to random boundary number generators for Sint32
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   812
 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   813
int
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   814
sdltest_randomBoundaryNumberSint32(void *arg)
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   815
{
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   816
  const char *expectedError = "That operation is not supported";
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   817
  char *lastError;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   818
  Sint64 sresult;
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   819
#if ((ULONG_MAX) == (UINT_MAX))
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   820
  Sint32 long_min = LONG_MIN;
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   821
  Sint32 long_max = LONG_MAX;
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   822
#else
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   823
  Sint32 long_min = INT_MIN;
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   824
  Sint32 long_max = INT_MAX;
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   825
#endif
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   826
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   827
  /* Clean error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   828
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   829
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   830
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   831
  /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   832
  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   833
  SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   834
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   835
    sresult == 10,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   836
    "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   837
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   838
  /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   839
  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 11, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   840
  SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   841
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   842
    sresult == 10 || sresult == 11,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   843
    "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   844
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   845
  /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   846
  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 12, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   847
  SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   848
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   849
    sresult == 10 || sresult == 11 || sresult == 12,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   850
    "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   851
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   852
  /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   853
  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 13, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   854
  SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   855
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   856
    sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   857
    "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   858
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   859
  /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   860
  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 20, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   861
  SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   862
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   863
    sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   864
    "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   865
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   866
  /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   867
  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(20, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   868
  SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   869
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   870
    sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   871
    "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   873
  /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   874
  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(1, 20, SDL_FALSE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   875
  SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   876
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   877
    sresult == 0 || sresult == 21,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   878
    "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %"SDL_PRIs64, sresult);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   879
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   880
  /* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   881
  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, 99, SDL_FALSE);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   882
  SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   883
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   884
    sresult == 100,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   885
    "Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   886
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   887
  /* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   888
  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min + 1, long_max, SDL_FALSE);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   889
  SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   890
  SDLTest_AssertCheck(
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   891
    sresult == long_min,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   892
    "Validate result value for parameters (LONG_MIN+1,LONG_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_min, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   893
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   894
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   895
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   896
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   897
  /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX - 1, SDL_FALSE) returns LONG_MAX (no error) */
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   898
  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max - 1, SDL_FALSE);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   899
  SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   900
  SDLTest_AssertCheck(
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   901
    sresult == long_max,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   902
    "Validate result value for parameters (LONG_MIN,LONG_MAX - 1,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_max, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   903
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   904
  SDLTest_AssertPass("SDL_GetError()");
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7614
diff changeset
   905
  SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   906
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   907
  /* RandomSintXBoundaryValue(LONG_MIN, LONG_MAX, SDL_FALSE) returns 0 (sets error) */
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   908
  sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, long_max, SDL_FALSE);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   909
  SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   910
  SDLTest_AssertCheck(
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   911
    sresult == long_min,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   912
    "Validate result value for parameters(LONG_MIN,LONG_MAX,SDL_FALSE); expected: %d, got: %"SDL_PRIs64, long_min, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   913
  lastError = (char *)SDL_GetError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   914
  SDLTest_AssertPass("SDL_GetError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   915
  SDLTest_AssertCheck(lastError != NULL && SDL_strcmp(lastError, expectedError) == 0,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   916
             "SDL_GetError(): expected message '%s', was message: '%s'",
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   917
             expectedError,
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   918
             lastError);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   919
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   920
  /* Clear error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   921
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   922
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   923
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   924
  return TEST_COMPLETED;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   925
}
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   926
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   927
/*
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   928
 * @brief Calls to random boundary number generators for Sint64
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   929
 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   930
int
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   931
sdltest_randomBoundaryNumberSint64(void *arg)
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   932
{
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   933
  const char *expectedError = "That operation is not supported";
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   934
  char *lastError;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   935
  Sint64 sresult;
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   936
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   937
  /* Clean error messages */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   938
  SDL_ClearError();
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   939
  SDLTest_AssertPass("SDL_ClearError()");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   940
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   941
  /* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   942
  sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 10, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   943
  SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   944
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   945
    sresult == 10,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   946
    "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   947
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   948
  /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   949
  sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   950
  SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   951
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   952
    sresult == 10 || sresult == 11,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   953
    "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %"SDL_PRIs64, sresult);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   954
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   955
  /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   956
  sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE);
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   957
  SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   958
  SDLTest_AssertCheck(
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6839
diff changeset
   959
    sresult == 10 || sresult == 11 || sresult == 12,
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforde