test/testautomation_clipboard.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 19:59:00 -0400
changeset 10266 c09f06c4e8c8
parent 9617 062bfde7330a
permissions -rw-r--r--
emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     1
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
 * New/updated tests: aschiffler at ferzkopp dot net
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     5
#include <stdio.h>
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     6
#include <string.h>
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     7
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     8
#include "SDL.h"
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     9
#include "SDL_test.h"
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    10
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    11
/* ================= Test Case Implementation ================== */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    12
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    13
/* Test case functions */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    14
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    15
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    16
 * \brief Check call to SDL_HasClipboardText
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    17
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    18
 * \sa
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    19
 * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    20
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    21
int
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    22
clipboard_testHasClipboardText(void *arg)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    23
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    24
    SDL_bool result;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    25
    result = SDL_HasClipboardText();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    26
    SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    27
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    28
    return TEST_COMPLETED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    29
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    30
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    31
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    32
 * \brief Check call to SDL_GetClipboardText
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    33
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    34
 * \sa
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    35
 * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    36
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    37
int
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    38
clipboard_testGetClipboardText(void *arg)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    39
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    40
    char *charResult;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    41
    charResult = SDL_GetClipboardText();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    42
    SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    43
7719
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7477
diff changeset
    44
    SDL_free(charResult);
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    45
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    46
    return TEST_COMPLETED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    47
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    48
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    49
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    50
 * \brief Check call to SDL_SetClipboardText
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    51
 * \sa
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    52
 * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    53
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    54
int
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    55
clipboard_testSetClipboardText(void *arg)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    56
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    57
    char *textRef = SDLTest_RandomAsciiString();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    58
    char *text = SDL_strdup(textRef);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    59
    int result;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    60
    result = SDL_SetClipboardText((const char *)text);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    61
    SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    62
    SDLTest_AssertCheck(
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    63
        result == 0,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    64
        "Validate SDL_SetClipboardText result, expected 0, got %i",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    65
        result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    66
    SDLTest_AssertCheck(
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    67
        SDL_strcmp(textRef, text) == 0,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    68
        "Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    69
        textRef, text);
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
    /* Cleanup */
7719
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7477
diff changeset
    72
    SDL_free(textRef);
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7477
diff changeset
    73
    SDL_free(text);
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    74
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    75
   return TEST_COMPLETED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    76
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    77
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    78
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
 * \brief End-to-end test of SDL_xyzClipboardText functions
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    80
 * \sa
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    81
 * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
 * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    83
 * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    84
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    85
int
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    86
clipboard_testClipboardTextFunctions(void *arg)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    87
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    88
    char *textRef = SDLTest_RandomAsciiString();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    89
    char *text = SDL_strdup(textRef);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    90
    SDL_bool boolResult;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    91
    int intResult;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    92
    char *charResult;
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    93
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    94
    /* Clear clipboard text state */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    95
    boolResult = SDL_HasClipboardText();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    96
    SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
    97
    if (boolResult == SDL_TRUE) {
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    98
        intResult = SDL_SetClipboardText((const char *)NULL);
7144
c700de9c8ed4 Corrected spelling in C source files of test suites.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 6822
diff changeset
    99
        SDLTest_AssertPass("Call to SDL_SetClipboardText(NULL) succeeded");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   100
        SDLTest_AssertCheck(
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   101
            intResult == 0,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   102
            "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   103
            intResult);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   104
        charResult = SDL_GetClipboardText();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   105
        SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
9617
062bfde7330a Fixed bug 2989 - Memory loss in clipboard_testClipboardTextFunctions
Sam Lantinga <slouken@libsdl.org>
parents: 7721
diff changeset
   106
        SDL_free(charResult);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   107
        boolResult = SDL_HasClipboardText();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   108
        SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   109
        SDLTest_AssertCheck(
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   110
            boolResult == SDL_FALSE,
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   111
            "Verify SDL_HasClipboardText returned SDL_FALSE, got %s",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   112
            (boolResult) ? "SDL_TRUE" : "SDL_FALSE");
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   113
    }
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   114
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   115
    /* Empty clipboard  */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   116
    charResult = SDL_GetClipboardText();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   117
    SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   118
    SDLTest_AssertCheck(
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   119
        charResult != NULL,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   120
        "Verify SDL_GetClipboardText did not return NULL");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   121
    SDLTest_AssertCheck(
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   122
        charResult[0] == '\0',
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   123
        "Verify SDL_GetClipboardText returned string with length 0, got length %i",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   124
        SDL_strlen(charResult));
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   125
    intResult = SDL_SetClipboardText((const char *)text);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   126
    SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   127
    SDLTest_AssertCheck(
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   128
        intResult == 0,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   129
        "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   130
        intResult);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   131
    SDLTest_AssertCheck(
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   132
        SDL_strcmp(textRef, text) == 0,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   133
        "Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   134
        textRef, text);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   135
    boolResult = SDL_HasClipboardText();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   136
    SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   137
    SDLTest_AssertCheck(
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   138
        boolResult == SDL_TRUE,
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   139
        "Verify SDL_HasClipboardText returned SDL_TRUE, got %s",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   140
        (boolResult) ? "SDL_TRUE" : "SDL_FALSE");
9617
062bfde7330a Fixed bug 2989 - Memory loss in clipboard_testClipboardTextFunctions
Sam Lantinga <slouken@libsdl.org>
parents: 7721
diff changeset
   141
    SDL_free(charResult);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   142
    charResult = SDL_GetClipboardText();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   143
    SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   144
    SDLTest_AssertCheck(
7477
a73210626b97 Replaced use of strcmp() with SDL_strcmp() in tests.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7191
diff changeset
   145
        SDL_strcmp(textRef, charResult) == 0,
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   146
        "Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   147
        textRef, charResult);
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   148
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   149
    /* Cleanup */
7719
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7477
diff changeset
   150
    SDL_free(textRef);
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7477
diff changeset
   151
    SDL_free(text);
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7477
diff changeset
   152
    SDL_free(charResult);
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   153
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   154
   return TEST_COMPLETED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   155
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   156
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   157
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   158
/* ================= Test References ================== */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   159
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   160
/* Clipboard test cases */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   161
static const SDLTest_TestCaseReference clipboardTest1 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   162
        { (SDLTest_TestCaseFp)clipboard_testHasClipboardText, "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED };
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   163
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   164
static const SDLTest_TestCaseReference clipboardTest2 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   165
        { (SDLTest_TestCaseFp)clipboard_testGetClipboardText, "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED };
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   166
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   167
static const SDLTest_TestCaseReference clipboardTest3 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   168
        { (SDLTest_TestCaseFp)clipboard_testSetClipboardText, "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED };
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   169
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   170
static const SDLTest_TestCaseReference clipboardTest4 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   171
        { (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED };
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   172
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   173
/* Sequence of Clipboard test cases */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   174
static const SDLTest_TestCaseReference *clipboardTests[] =  {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   175
    &clipboardTest1, &clipboardTest2, &clipboardTest3, &clipboardTest4, NULL
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   176
};
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   177
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   178
/* Clipboard test suite (global) */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   179
SDLTest_TestSuiteReference clipboardTestSuite = {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   180
    "Clipboard",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   181
    NULL,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   182
    clipboardTests,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7144
diff changeset
   183
    NULL
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   184
};