testautomation_clipboard.c File Reference
`#include <stdio.h>`
`#include <string.h>`
`#include "SDL.h"`
`#include "SDL_test.h"`
Include dependency graph for testautomation_clipboard.c:

Go to the source code of this file.

## Functions

int | clipboard_testHasClipboardText (void *arg)
| Check call to SDL_HasClipboardText. More...
int | clipboard_testGetClipboardText (void *arg)
| Check call to SDL_GetClipboardText. More...
int | clipboard_testSetClipboardText (void *arg)
| Check call to SDL_SetClipboardText. More...
int | clipboard_testClipboardTextFunctions (void *arg)
| End-to-end test of SDL_xyzClipboardText functions. More...

## Variables

static const SDLTest_TestCaseReference | clipboardTest1
static const SDLTest_TestCaseReference | clipboardTest2
static const SDLTest_TestCaseReference | clipboardTest3
static const SDLTest_TestCaseReference | clipboardTest4
static const SDLTest_TestCaseReference * | clipboardTests []
SDLTest_TestSuiteReference | clipboardTestSuite

## Function Documentation

## clipboard_testClipboardTextFunctions()

int clipboard_testClipboardTextFunctions | ( | void * | arg | ) |

End-to-end test of SDL_xyzClipboardText functions.

See also
  http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText

Definition at line 86 of file testautomation_clipboard.c.

References NULL, SDL_FALSE, SDL_free, SDL_GetClipboardText, SDL_HasClipboardText, SDL_SetClipboardText, SDL_strcmp, SDL_strdup, SDL_strlen, SDL_TRUE, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomAsciiString(), TEST_COMPLETED, and text.

{
char *textRef = SDLTest_RandomAsciiString();
char *text = SDL_strdup(textRef);
SDL_bool boolResult;
int intResult;
char *charResult;
/* Clear clipboard text state */
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
if (boolResult == SDL_TRUE) {
intResult = SDL_SetClipboardText((const char *)NULL);
SDLTest_AssertPass("Call to SDL_SetClipboardText(NULL) succeeded");
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
intResult);
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
SDL_free(charResult);
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
SDLTest_AssertCheck(
boolResult == SDL_FALSE,
"Verify SDL_HasClipboardText returned SDL_FALSE, got %s",
(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
}
/* Empty clipboard */
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
SDLTest_AssertCheck(
charResult != NULL,
"Verify SDL_GetClipboardText did not return NULL");
SDLTest_AssertCheck(
charResult[0] == '\0',
"Verify SDL_GetClipboardText returned string with length 0, got length %i",
(int) SDL_strlen(charResult));
intResult = SDL_SetClipboardText((const char *)text);
SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
intResult);
SDLTest_AssertCheck(
SDL_strcmp(textRef, text) == 0,
"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
textRef, text);
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
SDLTest_AssertCheck(
boolResult == SDL_TRUE,
"Verify SDL_HasClipboardText returned SDL_TRUE, got %s",
(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
SDL_free(charResult);
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
SDLTest_AssertCheck(
SDL_strcmp(textRef, charResult) == 0,
"Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'",
textRef, charResult);
/* Cleanup */
SDL_free(textRef);
SDL_free(text);
SDL_free(charResult);
return TEST_COMPLETED;
}
SDL_TRUE
Definition: SDL_stdinc.h:142
SDLTest_AssertPass
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
Definition: SDL_test_assert.c:94
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_GetClipboardText
#define SDL_GetClipboardText
Definition: SDL_dynapi_overrides.h:99
SDLTest_RandomAsciiString
char * SDLTest_RandomAsciiString(void)
Definition: SDL_test_fuzzer.c:486
SDLTest_AssertCheck
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
Definition: SDL_test_assert.c:65
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
TEST_COMPLETED
#define TEST_COMPLETED
Definition: SDL_test_harness.h:53
NULL
#define NULL
Definition: begin_code.h:164
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:139
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
SDL_strlen
#define SDL_strlen
Definition: SDL_dynapi_overrides.h:393
SDL_strdup
#define SDL_strdup
Definition: SDL_dynapi_overrides.h:397
SDL_HasClipboardText
#define SDL_HasClipboardText
Definition: SDL_dynapi_overrides.h:100
SDL_strcmp
#define SDL_strcmp
Definition: SDL_dynapi_overrides.h:417
SDL_SetClipboardText
#define SDL_SetClipboardText
Definition: SDL_dynapi_overrides.h:98

## clipboard_testGetClipboardText()

int clipboard_testGetClipboardText | ( | void * | arg | ) |

Check call to SDL_GetClipboardText.

See also
  http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText

Definition at line 38 of file testautomation_clipboard.c.

References SDL_free, SDL_GetClipboardText, SDLTest_AssertPass(), and TEST_COMPLETED.

{
char *charResult;
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
SDL_free(charResult);
return TEST_COMPLETED;
}
SDLTest_AssertPass
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
Definition: SDL_test_assert.c:94
SDL_GetClipboardText
#define SDL_GetClipboardText
Definition: SDL_dynapi_overrides.h:99
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
TEST_COMPLETED
#define TEST_COMPLETED
Definition: SDL_test_harness.h:53

## clipboard_testHasClipboardText()

int clipboard_testHasClipboardText | ( | void * | arg | ) |

Check call to SDL_HasClipboardText.

New/updated tests: aschiffler at ferzkopp dot net

See also
  http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText

Definition at line 22 of file testautomation_clipboard.c.

References SDL_HasClipboardText, SDLTest_AssertPass(), and TEST_COMPLETED.

{
SDL_bool result;
result = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
return TEST_COMPLETED;
}
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9432
SDLTest_AssertPass
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
Definition: SDL_test_assert.c:94
TEST_COMPLETED
#define TEST_COMPLETED
Definition: SDL_test_harness.h:53
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:139
SDL_HasClipboardText
#define SDL_HasClipboardText
Definition: SDL_dynapi_overrides.h:100

## clipboard_testSetClipboardText()

int clipboard_testSetClipboardText | ( | void * | arg | ) |

Check call to SDL_SetClipboardText.

See also
  http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText

Definition at line 55 of file testautomation_clipboard.c.

References SDL_free, SDL_SetClipboardText, SDL_strcmp, SDL_strdup, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomAsciiString(), TEST_COMPLETED, and text.

{
char *textRef = SDLTest_RandomAsciiString();
char *text = SDL_strdup(textRef);
int result;
result = SDL_SetClipboardText((const char *)text);
SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
SDLTest_AssertCheck(
result == 0,
"Validate SDL_SetClipboardText result, expected 0, got %i",
result);
SDLTest_AssertCheck(
SDL_strcmp(textRef, text) == 0,
"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
textRef, text);
/* Cleanup */
SDL_free(textRef);
SDL_free(text);
return TEST_COMPLETED;
}
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9432
SDLTest_AssertPass
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
Definition: SDL_test_assert.c:94
SDLTest_RandomAsciiString
char * SDLTest_RandomAsciiString(void)
Definition: SDL_test_fuzzer.c:486
SDLTest_AssertCheck
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
Definition: SDL_test_assert.c:65
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
TEST_COMPLETED
#define TEST_COMPLETED
Definition: SDL_test_harness.h:53
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
SDL_strdup
#define SDL_strdup
Definition: SDL_dynapi_overrides.h:397
SDL_strcmp
#define SDL_strcmp
Definition: SDL_dynapi_overrides.h:417
SDL_SetClipboardText
#define SDL_SetClipboardText
Definition: SDL_dynapi_overrides.h:98

## Variable Documentation

## clipboardTest1

const SDLTest_TestCaseReference clipboardTest1

static

Initial value:
=
{ (SDLTest_TestCaseFp)clipboard_testHasClipboardText, "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED }
clipboard_testHasClipboardText
int clipboard_testHasClipboardText(void *arg)
Check call to SDL_HasClipboardText.
Definition: testautomation_clipboard.c:22
SDLTest_TestCaseFp
int(* SDLTest_TestCaseFp)(void *arg)
Definition: SDL_test_harness.h:67
TEST_ENABLED
#define TEST_ENABLED
Definition: SDL_test_harness.h:47

Definition at line 161 of file testautomation_clipboard.c.

## clipboardTest2

const SDLTest_TestCaseReference clipboardTest2

static

Initial value:
=
{ (SDLTest_TestCaseFp)clipboard_testGetClipboardText, "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED }
SDLTest_TestCaseFp
int(* SDLTest_TestCaseFp)(void *arg)
Definition: SDL_test_harness.h:67
TEST_ENABLED
#define TEST_ENABLED
Definition: SDL_test_harness.h:47
clipboard_testGetClipboardText
int clipboard_testGetClipboardText(void *arg)
Check call to SDL_GetClipboardText.
Definition: testautomation_clipboard.c:38

Definition at line 164 of file testautomation_clipboard.c.

## clipboardTest3

const SDLTest_TestCaseReference clipboardTest3

static

Initial value:
=
{ (SDLTest_TestCaseFp)clipboard_testSetClipboardText, "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED }
SDLTest_TestCaseFp
int(* SDLTest_TestCaseFp)(void *arg)
Definition: SDL_test_harness.h:67
clipboard_testSetClipboardText
int clipboard_testSetClipboardText(void *arg)
Check call to SDL_SetClipboardText.
Definition: testautomation_clipboard.c:55
TEST_ENABLED
#define TEST_ENABLED
Definition: SDL_test_harness.h:47

Definition at line 167 of file testautomation_clipboard.c.

## clipboardTest4

const SDLTest_TestCaseReference clipboardTest4

static

Initial value:
=
{ (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED }
clipboard_testClipboardTextFunctions
int clipboard_testClipboardTextFunctions(void *arg)
End-to-end test of SDL_xyzClipboardText functions.
Definition: testautomation_clipboard.c:86
SDLTest_TestCaseFp
int(* SDLTest_TestCaseFp)(void *arg)
Definition: SDL_test_harness.h:67
TEST_ENABLED
#define TEST_ENABLED
Definition: SDL_test_harness.h:47

Definition at line 170 of file testautomation_clipboard.c.

## clipboardTests

const SDLTest_TestCaseReference* clipboardTests[]

static

Initial value:
= {
&clipboardTest1, &clipboardTest2, &clipboardTest3, &clipboardTest4, NULL
}
clipboardTest4
static const SDLTest_TestCaseReference clipboardTest4
Definition: testautomation_clipboard.c:170
clipboardTest1
static const SDLTest_TestCaseReference clipboardTest1
Definition: testautomation_clipboard.c:161
NULL
#define NULL
Definition: begin_code.h:164
clipboardTest2
static const SDLTest_TestCaseReference clipboardTest2
Definition: testautomation_clipboard.c:164
clipboardTest3
static const SDLTest_TestCaseReference clipboardTest3
Definition: testautomation_clipboard.c:167

Definition at line 174 of file testautomation_clipboard.c.

## clipboardTestSuite

SDLTest_TestSuiteReference clipboardTestSuite

Initial value:
= {
"Clipboard",
NULL,
clipboardTests,
NULL
}
NULL
#define NULL
Definition: begin_code.h:164
clipboardTests
static const SDLTest_TestCaseReference * clipboardTests[]
Definition: testautomation_clipboard.c:174

Definition at line 179 of file testautomation_clipboard.c.